Prevent the rectangle from being drawn continually, only at each new bar.

Forums ProRealTime English forum ProBuilder support Prevent the rectangle from being drawn continually, only at each new bar.

Viewing 15 posts - 1 through 15 (of 18 total)
  • #214284

    Hi together,

    I want to draw a rectangle after each new bar (timeframe 30 minutes) and not every time the loop is run and the conditions are true.

    I’ve already tried a few things (bar index, etc.) and have not come to a satisfying result.

    Does anyone have an idea?

    I can also provide the complete code. (Calculations of the arrays – positions of the rectangle based on the Meander band).

    Thanks

     

    #214448

    You should add a 2-element array named $myTime (or whatever name you like) to prevent arrays from being continuously updated, as they are not historicized, unlike common variables:

    #214449

    I think that to get a perfect and neat answer to your query, you should provide the complete code.

    I understand that you plot the rectangles in the past from the current bar, right?

    Did you use:

    DEFPARAM DRAWONLASTBARONLY=TRUE

    for that purpose ?

    #214463

    Your solution with the $myTime array is a good approach to get around this problem. I basically store the current time value in an array and then compare it to the previous stored value to determine if the current candle is a new one. If the current candle is new, the main code is executed, if I understand it correctly.

    Thanks, I will try that. 🙂

    #214464

    Hi Nicolas,

    Thanks for your answer!

    Yes I use DEFPARAM DRAWONLASTBARONLY=TRUE

    It’s also a Multitimeframe approach which takes into account the Waddah-Attar-Explosion in the H1 Chart, which i use in a modified version (better bollinger band).

    I’ll try the solution of robertogozzi and then I’ll post the complete code.

    #214472

    Here is the code without the extension.

    #214477

    And here is the updated version. Did I miss something? I’m going to test it.

    #214492

    Well, I did not get anything plotted on the chart. There is an error of multiple assignment of the “counter” variable through different timeframes (which is not possible), so you have to change it in one of the timeframe (because I don’t think they are related to each other, you are using it in your loop).

    My question is: why do you want to plot only one time on the current bar? Is it related to performance of calculation?

    Some tips:

    1/ in order to get an huge performance increase, make your calculation only when the last bar of the chart update by encapsulate the parts of the code that plot in the past with a condition: IF ISLASTBARUPDATE THEN … ENDIF

    2/ to plot only one time per bar, check if the OPENTIMESTAMP is different from the last saved one:

     

    1 user thanked author for this post.
    #214514

    Thanks for your answer.

    Did you add the 3 variables (booleans)?

    For me it works, I attached the ITF-File to import.

    To come back to your question, because it then still looks like this. (See . PNG – Left retangle should be …)

    #214520

    Yes I added them. Got the error message about assignments of values for the same variable with different variables, with your code. No error for you??

    #214548

    Did you import the ITF-File also?

    No, no error for me, this is a live screenshot seconds ago. (DJI 30 Minutes)

    It worked all the time (except the infinite drawing during the candle-duration).

     

    #214732

    In fact, there is no problem, you are plotting 3 different rectangles on the same bar.

    The X-axis coordinates are the same, but no the Y-axis (price). If you add this line right below the DRAWRECTANGLE, it will add the number of the plotted rectangle:

    So if you consider that it can’t be more than 1 rectangle on the same bar, then do not increase you array that save the coordinates of the rectangle, just continuously save the coordinates in the same column.

    #214755

    Hi Nicolas,

    Thanks for your answer.

    When I use the extension under the draw function, no more retangle is drawn.

    I’ve shortened the code and limited it to the core function for testing. (meander calculation + drawing the rectangle).

    Unfortunately, I’ve not found a solution so far

    #214757

    Was missing in 1. Line.

    #214758

    Retangles with numbers

     

     

Viewing 15 posts - 1 through 15 (of 18 total)

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