Zigzag Cumulative Volume Tweaking Needed

 

Hi there brothers.


I think I opened a thread in the wrong forum, I am opening here then, which is the right place.


I have this indicator here which I found at forexfactory called zigzag counter, which displays the total volume of each leg of the zigzag.


What I wanted was for it to show the AVERAGE volume of each leg, not the total sum. Because the total sum does not give a real reading, for example, if you have one up swing with a leg formed by 4 bars, each bar with 2000 volume so total 8000, then you have a down swing with a leg made of 3 bars, two bars with 3000 and one with 2000, also with 8000 total. You would think that it has the same power that the up leg, but no, it is more powerful, it has 33% more power, in this case, if you calculate the average. up leg 8000/4 = 2000, down leg 8000/3 = 2.666

Can someone please tweak this indicator? I think it is easy, you just need to remove the code for summing and replace with a division code, for it to divide the total volume of the leg by the number of bars of the leg.

Thanks a lot!

Files:
 
void DrawLabel(int bar1, int bar2, double price1, double price2)
{
 int Nbar1=iBarShift(NULL, 0, bar1);  //index1
 int Nbar2=iBarShift(NULL, 0, bar2);  //index2
 int u,vol;
 for(u=Nbar2; u<Nbar1+1; u++){
   vol=(vol+Volume[u]);               //total volume
 }
 //string Str=TextFormat(Nbar1-Nbar2, price1-price2);
 string Str=vol;                      
 string obj_name=""+bar2;
 ObjectCreate(obj_name, OBJ_TEXT, 0, bar2, price2);
 ObjectSetText(obj_name, Str, FontSize, "Arial", TextColor);
 ObjectSet(obj_name, OBJPROP_PRICE1, price2);
 return;
}

Number of bars = index1 - index2

Average = total volume / Number of bars

 
Brother thank you very much for being so kind and taking a look at it. You see, I am no coder, also I don't have a clue of where I would open this file to edit the code and then save it or compile a new .mq4 file. Can you do it for me and post here??
 

Line 81

string Str = (string)(vol / (Nbar1 - Nbar2)); //string Str=vol;
 
Naguisa Unada:

Line 81

Hi!!

Thanks Naguisa, but I still have no clue of how to edit it, don't I need a software to do that?

So what should I do now? Do I open the mq4 file one the notepad and edit there? 

Perhaps I wasn't clear, but what I asked was, if you or anyone be so kind, open the file I posted in the proper editor, remove the summing code and add this code to display average volume, then save the new file and post it here for anyone to download. I obviously do not know how to do it.
 

Someone was kind enough to tweak the indicator, here is the file, enjoy.

 
beto_gauer: Can someone please tweak this indicator? I think it is easy,

You don't know how to code, but the changes are easy? That's like saying "I don't know how to build engines but adding another cylinder should be easy; it's just one more."
          Is it easy (or difficult) to …? - General - MQL5 programming forum #2 2017.08.31

Reason: