So, while I wait for the feedback, here is the interim solution...instead of custome indicator, I created a subroutine in the EA itself to provide the vital inputs...here is the subroutine...I know that it is little lame to have three loops, but was too lazy to put everything in one loop (really lazy!) :)
void PivotCalcs() { int handle,i,j,LoopCount; double YH=0, YL=9999, YC; // Calculate LoopCount such that previous 49 hours are covered // to ensure that the pivot and sup/res calcs are carried out on // prior day data. LoopCount=2*(24*60)/Period()+1; // Find high from the previous day for (i=LoopCount;i>=1;i--) {if ((TimeMinute(Time[i]) == 00) && (TimeHour(Time[i]) - TimeZoneOfData == 00)) {for (j=i;j>=(i-23);j--) {if (High[j]>YH) YH=High[j]; } } } // Find low from the previos day for (i=LoopCount;i>=1;i--) {if ((TimeMinute(Time[i]) == 00) && (TimeHour(Time[i]) - TimeZoneOfData == 00)) {for (j=i;j>=(i-23);j--) {if ((Low[j]<YL)&&(j>0)) {YL=Low[j]; } } } } // Find close from the previous day for (i=LoopCount;i>=1;i--) {if ((TimeMinute(Time[i]) == 00) && (TimeHour(Time[i]) - TimeZoneOfData == 00)) {for (j=i-1;j>=1;j--) {if ((TimeMinute(Time[j]) == 00) && (TimeHour(Time[j]) - TimeZoneOfData == 00)) {YC=Close[j]; } } } } // Carry out Pivot and Support/Resistance calculations Pivot = (YH+YL+YC)/3; R1=2*Pivot-YL; S1=2*Pivot-YH; R2=Pivot-S1+R1; S2=Pivot-R1+S1; R3=R1+YH-YL; S3=S1-YH+YL; /*Write to the file handle=FileOpen("Pivots", FILE_CSV|FILE_WRITE, ';'); if(handle>0) { // write table columns headers FileWrite(handle, "Time;High;Low;Close;Pivot;R1;R2;R3;S1;S2;S3"); // write data FileWrite(handle, Time[1], High[1], Low[1], Close[1],Pivot, R1, R2, R3, S1, S2, S3) ; FileClose(handle); } Print("High=",YH," Low=",YL," Close=",YC," Pivot=",Pivot," R1=",R1," R2=",R2," R3=",R3," S1=",S1," S2=",S2," S3=",S3);*/ return(0); }
I still can't find a way to append the file in MQL (I've the code to write once above - inside comments)....any clues?
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
Here is my problem. I have a daily pivot point calculating and plotting indicator (downloaded from the web). I want to use the Support/resistance values in another EA to decide my stop/loss as well profit targets. I followed the instructions for iCustom and the EA is running, but the values (support/resistance points imported from the custom indicator) do not seem right. I'm doing something wrong, but am not able to pinpoint it. I'm enclosing the code for both (the pivot point indicator as well as the EA) here.
Pivot Point Calculator Code
EA Code
My guess is that I'm unnecessarily calculating pivot points for all days visible on the chart instead of just the previous day and current day. Also, how can EA communicate with the indicator to ensure that the pivot points calculated are relevant for current bar under calculation in EA?
Any help would be appreciated.