int OnStart(void) { long a=VolumeAverage(); Print(a); return 0; } //+------------------------------------------------------------------+ long VolumeAverage() { return ( iVolume(NULL,PERIOD_CURRENT,1)+iVolume(NULL,PERIOD_CURRENT,1)+iVolume(NULL,PERIOD_CURRENT,3)+ iVolume(NULL,PERIOD_CURRENT,4)+iVolume(NULL,PERIOD_CURRENT,5)+iVolume(NULL,PERIOD_CURRENT,6)+ iVolume(NULL,PERIOD_CURRENT,7)+iVolume(NULL,PERIOD_CURRENT,8)+iVolume(NULL,PERIOD_CURRENT,9)+ iVolume(NULL,PERIOD_CURRENT,10)+iVolume(NULL,PERIOD_CURRENT,11)+iVolume(NULL,PERIOD_CURRENT,12)+ iVolume(NULL,PERIOD_CURRENT,13)+iVolume(NULL,PERIOD_CURRENT,14)+iVolume(NULL,PERIOD_CURRENT,15)+ iVolume(NULL,PERIOD_CURRENT,16)+iVolume(NULL,PERIOD_CURRENT,17)+iVolume(NULL,PERIOD_CURRENT,18)+ iVolume(NULL,PERIOD_CURRENT,19)+iVolume(NULL,PERIOD_CURRENT,20)+iVolume(NULL,PERIOD_CURRENT,21)+ iVolume(NULL,PERIOD_CURRENT,22)+iVolume(NULL,PERIOD_CURRENT,23)+iVolume(NULL,PERIOD_CURRENT,24)+ iVolume(NULL,PERIOD_CURRENT,25)+iVolume(NULL,PERIOD_CURRENT,26)+iVolume(NULL,PERIOD_CURRENT,27)+ iVolume(NULL,PERIOD_CURRENT,28)+iVolume(NULL,PERIOD_CURRENT,29)+iVolume(NULL,PERIOD_CURRENT,30)+ iVolume(NULL,PERIOD_CURRENT,31)+iVolume(NULL,PERIOD_CURRENT,32)+iVolume(NULL,PERIOD_CURRENT,33)+ iVolume(NULL,PERIOD_CURRENT,34)+iVolume(NULL,PERIOD_CURRENT,35)+iVolume(NULL,PERIOD_CURRENT,36)+ iVolume(NULL,PERIOD_CURRENT,37)+iVolume(NULL,PERIOD_CURRENT,38)+iVolume(NULL,PERIOD_CURRENT,39)+ iVolume(NULL,PERIOD_CURRENT,40)+iVolume(NULL,PERIOD_CURRENT,41)+iVolume(NULL,PERIOD_CURRENT,42)+ iVolume(NULL,PERIOD_CURRENT,43)+iVolume(NULL,PERIOD_CURRENT,44)+iVolume(NULL,PERIOD_CURRENT,45)+ iVolume(NULL,PERIOD_CURRENT,46)+iVolume(NULL,PERIOD_CURRENT,47)+iVolume(NULL,PERIOD_CURRENT,48)+ iVolume(NULL,PERIOD_CURRENT,49)+iVolume(NULL,PERIOD_CURRENT,50))/50; } //+------------------------------------------------------------------+
apirakkamjan:
Thank you very much for the correction of the codes sir. It works! God bless you more and more for your generosity.
iVolume(NULL,PERIOD_CURRENT,1)+iVolume(NULL,PERIOD_CURRENT,1)+iVolume(NULL,PERIOD_CURRENT,3)+
Typo- Don't copy and paste code, write a loop.
double VolumeAverage(int iBar=1, int count=50) { double sum = 0.0; for(int iEnd = iBar+count; iBar < iEnd; ++iBar) sum += iVolume(NULL,PERIOD_CURRENT,iBar); return sum / count; }
apirakkamjan:
Thank you very much for the correction of the codes sir. It works! God bless you more and more for your generosity
whroeder1:
Thank you very much for being so generous to me. Your code works! God bless you more...
- Typo
- Don't copy and paste code, write a loop.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello everyone, good day!
I am starting making an EA and I just want to include the Volumes on every candles. I just wanna ask some help in making codes for a function that will return the Average Volume of the last 50 candlesticks so that it can add and refine the present strategies in opening positions. I hope some generous people here can help me with the codes. I have started the codes but it didnt work. Maybe i missed some analysis in it. God Bless you all.