The error is for longStopLoss and longTakeProfit, shortStopLoss and shortTakeProfit. I double checked the original definition and its the same. I think its because theyre part of different functions but I dont know how to fix it.
if (longCondition)
longStopLoss = close * (1 – stopLossPerc)
longTakeProfit = close * (1 + takeProfitPerc)
if (shortCondition)
shortStopLoss = close * (1 + stopLossPerc)
shortTakeProfit = close * (1 – takeProfitPerc)
if (longCondition)
strategy.entry(“Long”, strategy.long)
strategy.exit(“Take Profit/Stop Loss”, from_entry=”Long”, limit = longTakeProfit, stop = longStopLoss)
if (shortCondition)
strategy.entry(“Short”, strategy.short)
strategy.exit(“Take Profit/Stop Loss”, from_entry=”Short”, limit = shortTakeProfit, stop = shortStopLoss)
Kubuś Poz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.