How do I code identify a previous periods close. So, I want my code to make reference to a previous periods candle etc.
Eg – Today Close > previous days close
If it is just daily close that you want then use DCLOSE[1] which is yesterdays close or DOPEN[1] . It is not possible to directly retrieve other values such as week close or year high for example but this recent indicator that I posted to the library might be useful to you if you want those values. Either hard code whichever section you need into a strategy or use CALL to get the values you need.
Yearly Quarterly Monthly Weekly Daily H4 H1 OHLC Lines
Unlikely common referencing of previous data, by means of brackets, DOPEN, DCLOSE, DHIGH and DLOW require parentheses to reference previous days.
DOPEN, DCLOSE, DHIGH and DLOW require parentheses
Well spotted Roberto. That is one that I always get wrong and PRT always tells me I got wrong! My previous post should read DCLOSE(1) and not DCLOSE[1].
Thanks guys, So I’ve been playing with the SUPERTREND TOUCH CODE from the forum which is:
ca1=low <= Supertrend[3,10]
ca2=close > Supertrend[3,10]
Screener[ca1 and ca2]
I want to get it to look back at the previous periods close. So the codes reads:
ca1=low <= Supertrend[3,10] //but less than previous period??
ca2=close > Supertrend[3,10]
Screener[ca1 and ca2]
Im struggling
Spider and The Fly – Please use the ‘Insert PRT Code’ button when putting code in your posts to make it easier for others to read. I have tidied up your post for you.
I will also move your topic to the screener forum as that is a more relevant place for it. 🙂
What do you mean by ‘but less than previous period??’? Do you mean the low of this bar is lower than the lowest low of yesterday?
This code will give you yesterdays lowest low:
if day <> day[1] then
YesterdaysLow = dLow(1)
endif
Im sorry, I’m very new to code.’I cant work out how to do the PRT insert.
I want the close of yesterdays candle to be lower than the close of today’s candle. I don’t know how or where to put that in the original code listed below.
ca1=low <= Supertrend[3,10] //but less than previous period??
ca2=close > Supertrend[3,10]
Screener[ca1 and ca2]
Please use the ‘Insert PRT Code’ button. I tidied up your post again!
As we are working in a screener we can use the TIMEFRAME instruction.
timeframe(daily)
ca3 = close > close[1]
timeframe(default)
ca1=low <= Supertrend[3,10] //but less than previous period??
ca2=close > Supertrend[3,10]
Screener[ca1 and ca2 and ca3]
Im trying to get the screener to show the Supertrend when it flips bearish to bullish and vice versa as opposed to just recording a touch. Does that make sense?
Thanks very much guys. I’ve worked it out with your input. Much appreciated.
Im trying to get the screener to show the Supertrend when it flips bearish to bullish and vice versa as opposed to just recording a touch.
It might have been helpful if we’d had this information from the very beginning as it is very different to your first request! 🙂
Supertrend change its colour once the Close has crossed the line.