Hello Community
For educational purpose, i am trying to code a script where the lowest[x](low) in previous bars could acts as a strategy stop loss
Additionally, the distance between tradeprice and stop loss price would be the Target Profit. I coded the following but seems it doesnt’t do the job.
IF myconditons AND NOT ONMARKET THEN
BUY 1 CONTRACTS AT MARKET
LowestPrice = lowest[12](low)
ENDIF
IF ONMARKET THEN
if (close < LowestPrice) then
SELL AT MARKET
ENDIF
ENDIF
IF ONMARKET THEN
TargetProfit = TradePrice - LowestPrice
SET TARGET PPROFIT TargetProfit
ENDIF
I would be grateful if you can explain me why this code doesn’t work properly, cause i can run up my learning curve.
Thank you!
Ok it seems to be fixed. I added the NOT ONMARKET condition (edited the previous post) in the first row and it does the job. Sorry for double-posting but my internet connection is a bit weak today.