coding for previous period

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #96913 quote
    Spider and The Fly
    Participant
    New

    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

    #96917 quote
    Vonasi
    Moderator
    Master

    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

    #96919 quote
    robertogozzi
    Moderator
    Master

    Unlikely common referencing of previous data, by means of brackets, DOPEN, DCLOSE, DHIGH and DLOW require parentheses to reference previous days.

    #96920 quote
    Vonasi
    Moderator
    Master

    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].

    #96921 quote
    Spider and The Fly
    Participant
    New

    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
    #96924 quote
    Vonasi
    Moderator
    Master

    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. 🙂

    #96926 quote
    Spider and The Fly
    Participant
    New

    Thanks very much

    #96927 quote
    Vonasi
    Moderator
    Master

    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?

    #96929 quote
    Vonasi
    Moderator
    Master

    This code will  give you yesterdays lowest low:

    if day <> day[1] then
    YesterdaysLow = dLow(1)
    endif
    
    #96932 quote
    Spider and The Fly
    Participant
    New

    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]
    #96933 quote
    Vonasi
    Moderator
    Master

    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]
    #96934 quote
    Spider and The Fly
    Participant
    New

    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?

    #96938 quote
    Spider and The Fly
    Participant
    New

    Thanks very much guys.  I’ve worked it out with your input. Much appreciated.

    #96940 quote
    Vonasi
    Moderator
    Master

    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! 🙂

    #96959 quote
    Nicolas
    Keymaster
    Master

    Supertrend change its colour once the Close has crossed the line.

Viewing 15 posts - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.

coding for previous period


ProScreener: Market Scanners & Detection

New Reply
Author
Summary

This topic contains 14 replies,
has 4 voices, and was last updated by Nicolas
6 years, 11 months ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 04/22/2019
Status: Active
Attachments: No files
Logo Logo
Loading...