EveryDayBetter
Pine Script Master
Pine Script Master
Posts: 27
Joined: February 16th, 2022

How to define as another buy condition, that there wasn't made a trade in this stock in 40 days?

How is it possible to define it as another buy condition, that there wasn't made a trade in this stock in X days? For instance X = 40

processingclouds
Pine Script Master
Pine Script Master
Posts: 115
Joined: January 30th, 2022

Re: How to define as another buy condition, that there wasn't made a trade in this stock in 40 days?

Your question is very vague and not clear at all.
'Another buy condition'
'No trade in 40 days'
' X = 40 '

If you are referring to a script that you have, it would be better to show that and than maybe its easier to understand what you would like the script to do.

EveryDayBetter
Pine Script Master
Pine Script Master
Posts: 27
Joined: February 16th, 2022

Re: How to define as another buy condition, that there wasn't made a trade in this stock in 40 days?

Yes, thank you for the hint. I've put my thoughts in order ;) Is this better for understanding? Relevant is only the "ANOTHER BUY CONDITION"

Code: Select all

sma50 = ta.sma(close, 50)
sma150 = ta.sma(close, 150)

plot(sma50, color=color.new(#000000, 0), linewidth=4, title='SMA 50')
plot(sma150, color=color.new(#76EE00 , 0), linewidth=4, title='SMA 150')

 ANOTHER BUY CONDITION = ??? //in this stock, the last 40 days wasn't made a trade. The "40" shouldn't be a fix number, it also could be 60 or any other number, so it should be easy replaceable

if close < sma50 and close > sma150 and ANOTHER BUY CONDITION
    strategy.entry('long', strategy.long)

Return to “Pine Script Q&A”