Hi,thanks for the support !
I'm not receiving any error.
The value from OnCalculate Low[] is for example : 1.233432,using iLow,returns 1.233789
i don't know why this difference of prices,but the result is not the same !
Bilal Said:
Hi,thanks for the support !
I'm not receiving any error.
The value from OnCalculate Low[] is for example : 1.233432,using iLow,returns 1.233789
i don't know why this difference of prices,but the result is not the same !
I didn't see how does the low function work because is not attached here however I think if you are using the same time frame as in iLow function and also using the same index so the priblem could be in Array access methof . You can try to declare the time serious arraybas a dynamic Array and followed by ArraySetAsSeriiud = true
Mohamed Nabil:
I didn't see how does the low function work because is not attached here however I think if you are using the same time frame as in iLow function and also using the same index so the priblem could be in Array access methof . You can try to declare the time serious arraybas a dynamic Array and followed by ArraySetAsSeriiud = true
Hi,thanks for the fast response !
I tried it too.
//+------------------------------------------------------------------+ //| Heiken_Ashi.mq5 | //| Copyright 2009, MetaQuotes Software Corp. | //| http://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "2009, MetaQuotes Software Corp." #property link "http://www.mql5.com" //--- indicator settings #property indicator_chart_window #property indicator_buffers 5 #property indicator_plots 1 #property indicator_type1 DRAW_COLOR_CANDLES #property indicator_color1 DodgerBlue, Red #property indicator_label1 "Heiken Ashi Open;Heiken Ashi High;Heiken Ashi Low;Heiken Ashi Close" //--- indicator buffers double ExtOBuffer[]; double ExtHBuffer[]; double ExtLBuffer[]; double ExtCBuffer[]; double ExtColorBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,ExtOBuffer,INDICATOR_DATA); SetIndexBuffer(1,ExtHBuffer,INDICATOR_DATA); SetIndexBuffer(2,ExtLBuffer,INDICATOR_DATA); SetIndexBuffer(3,ExtCBuffer,INDICATOR_DATA); SetIndexBuffer(4,ExtColorBuffer,INDICATOR_COLOR_INDEX); //--- IndicatorSetInteger(INDICATOR_DIGITS,_Digits); //--- sets first bar from what index will be drawn IndicatorSetString(INDICATOR_SHORTNAME,"Heiken Ashi"); //--- sets drawing line empty value PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0); //--- initialization done } //+------------------------------------------------------------------+ //| Heiken Ashi | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total,const int prev_calculated, const datetime &Time[], const double &Open[], const double &High[], const double &Low[], const double &Close[], const long &TickVolume[], const long &Volume[], const int &Spread[]) { int i,limit; //--- preliminary calculations if(prev_calculated==0) { //--- set first candle ExtLBuffer[0]=Low[0]; ExtHBuffer[0]=High[0]; ExtOBuffer[0]=Open[0]; ExtCBuffer[0]=Close[0]; limit=1; } else limit=prev_calculated-1; //--- the main loop of calculations for(i=limit;i<rates_total && !IsStopped();i++) { Print("ILOW["+i+"]="+Low[i]); Print("iLow("+i+")="+iLow(Symbol(),PERIOD_CURRENT,i)); double haOpen=(ExtOBuffer[i-1]+ExtCBuffer[i-1])/2; double haClose=(Open[i]+High[i]+Low[i]+Close[i])/4; double haHigh=MathMax(High[i],MathMax(haOpen,haClose)); double haLow=MathMin(Low[i],MathMin(haOpen,haClose)); ExtLBuffer[i]=haLow; ExtHBuffer[i]=haHigh; ExtOBuffer[i]=haOpen; ExtCBuffer[i]=haClose; //--- set candle color if(haOpen<haClose) ExtColorBuffer[i]=0.0; // set color DodgerBlue else ExtColorBuffer[i]=1.0; // set color Red } //--- done return(rates_total); } //+------------------------------------------------------------------+ double iLow(string strSymbol,ENUM_TIMEFRAMES tf,int nShift) { double timeseries[1]; if(CopyLow(strSymbol,tf,nShift,1,timeseries)==1) return(timeseries[0]); else return(-1.0); }
Can you help me to identify the mistake ? Here is the code of the indicator,i'm printing the data inside main loop
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
Hi,i'm trying to modify an Indicator "Heiken Ashi" to return me the values in which timeframe i want,for test i'm using PERIOD_CURRENT.
Inside Calculation,i have :
double iLow(string strSymbol,ENUM_TIMEFRAMES tf,int nShift)
{
double timeseries[1];
if(CopyLow(strSymbol,tf,nShift,1,timeseries)==1) return(timeseries[0]);
else return(-1.0);
}
But i'm getting 2 different Values.
Thanks !