- New Dolly
- Can someone help me to make alert on my indicator when breakhi and breaklow??
- How to Subscribe to a MT4 Signal (new instructions, after 1065 version upgrade)
Please explain your question in detail!
First you need to update the pivot bar structure like this , you are declaring an open and a timeOpen :
struct SPivotBar { datetime timeCurPeriodStart; datetime timeCurPeriodEnd; datetime timePivotOpen; datetime timePivotRealOpen; datetime timePivotClose; double open; datetime timeOpen; double high; datetime timeHigh; double low; datetime timeLow; double close; datetime timePivotRealClose; double r8,r7,r6,r5,r4,r3,r2,r1; double p; double s1,s2,s3,s4,s5,s6,s7,s8; };
Then you just go to the bar calculation (the "real" calculation , and since you are looping from the present toward the past you can safely update the open price at every "valid" bar.
(you have grabbed the close once at first so you are set there)
bool CMain::CalcPivotBarHLC(int I,SPivotBar &PIVOT_BAR) { PIVOT_BAR.timePivotRealOpen=0; PIVOT_BAR.timePivotRealClose=0; for(int i=I,total=Bars; i<total; i++) { if(Time[i]<PIVOT_BAR.timePivotOpen) break; if(Time[i]>PIVOT_BAR.timePivotClose) continue; if(PIVOT_BAR.timePivotRealClose==0) { PIVOT_BAR.high=High[i]; PIVOT_BAR.timeHigh=Time[i]; PIVOT_BAR.low=Low[i]; PIVOT_BAR.timeLow=Time[i]; PIVOT_BAR.close=Close[i]; PIVOT_BAR.timePivotRealClose=Time[i]; } PIVOT_BAR.timePivotRealOpen=Time[i]; //keep updating the open + open time since you are going into the past PIVOT_BAR.open=Open[i]; PIVOT_BAR.timeOpen=Time[i]; if(NormalizeDouble(High[i]-PIVOT_BAR.high,_Digits)>0) { PIVOT_BAR.high=High[i]; PIVOT_BAR.timeHigh=Time[i]; } if(NormalizeDouble(PIVOT_BAR.low-Low[i],_Digits)>0) { PIVOT_BAR.low=Low[i]; PIVOT_BAR.timeLow=Time[i]; } } return true; }
then the to_string function needs to output the open and open time as well :
string CMain::ToString(void) { return StringConcatenate("\n===LEVELS ",EnumToString(workMode),"=== | StartHour",StartHour," | timeGetLevels_",timeGetLevels, "\nCUR ",pivotBar.timeCurPeriodStart," - ",pivotBar.timeCurPeriodEnd," | P_",DoubleToString(pivotBar.p,_Digits), "\ntimePivotOpen",pivotBar.timePivotOpen, " | open_",DoubleToString(pivotBar.open,_Digits)," at_",pivotBar.timeOpen, " | high_",DoubleToString(pivotBar.high,_Digits)," at_",pivotBar.timeHigh, " | low_",DoubleToString(pivotBar.low,_Digits)," at_",pivotBar.timeLow, " | close_",DoubleToString(pivotBar.close,_Digits)," at_",pivotBar.timePivotRealClose); }
and lastly the P calculation , i did not find any reference to pivot points with the open price but the open is now available in the pivot bar if you need it in the formula.
double P = (PIVOT_BAR.high+PIVOT_BAR.low+PIVOT_BAR.close)/3; //you can now call the open price here in the formula , delete the following if its not what you want P=(PIVOT_BAR.open+PIVOT_BAR.high+PIVOT_BAR.low+PIVOT_BAR.close)/4;
That's all i think
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