DislikedHey all. Any programmer kind enough to lend me a help. I have a pivots indicator which im trying to change. I want it to make the pivot of the last two days instead of last day. Having a hard time. yada yada yada here is the code i curently have (someone else programmed it): if(counted_bars < 0) return(-1); //---- last counted bar will be recounted // if(counted_bars>0) counted_bars--; limit = (Bars - counted_bars) - 1; //---- for(i = limit; i >= 0; i--) { if(High[i+1] > LastHigh) LastHigh = High[i+1]; //---- if(Low[i+1] < LastLow) LastLow=Low[i+1];...Ignored
Here how to calculate the highest high of the last two days - an example
Inserted Code
double hi1 = iHigh(NULL,PERIOD_D1,i+1);
double hi2 = iHigh(NULL,PERIOD_D1,i+2);
DHi = MathMax(hi1,hi2);
DLo = iLow(NULL,PERIOD_D1,i+1); DHi calculates the highest high of the previous two days.
DLo calculates the lowest low of the previous day.
The above comparison illustrates what edits are required to be applied to DLo
The image illustrates the effect of DHi
0 day calculates the highest of previous D1 and D2.
1 day calculates the highest of previous D2 and D3.
2 day calculates the highest of previous D3 and D4.
3 day calculates the highest of previous D4 and Sunday (The Sunday effect is not eliminated in the code - first example found and no time to look for other)
5 day calculates the highest of previous D6 and D7.
So in this example - once the edits (MathMin) are applied to DLo to calculate lowest low of previous two days then Calc can be calculated
Inserted Code
DHi = MathMax(hi1,hi2); DLo = MathMin(lo1,lo2); Calc = (DHi+DLo)/2;
reference - iHigh - https://docs.mql4.com/series/ihigh
reference - MathMax/MathMin - https://docs.mql4.com/math/mathmax
Not available for further comments
TSLA: 30-Dec-22 123.18 // 16-Jun-23 260.54 **111.51%**