0
votes

I am new to PineScript. I need help with a simple strategy that

Buys if the price is higher than the price at the close of the previous day.

Sells if the price is lower than the price at the close of the previous day

How can I do that? Thank you

1
Please share what you have tried so far. - Tommy
I am now going through the documentation. I am new to coding..... - Kairos777

1 Answers

0
votes

Go in the pine editor, click on new -> blank strategy script, you will have a good template for strategies, the conditions should be stated in longCondition and shortCondition.

longCondition = close > close[1]
if (longCondition)
    strategy.entry("My Long Entry Id", strategy.long)

shortCondition = close < close[1]
if (shortCondition)
    strategy.entry("My Short Entry Id", strategy.short)

Note that such strategy is already implemented under the name "Bar UpDn Strategy".