Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Pinescript Beginner Strategy not generating orders?

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

It generates an order but you don’t close your position. So, it is always in a position.

enter image description here

You should use strategy.exit() or strategy.close() to exit your position.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading