Creating my first trading bot and have overcome a lot of issues. This one doesn't seem to be on my side.
I wanted to exit a position if my stop price is lower than my profit target. I don't remember having this issue over the past 2 weeks, but today I saw this anomaly when I was reviewing the trades. Instead of exiting when the Stop Price (lite purple) was lower than the Profit Target (green) it just left the position open. No Profit Exit
As you look forward you can see that the position finally exited using the Low BB trigger I programmed. For some reason the Profit Target Stop just will not execute. I tried moving the if statement out of all other previous conditions and it still does not execute. BB Stop
Here is the code I have in my Orders section. Im targeting specifically this line, if fallingClosePrice <= profitTarget
strategy.exit(id="FPS", stop=fallingClosePrice) //Profit Target Reached.
If anyone can shed some light on this that would be great. I noticed that there was an update to Tradingview the other day and I feel like ever since then, it has not been acting the same.
if testPeriod()
strategy.entry(when = triggerTrue, id="Short", long=false, qty = posSize)
if (strategy.position_size != 0)
if BBexitEnabled and BBtimeoutDone
if BBlowTrue and close[1] < (strategy.position_avg_price)
strategy.close_all(comment="BB")
if risingTrend
if risingClosePrice <= profitTarget
strategy.exit(id="RPS", stop=risingClosePrice) //Profit Target Reached
if TSenabled
if tradeTimeoutDone
if strategy.opentrades >=3 // Trades Maxed and Timeout Done
strategy.exit(id="RSL TO", stop=risingClosePrice) // Rising Stop Loss Timeout
else if strategy.opentrades >=2 and risingClosePrice < strategy.position_avg_price // Timeout done and can BE
strategy.exit(id="RSS TO", stop=risingClosePrice) // Rising Safe Stop Timeout
else if risingClosePrice*(1.005) < strategy.position_avg_price and abs(strategy.position_size) > maxPosSize*0.9 // Positon Maxed and Timeout not Done
strategy.exit(id="RSS", stop=risingClosePrice) // Rising Safe Stop
if fallingTrend
if fallingClosePrice <= profitTarget
strategy.exit(id="FPS", stop=fallingClosePrice) //Profit Target Reached
if TSenabled
if tradeTimeoutDone
if fallingClosePrice*(1.005) < strategy.position_avg_price or abs(strategy.position_size) > maxPosSize*0.9 // Timeout done and can BE
strategy.exit(id="FSS TO", stop=fallingClosePrice, qty=abs(strategy.position_size)) //Falling Safe Stop Timeout
else if fallingClosePrice*(1.005) < strategy.position_avg_price and abs(strategy.position_size) > maxPosSize*0.9 // Positon Maxed and Timeout not Done
strategy.exit(id="FSS", stop=fallingClosePrice, qty=abs(strategy.position_size)) // Falling Safe Stop
question from:
https://stackoverflow.com/questions/65946484/is-anyone-else-having-an-issue-with-strategy-exit-not-firing 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…