Page 1 of 1

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

Posted: Thu Mar 31, 2022 6:58 pm
by EveryDayBetter
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

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

Posted: Fri Apr 01, 2022 5:41 pm
by processingclouds
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.

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

Posted: Fri Apr 01, 2022 9:37 pm
by EveryDayBetter
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)