i wonder how can i add triling stop to my position
my current code take profit after 8 ticks of es contract
if marketposition > 0 then
sell next bar 0.5*position_size avgentryprice + 8 limit
how would you add a trailing stop in which will start only if the first take profit been hit + keep 4 ticks as a trailing stop ?
so if i buy 2 contracts at 1200.5 and it goes to 1202.5 i sell 1 contract and than there is a stop for 1 contract on 1201.5 and when last goes to 1202.75 the stop goes with it to 1201.75
thanks
tick trailing stop
- Marina Pashkova
- Posts: 2758
- Joined: 27 Jul 2007
Hi JoulVern,
If we understand correctly what you are trying to do, then you can use a simple sample code below:
-------------------------
Let me know if it does the job for you.
Best regards.
If we understand correctly what you are trying to do, then you can use a simple sample code below:
Code: Select all
buy("LE") 2 contracts next bar at market;
if ( marketposition = 1 ) then
sell("LX") from entry("LE") 1 contract next bar at entryprice + 8 points limit;
if currentcontracts = 1 then
begin
setstopcontract;
setdollartrailing(4*pointvalue);
end;
setstoploss( 10 * pointvalue );
Let me know if it does the job for you.
Best regards.