Edas:
EA shall store the values in an Array or simply use iCustom() function from mql to read values from your indicator directly.
I would be careful of putting "bar-number-position-from-current-bar" anywhere - they change with as each new bar!
Techniques I use are
a) bar-number-from-oldest-bar. This only changes if new history brought in, which will trigger (I hope) complete recalc from oldest bar
b) a relative bar number ("special bar is 4 older than me")
c) a count since specialbar - which is an example of b). I use this to track 'how many bull candles are in this sequence?" by having BufferBullCandlesCount[] and BufferBearCandlesCount[]. When I get a Bull Candle, I set BufferBearCandlesCount[i]=0; and set BufferBullCandlesCount [i]=BufferBullCandlesCount [i+1]+1;// with special case for oldest bar!
Hi folks,
Thanks for advices.
I tried to use Time[PivotBar] as solution.
Partially it works, however results are a little incorrect.
Programming algorithm
First, I find high bar number and high value using function:
bool isHighPivotBar = HighPivotPip(MaxCalc, LeftStrenPip, RightStrenPip, MaxCalc);
//This function is like Zigzad - LeftStrenPip & RighStrenPip - Zigzag values in pips. Maxcalc - what is maximum bars to both sides (left and right ) to calculate
if (isHighPivotBar) //is high Pivot is found, lets remember this Pivot's time and value. Also let's save older values to array.
{
HighBarTime[3] = HighBarTime[2];
HighBarTime[2] = HighBarTime[1];
HighBarTime[1] = Time[MaxCalc];
HighPivot[3] = HighPivot[2];
HighPivot[2] = HighPivot[1];
HighPivot[1] = High[MaxCalc];
}
What is strange, that these array values does not work well. Below is screenshot.
Arrows show Bar time and High values.
You could compare Pivot info text with real values.
Last High Pivot is 1.3506 - OK
Previous Pivot 1.3440 -OK
Next previous Pivot 1.3440 - (the same) Bad (should be 1.3160)
I checked array numbers, they are ok.
Similar situation is with time. Difference is that last and previous pivots time are OK, but second previous is incorrect :dublicates with previous (does not fit to info string.
By the way, in indicator similar code works OK.
What is the matter ?
Thanks in advance,
Edas
Hi folks,
Thanks for advices.
I tried to use Time[PivotBar] as solution.
Partially it works, however results are a little incorrect.
Programming algorithm
First, I find high bar number and high value using function:
bool isHighPivotBar = HighPivotPip(MaxCalc, LeftStrenPip, RightStrenPip, MaxCalc);
//This function is like Zigzad - LeftStrenPip & RighStrenPip - Zigzag values in pips. Maxcalc - what is maximum bars to both sides (left and right ) to calculate
if (isHighPivotBar) //is high Pivot is found, lets remember this Pivot's time and value. Also let's save older values to array.
{
HighBarTime[3] = HighBarTime[2];
HighBarTime[2] = HighBarTime[1];
HighBarTime[1] = Time[MaxCalc];
HighPivot[3] = HighPivot[2];
HighPivot[2] = HighPivot[1];
HighPivot[1] = High[MaxCalc];
}
What is strange, that these array values does not work well. Below is screenshot.
Arrows show Bar time and High values.
You could compare Pivot info text with real values.
Last High Pivot is 1.3506 - OK
Previous Pivot 1.3440 -OK
Next previous Pivot 1.3440 - (the same) Bad (should be 1.3160)
I checked array numbers, they are ok.
Similar situation is with time. Difference is that last and previous pivots time are OK, but second previous is incorrect :dublicates with previous (does not fit to info string.
By the way, in indicator similar code works OK.
What is the matter ?
Thanks in advance,
Edas
hOW CAN YOU PUT STOP LOSS BEHEIND OF THOSE ARROWS YOU HAVE IN YOUR CHART? I KNOW OYUR STRATEGY IS DIFFERENT, BUT LOOKING AT YOUR CHART, I ASKED THAT BECAUSE i USE CCI ARROWS AND I AM TRYING TO SET UP A STOP LOSS BEHEIND OF THAT.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- 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,
I wrote indicator which works many with bar number.
Example of code is below:
for (Bar = limit; Bar >= 0; Bar--) //all bar cycle
{
//some code here
for (int i=4; i>=2; i--) //shifting Highs and Bar Numbers in Array
{
HighBar[i] = HighBar[i-1];
HighPivot[i] = HighPivot[i-1];
LowHighBar[i] = LowHighBar[i-1];
LowHighPip[i] = LowHighPip[i-1]; } //shifting Highs and Lows in array
HighBar[1] = Bar; //Last HighBar Bar number is remembered
HighPivot[1] = High[Bar]; //High value of Bar is remembered
LowHighBar[1] = LowBar[1] - HighBar[1];
LowHighPip[1] = HighPivot[1] - LowPivot[1];
I want to make Expert from this indicator. How could Expert remember Bar numbers and High / Low values ?
Thanks,
Edas