Adding more position when setperecttrailing is set problem

Questions about MultiCharts and user contributed studies.
User avatar
muhaha2015
Posts: 2
Joined: 20 Oct 2020

Adding more position when setperecttrailing is set problem

Postby muhaha2015 » 27 Oct 2020

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);

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Adding more position when setperecttrailing is set problem

Postby TJ » 27 Oct 2020

See posts #1 & #2
1. [FAQ] How to Post Codes . . . so that people can read.
viewtopic.php?t=11713

User avatar
muhaha2015
Posts: 2
Joined: 20 Oct 2020

Re: Adding more position when setperecttrailing is set problem

Postby muhaha2015 » 27 Oct 2020

I see, thx for the tips

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);

User avatar
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

Postby Kate MultiCharts » 21 Dec 2020

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:

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);


Return to “MultiCharts”