I would like to vary a trailing stop loss mid-trade depending on the current points ahead / behind of the trade, but I can’t seem to find the constant in the coding window function help. Does anyone know if this exists or how I can derive this value?
Thanks in advance.
Something like this?
status = close - tradeprice(1)
Simply check the difference between the current close and which price the last order was executed.
Mattias’s suggestion will only work for long positions so you will need to use the reversed calculation for short positions:
status = tradeprice(1) - close
Also if you have multiple positions open at multiple prices then it won’t work.
You should consider using COUNTOFPOSITION with POSITONPRICE or POSITIONPERF in a calculation.
COUNTOFPOSITION
POSITIONPRICE
POSITIONPERF