I am a total beginner in Pinescript, and I tried to create a super-simple strategy to enter a long position whenever a new low pivot point is higher than the previous pivot point. However, this strategy does not generate any orders. Any help would be much appreciated.
//@version=5
strategy("HigherLows", overlay=true, margin_long=100, margin_short=100)
int leftleg = input(3)
int rightleg = input(3)
var float newLow = na
var float prevLow = na
pivotLowPrice= ta.pivotlow(leftleg, rightleg)
if not na(pivotLowPrice)
newLow := pivotLowPrice
if not na(prevLow)
if newLow > prevLow
strategy.entry("Long", strategy.long, 1)
prevLow := pivotLowPrice
>Solution :
It generates an order but you don’t close your position. So, it is always in a position.
You should use strategy.exit() or strategy.close() to exit your position.
