drawonlastbaronly = false

Forums ProRealTime English forum ProBuilder support drawonlastbaronly = false

Viewing 8 posts - 1 through 8 (of 8 total)
  • #198163

    Hello,

    If I am using (defparam drawonlastbaronly = false) in my code on hourly intraday Main indicator. How do I confine a sub-code of the indicator to printing results on today and previous day’s candles ONLY.

    Note:

    I am using DEFPARAM CALCULATEONLASTBARS = 300 so the chart so the primary purpose of my indicator is to show results on last 300 bars. But have a sub-code that I only want to show results on current trading day (hourly chart 24 bars) and previous trading day only. So basically 48 bars only

    #198164

    Hi –  I don’t think that is possible. OK, it probably will be possible to initially draw on the first 48 hours (bars) only, but after that the next bar (current hour) will be drawn and the 48th “draw” will shift to the 49th and so on. So if you wait a day with a running PRT platform and not re-initialising the chart, you’d have 60 hours drawn with the indicator (6 hours less because the platform runs 18 hours n a row only 😉 )
    Would that be a bad thing ? hence why the 48 bars only ?

    If it is for speed (cpu cycles) then filtering this way will not be an issue / won’t make any difference to speed.

     

    CALCULATEONLASTBARS = 300 so the chart so the primary purpose of my indicator is to show results on last 300 bars. But have a sub-code that I only want to show results on current trading day (hourly chart 24 bars) and previous trading day only.

    Assumed that your indicator involved draws on the Price part of the Chart, just make a second Indicator with a  CalculateOnLastbars = 48 ?
    It would behave the same as I described above.

    #198165

    I could always simply create a separate indicator just for the sub-code and set it to CALCULATEONLASTBARS = 48 and problem solved but was just wondering if I could achieve this inside the one indicator that has CALCULATEONLASTBARS = 300

    #198167

    Let me ask the question in another way:

    Irrespective of which intraday timeframe chart I am on, what is the best way of telling an indicator to drawtext only on most recent 2 trading days of candles (today and yesterday). beyond that no print.

    #198171

    Weren’t you involved in that topic where the alpha value of the Coloured clause was manipulated to 0 (invisible) ? So that. It would still be drawing, but with Alpha to 0 it would be invisible (100% transparency).
    Coloured (255,40,255, 0)   // The 4th parameter is the Alpha value.

    And that of course under an If condition, that 4th parameter being a variable.

    Pseudo code :

    AlphaValue = 255
    If BarIndex – XYZ > 48 then   // Your test for less than 49 bars passed.
    AlphaValue = 0
    Endif
    DrawText/DrawUpArrow/etc. … Coloured (255,40,255,AlphaValue)
    or
    Return Indicator1 Coloured (255,40,255,AlphaValue)

     

    Would that be sufficient for you ?

     

    PS: Remember, this will not prevent the 49th bar back (and beyond) to be seen in live after the chart initiated and an other hour passed.

    beyond that no print

    So that would be a challenge I think.

    #198173

    Available options:

    1. DEFPARAM DrawOnLastBarOnly=FALSE will draw at ANY bar; what is plotted can never be later undone
    2. DEFPARAM DrawOnLastBarOnly=TRUE will draw at ANY bar ALL data you need.

    You can plot some data for the last 300 bars and some additional data for the last 30 bars (numbers can be any of your choice) by using arrays. You can store some data in one or more 300-element array and some data in one or more 30-element array. Plot them at any bar with option 2.

     

    #198192

    Hi trader..

    My first thought is why don’t you want to set ‘DrawOnLastBarOnly to true’.

    Secondly, unless i’m mistaken, doesn’t ‘calculateOnLastBars’ just delays the start of code execution if you’ve got billion historical bars loaded. But from a displaying perspective, each new bar still add to any existing result line, so would display 300+ bars anyway.

    In your later comments about having a 2nd indicator for 48bars, this would still display 48+ bars if ‘drawOnLastBarOnly = false’. Setting to true, would solve your problem , but that leads me back to my first thought!.

    Regarding your 24/48 bar problem, and in addition to the other commented problems in doing it, i’ll add that to display over the last ‘n’ bars only, you need to know the last bar. Roberto’s array’s does that because the last ‘n’ entries would align up to the one’s you want. Alternatively the code below does it by looping after ‘lastBarUpdate’.

    Further to ‘any timeframe’ comment, determine the timeframe; which of 48 bars, current bar is on; loop over the relevant bars/values after ‘isLastbarUpdate’; and of course,  ‘drawOnLastBarOnly = true;

    I’ll just say this, when you state 24,48 bars and today and tomorrow, what are you referring to. Though there are 24hrs in a day, current their are only 13 bars today at this time. So, today and tomorrow would currently equate to 37 bars, if we go by 48bars, this could cover bars over three days. not just today/tomorrow. Don’t get me started at the weekend and market close scenario’s.

    It’s a 50/50 choice, next time pick ‘true’!

    All the best

    #198196
    Seems I’am mistaken about what is drawn when using ‘calculateOnLastBars’ and it doesn’t add to existing result lines.

    Secondly, unless i’m mistaken, doesn’t ‘calculateOnLastBars’ just delays the start of code execution if you’ve got billion historical bars loaded. But from a displaying perspective, each new bar still add to any existing result line, so would display 300+ bars anyway.

    In your later comments about having a 2nd indicator for 48bars, this would still display 48+ bars if ‘drawOnLastBarOnly = false’. Setting to true, would solve your problem , but that leads me back to my first thought!.

Viewing 8 posts - 1 through 8 (of 8 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login