zacorbul:
I'm trying to point out the candle, on M1,with the biggest volume within an hour for every hour.
The results are puzzling, some do point out the biggest volume, some hours have none. Could you please help me out as i don't know where i'm going wrong with this.
- After the first run, "i" will only be zero, biggestM1Vol will also be zero and you conclude that bar zero is the biggest. You are trying to do it on the fly, you have to look at the old values.
- Your code breaks on any chart but the M1. iTime(NULL,PERIOD_M1,i)); You are mixing apples and oranges
- Drop everything inside your for loop and do it right.
- For chart bar "i," Find the M1 bar. Don't mix apples and oranges
- Compute the start of the hour, and find that M1 bar.
- Find the M1 with maximum volume.
- Find the corresponding chart bar. Don't mix apples and oranges
- Draw the object (deleting the old one first)
datetime TimeChart = Time[i]; int iM1 = iBarShift(NULL, PERIOD_M1, TimeChart); datetime beginningHour = TimeChart - TimeChart % 3600; int iM1Hour = iBarShift(NULL, PERIOD_M1, BeginningHour); int iMaxVol = iHighest(NULL, PERIOD_M1, MODE_VOLUME, iM1 - iM1Hour + 1, iM1); datetime highestVolume = iTime(NULL, PERIOD_M1, iMaxVol); int iChart = iBarShift(NULL, PERIOD_CURRENT, highestVolume); string objName = "volumee"+string(beginningHour); ObjectDelete(objName); ObjectCreate(objName, OBJ_TEXT, 0, Time[iChart], Low[iChart]+15*Point); ObjectSetText(objName, CharToStr(159), 30, "Wingdings", Aqua);
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
I'm trying to point out the candle, on M1,with the biggest volume within an hour for every hour.
The results are puzzling, some do point out the biggest volume, some hours have none. Could you please help me out as i don't know where i'm going wrong with this.