Zigzag Code does not update automatically
Forums › ProRealTime English forum › ProBuilder support › Zigzag Code does not update automatically
- This topic has 9 replies, 3 voices, and was last updated 1 year ago by GustavoL.O.
-
-
06/21/2023 at 8:12 PM #216565
Hello,
I need to fix a problem I have with this code. The cumulative Histogram does not update the zigzag, to update I have to reset the indicator on the Intraday chart.
Thank you very much, waiting for an answer.
//PRC_CumulativeVolume ZigZag | indicator
// — parameters
percentVariation = 0.04zz = ZigZag[percentVariation](close)
peak = zz<zz[1] and zz[1]>zz[2]
tough = zz>zz[1] and zz[1]<zz[2]cumV = cumV+volume
if peak then
text = cumV/1000
//drawtext(“#text#K”,barindex[1],cumV[1]+0.17*cumV[1],Dialog,Bold,12) coloured(0,200,0)
//drawsegment(barindex[1],cumV[1]+0.20*cumV[1],previousX,previousY)
cumV = Volume
color = -1
previousX = barindex[1]
previousY = cumV[1]+0.20*cumV[1]
elsif tough then
text = cumV/1000
//drawtext(“#text#K”,barindex[1],cumV[1]+0.23*cumV[1],Dialog,Bold,12) coloured(200,0,0)
//drawsegment(barindex[1],cumV[1]+0.20*cumV[1],previousX,previousY)
cumV = Volume
color = 1
previousX = barindex[1]
previousY = cumV[1]+0.20*cumV[1]
endifreturn cumV coloured by color
06/21/2023 at 11:01 PM #216577Try increasing the units on the graph, 1000 or more.
06/22/2023 at 4:09 PM #216626Thanks! But it’s already at 10k. Zigzag does not update, it continues with a normal histogram, but when I apply the indicator again in modify indicator yes, then it resumes the correct zig zag calculation
06/22/2023 at 5:30 PM #21663106/23/2023 at 10:10 AM #216649Because the zigzag is repainting, you want the indicator calculated upon it to recalculate the past datas also. With that code, it is not possible, that would need a complete rewrite of it.
1 user thanked author for this post.
06/23/2023 at 12:33 PM #216655Hi Nicolas, thanks for the reply. (I guess the code is not strange for you right = ) ..) By the way, your indicators are great, they are amazing, thanks for sharing.
The code works very well, I like it a lot, it’s very useful for me. Only that, on intraday I often (not always) have to enter “Modify indicator” and click on “Apply to…” so that the indicator “updates” the calculation. This often plots a different current histogram than it was…What is the path, what should I do, how would this rewrite be possible?
best regards,
Gustavo06/23/2023 at 1:55 PM #216657Here are two examples, in the second screenshot after I entered Modify Incadtor and clicked Apply to… the indicator plotted the corrected cumulative histogram
06/26/2023 at 10:06 AM #216771Ok, so the below version will plot all the volumes accumulation from any top or bottom of the zigzag variation of “percentVariation”, from the current candle in the past of the chart, so it will repaint the whole indicator on each tick and therefore no need to reload it from time to time.
I introduced a setting “BarsLimit” to fix how many volumes bars to be plotted in the past.
123456789101112131415161718192021222324252627282930313233343536373839404142//PRC_CumulativeVolume ZigZag | indicatordefparam drawonlastbaronly=true// — parameterspercentVariation = 0.04BarsLimit = 200 //how many historgram to draw?// -----zz = ZigZag[percentVariation](close)peak = zz<zz[1] and zz[1]>zz[2]tough = zz>zz[1] and zz[1]<zz[2]cumV = cumV+volume$barvol[barindex]=cumv //store in an array the current volume for that bar$barcolor[barindex]=color //color of current trendif peak thencumV = Volumecolor = -1elsif tough thencumV = Volumecolor = 1endifif islastbarupdate thena = 0for i = barindex downto barindex-barslimit dor=255g=0if $barcolor[i]>0 thenr=0g=155endifdrawrectangle(barindex[a],$barvol[i],barindex[a],0) coloured(r,g,0)a=a+1nextendifreturn cumV coloured(0,0,0,0)06/26/2023 at 10:17 AM #216779For reference, just added the indicator into the library: Cumulative Volume ZigZag (live version)
1 user thanked author for this post.
07/26/2023 at 3:36 PM #218173Hello Nicolas,
thank you very much!!! I will test this! Tks!
-
AuthorPosts
Find exclusive trading pro-tools on