Order exec as a condition to set variable to different value

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
smashthepound
Posts: 82
Joined: 20 Jun 2009
Been thanked: 1 time

Order exec as a condition to set variable to different value

Postby smashthepound » 10 Jan 2010

Dear All,

maybe anyone has come across this problem:

I would like to set a variable to a different value once a stop order has been executed, e.g.

Variables:
...
tStop (false) ,
tStop.jdw (0) ;

...
if (@MarketPosition (00) = -01) then begin
...
then begin
sx.Price = LoLo + (EntryPrice - LoLo) * sx.TStopPct ;
Buy To Cover ("sx.tStop%") next bar at sx.Price stop ;

tStop = true ;
tStop.jdw = jdw ;


end ;

Please note that this serves just as an example an is not complete. I would like to change the value for the variable tStop and tStop.jdw once the stop order is executed.

I am not sure is this works. Maybe I am missing something or maybe there is another way to do this, e.g. to look up the name of the last order executed and if this is the trailing stop order "sx.tStop%" to change the value of the variables tStop and tStop.jdw upon this condition.

The purpose shall be that I want to use the variables as conditions for a re-entry after I got stoped out of an profitable directional trade by an trailing stop, e.g. I did set the trailing stop to tight for some of the trades.

Thanks for your help.

Return to “User Contributed Studies and Indicator Library”