Hi,
My first post, just joined the forums. My problem was how to calculate the amount of bull,bear and no body candles on the current chart and timeframe and alert the result: Being the newbie I am would you consider this to be a good solution? It seems to be working fine. Thanks for your insight. Br, Candles.
Yes, that's OK as newbie and that's OK, if what you want is to read the whole chart, and not just since open day. But, why indicator and why not just script, and why written in OnInit and not in OnCalculate ? If it is written for indicator, you could use data from OnCalculate.
In your code, I prefer to assign value of variable bars in OnInit(), or better in OnCalculate (if the code in there) and also I should check the return value of bars, ArraySetAsSeries, and CopyRates, just in case if it fails.
int bears,bulls,no_bodys, bars=Bars(_Symbol,_Period); //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping MqlRates rates[]; bars = Bars(_Symbol,_Period); if (bars > 0 && ArraySetAsSeries(rates,true) == true) { if (CopyRates(_Symbol, _Period, 1, bars, rates) >= bars - 1) { //--- your codes
Clad to hear it is working for you :)
Br,
Candles
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
My first post, just joined the forums. My problem was how to calculate the amount of bull,bear and no body candles on the current chart and timeframe and alert the result: Being the newbie I am would you consider this to be a good solution? It seems to be working fine. Thanks for your insight. Br, Candles.