- Direction
for(int i = 0; i < limit; i++){ int iTF = iBarShift(Symbol(), TimeFrame, Time[i]); Stoch_0 = iCustom(Symbol(), TimeFrame, "..., iTF); GMACDL_0 = iCustom(Symbol(), gmacdTimeFrame, "..., iTF);
For TimeFrame you get the correct shift for Stoch, but don't for GMACDL - Direction
int counted_bars=IndicatorCounted(); int barsCount = CalcBars(TimeFrame); int limit; if(counted_bars>0) counted_bars--; //limit=Bars-counted_bars; limit = barsCount - counted_bars;
Drop your barsCount and use Bars. You are painting the indicator on the CURRENT CHART. You are confusing where the data comes from (TimeFrame) with the chart's TF. - Contradictory information on IndicatorCounted() - MQL4 forum
WHRoeder:
- DirectionFor TimeFrame you get the correct shift for Stoch, but don't for GMACDL
- DirectionDrop your barsCount and use Bars. You are painting the indicator on the CURRENT CHART. You are confusing where the data comes from (TimeFrame) with the chart's TF.
- Contradictory information on IndicatorCounted() - MQL4 forum
Thank you for your answer.
Using Bars instead of barsCount does not solve the problem. I need to obtain the results of Stochastic using the TimeFrame I passed as an argument and GMACD using one unit lower TF. I get confusing results. For example, when I draw all of them on a chart I see that Stochastic is upper than Stoch_singnal and GMACD_Line is also upper than GMACD_Signal, but I get the yellow or red bar on Direction indicator.
Thanks again
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!
I have a problem I could not solve myself.
I need to construct an indicator which uses 2 other indicators (MACD and Stochastic) and returns the result based on the combination of results.
In particular, if for a given bar MACD_Line > MACD_Sig, I have MACD_UP = true, in a similar vein if MACD histogram is green I have MACD_Green = true, otherwise MACD_Red = true;
and one stochastic indicator behaving exactly the same way as MACD line. Stoch_Line > Stoch_Sig, then Stoch_Up = true;
My indicator (Direction) draws bars depending on the combination of results. Green, Red and yellow bars are drawn depending on MACD_Up, MACD_Green and Stoch_Up variables.
But the Stochastic indicator timeframe should be based on the parameter value which I pass and the MACD (both - line and histogram) timeframe should be based on one unit less timeframe. For example, for D1 argument,
Stochastic is calculated for D1 and MACDs for H4. Similarly, For H4 - Stoch (H4) and MACD(H1), etc...
The problem is that the MACD and Stochastic indicators are using strictly defined functions like Bars inside them so I receive incorrect results.
Can anyone help? I'm uploading the files if anybody can discover what am I doing wrong or what path should I take...
Many thanks in advance!
David