Why is so hard just to close a position in PineScript

I been trying so hard to just close a position. but still not able to just close it.

For example if I enter a long position, and when reach the stoploss condition, just close it, as simple as it. But after so many tries, it’s still not able to completely just close a position.

what is going on?

if (isLong1)
    strategy.close("Short_Entry_1",qty_percent = 100)
    strategy.entry("Long_Entry_1", strategy.long)
if (isLong2)
    strategy.entry("Long_Entry_2", strategy.long)
if (isShort1)
    strategy.close("Long_Entry_1",qty_percent = 100)
    strategy.entry("Short_Entry_1", strategy.short)
if (isShort1)
    strategy.entry("Short_Entry_2", strategy.short)


// stop-loss levels
if (longStopLoss)
    strategy.close("Long_Entry_1", qty_percent=100)

if (longStopLoss)
    strategy.close("Long_Entry_2", qty_percent=100)

if (shortStopLoss)
    strategy.close("Short_Entry_1", qty_percent=100)

if (shortStopLoss)
    strategy.close("Short_Entry_2", qty_percent=100)

  • thank you for refine my question.:) i am a newbies.

    – 

Leave a Comment