hello
I’m looking to code a trailing stop based on previous lows for long positions and previous highs for short positions.
I tested the following code for long positions which used price as the number of bps from the open;
if longonmarket then
SET STOP trailing lowest[5](low)
endif
I then tried the following, which didn’t seem to work either;
if longonmarket then
SET STOP trailing (close - lowest[a](low))
endif
I’d greatly appreciate any tips or suggestions on how to solve this.
Best
Chris
You should avoid using the trailing stop internal function and prefer a coded one with STOP/LIMIT orders. An example in this blog article: Create stoploss with indicator informations in ProOrder
For a long order, your moving stoploss could be set like this:
if longonmarket then
sell at lowest[5](low) stop
endif