Highest high and highest low of previous days and of specific schedules

Viewing 9 posts - 31 through 39 (of 39 total)
  • Author
    Posts
  • #85632 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Flags and conditions do both may qualify either as true or false, thus easily tracked using GRAPH, the difference is that a condition is a test between two (sometimes even more) data, such as “close > close[1]” or “close CROSSES OVER Rsi[14]”, while a flag is a signal such as “flag” in this example or “daysforbidden” in some strategies when you do not want to trade or “TradeON” and so on….

    In the code

    daysforbidden = OpenDayOfWeek < 1 OR OpenDayOfWeek > 5

    “OpenDayOfWeek < 1 OR OpenDayOfWeek > 5” is the condition to be checked and you can graph it with

    GRAPH OpenDayOfWeek < 1 OR OpenDayOfWeek > 5

    it will yieald a True/False logical value assigned to DAYSFORBIDDEN, which is a flag (and you can GRAPH it by itself, without having to write the longer line above), like a traffic lights, they are a flag to signal that some time has passed (the condition previously set) since it changed colour and needs to be changed again, you see the flag changing colour.

    It is a common variable that may be either true or false, you can use any name, flag is just a nickname to make it easier to understand that it signals something.

    “pi = 3.14” is not a flag, PI is just a common variable holding a numeric value, not a logical value.

    The above code could have been written

    if time = 210000 then
       TradeOrNot = 1
    endif
     .
    //
    IF NOT LongOnMarket AND TradeOrNot and time = 143000 THEN
     .
     .
    ENDIF
     .
    //later:
    if time = 203000 then
       TradeOrNot = 0
    endif

    I hope I understood what you meant.

    #85633 quote
    GraHalGraHal
    Participant
    Legend

    I hope I understood what you meant.

    Yes you did!

    Thank you for the comprehensive explanation.

    I’ve achieved same result in a long-winded way …  but I’ll set a flag / signal next time in my coding.

    Cheers
    GraHal

    #91942 quote
    MrCrousMrCrous
    Participant
    Average

    Hello,

    Thank you for code on how to get previous day high / low.

    But still, I dont understand this line :

    ll=close*1000

     

    Why do you set the variable to close * 1000 ?

     

    Thank you,

    #91944 quote
    MrCrousMrCrous
    Participant
    Average

    PS : Nothing is displayed on daily or even lower timeframes. Version is 10.3 and I apply the indicator on the price as recommended. Do you have any idea please ?

    #91946 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    close * 1000 is just a way to assign variables all and ll a very high value the first time or whenever they needs to be reset, so that Min() can later assign them a correct value, I prefer writing ll=999999, but both achieve the same goal.

    To be able to enter any trade you must launch it from a TF whose candles close on anyone of the times in the strategy. If you refer time 143000, then you can only use a TF <= 30 minutes, if you want to use the Daily TF… you need to change the code but you will probably write another strategy.

    #91952 quote
    MrCrousMrCrous
    Participant
    Average

    Hello,

     

    Sure, for the min() function, I found it out a few minutes after ^^

    I changed the hours to use it on DAX :

    starthour = 013000
    endhour = 220000

     

    But still, even on 30 15 5  min or 1h, notjing is displayed.

     

    I just changed these hours.

    Thank you,

    #91954 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    You should post your code, so I can replicate it.

    #92178 quote
    MrCrousMrCrous
    Participant
    Average

    Hello,

     

    Here is my code :

    starthour = 013000
    endhour = 220000
     
    count = today-date
     
    tcondition = time>=starthour and time<=endhour
     
    if count<=5 and count>0 then
    if tcondition then
    hh=max(hh,high)
    ll=min(ll,low)
    endif
    if tcondition[1] and not tcondition then
    drawhline(hh) coloured(0,255,0)
    drawhline(ll) coloured(255,0,0)
    hh=0
    ll=close*1000
    endif
    endif
     
    return
    

    I think the starthour format is not working…

     

    But I found this approach more satisfying :

    Configuration – Plus Haut & Plus bas précédent

    #92217 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    It’s beacuse the condition COUNT in line 4 is always 0, since both TODAY and DATE return the same value.

    Also, bear in mind that math applied to dates does not yield correct result (as in spreadsheets), TODAY – 30 will not return the date of 30 days ago, if today is 20190220, it will return 20190190.

Viewing 9 posts - 31 through 39 (of 39 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Highest high and highest low of previous days and of specific schedules


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
PVPRO @pvpro Participant
Summary

This topic contains 38 replies,
has 6 voices, and was last updated by robertogozzirobertogozzi
7 years, 8 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 09/24/2018
Status: Active
Attachments: 2 files
ProRealCode ProRealCode
Loading...