Hi, I have a question about adding more open position when setperecttrailing is set,
I am stuck for over a week and can't find the solution. I will be very appreciate if you may help.
When I have an open position (entry1) with setpercenttrailing filled.
Then I have a limit order (entry2) above or below the entryprice.
Then the price meet the trailing profit and keeps going to touch the limit order (entry2) price.
The limit order (entry2) filled and the setpercenttrailing stop price filled at the same time.
How can I solve this?
I want to keep both open position and the setpercenttrailing stop order instead of flatting them all.
Many Thanks.
I am using IB and here is my code:
if marketposition = 0 then
Buy ( "entry1" ) 1 contracts next bar at market ;
if currentcontracts = 1 then
Buy ( "entry2" ) 2 contracts next bar at entryprice + 3 limit;
SetStopPosition;
setpercenttrailing_pt(12,30);
setstoploss_pt(20);
Adding more position when setperecttrailing is set problem
- muhaha2015
- Posts: 2
- Joined: 20 Oct 2020
- TJ
- Posts: 7740
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2221 times
- muhaha2015
- Posts: 2
- Joined: 20 Oct 2020
Re: Adding more position when setperecttrailing is set problem
I see, thx for the tips
Heres the code not working
Heres the code not working
Code: Select all
if marketposition = 0 then
Buy ( "entry1" ) 1 contracts next bar at market ;
if currentcontracts = 1 then
Buy ( "entry2" ) 2 contracts next bar at entryprice + 3 limit;
SetStopPosition;
setpercenttrailing_pt(12,30);
setstoploss_pt(20);
- Kate MultiCharts
- Posts: 575
- Joined: 21 Oct 2020
- Has thanked: 7 times
- Been thanked: 144 times
Re: Adding more position when setperecttrailing is set problem
Hello muhaha2015,
As soon as the Entry order or Trailing Stop is filled, the other orders of the group will be canceled. After that the Trailing Stop will start monitoring the activation price again.
It will not be possible for the Trailing Stop to be active while the second Entry order is being filled.
You can try using setstopcontract mode. In that case the Trailing Stop for the first Entry order will continue moving after the second Entry order is filled. Also another Trailing Stop for the second Entry order will be added.
Here is the example:
As soon as the Entry order or Trailing Stop is filled, the other orders of the group will be canceled. After that the Trailing Stop will start monitoring the activation price again.
It will not be possible for the Trailing Stop to be active while the second Entry order is being filled.
You can try using setstopcontract mode. In that case the Trailing Stop for the first Entry order will continue moving after the second Entry order is filled. Also another Trailing Stop for the second Entry order will be added.
Here is the example:
Code: Select all
once cleardebug;
if marketposition = 0 then
begin
Buy ( "entry1" ) 1 contracts next bar at market ;
end;
if currentcontracts = 1 then
begin
print(entryprice );
Buy ( "entry2" ) 2 contracts next bar at entryprice + 3 limit;
end;
setstopcontract;
//setstopposition;
setpercenttrailing_pt(12,30);
setstoploss_pt(20);