Yes, so that’s what I talked about. In history your calculation is made only once because the bars are already closed. While on the current bar, until its closure, your calculation is made on each tick and on each new tick you are increasing the column number (counter in your code?) and there creating X rectangles for the same bar and they are all painted until the bar is closed.
I have trouble making the rectangles to be detected and plotted with your version, what is instrument and timeframe please?
In order for your counter to increase only a new bar, change this function like this: (checking if timestamp of the bar is newer):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Condition for rectangle
if(b[1]=1)then
BeginnRechteckLong=1
EndeRechteckLong=4
Counter=LastSet($RechteckStartBar)+1
ObereSeite=MeanderHI
UntereSeite=Middle1
// Saves the coordinates of the rectangle in array variables
To help us continually offer you the best experience on ProRealCode, we use cookies. By clicking on "Continue" you are agreeing to our use of them. You can also check our "privacy policy" page for more information.Continue