double why not work ? New comment Stefano Cerbioni 2020.12.03 14:15 hi guys i have a questions i have indicator at end of this indicator i divide two double and after i multiplay for constant 100 why return 100 ????????? if i print a single double return number little like 0.000232335 or 9.88888 but when i divide return always 1 how is possible that ??? //+------------------------------------------------------------------+ //| DIV-2-PGrad.mq4 | //| Michael H Kim | //| mhmkim@hotmail.com | //+------------------------------------------------------------------+ #property copyright "Michael H Kim" #property link "mhmkim@hotmail.com" #property version "1.00" #property strict #property indicator_separate_window #include <MovingAverages.mqh> //--- indicator settings #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 Green #property indicator_color2 Yellow //--- input parameter input int InpDivPeriod=3; input int MAL=4; //--- buffers double ExtDIVBuffer1[]; double MAGradBuff[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit(void) { string short_name; ChartSetSymbolPeriod(0,Symbol(),PERIOD_M5); //--- indicator buffers mapping IndicatorBuffers(2); IndicatorDigits(Digits); //---indicator line SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,ExtDIVBuffer1); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,MAGradBuff); //--- name for data window and indicator subwindow label // IndicatorShortName(short_name); // SetIndexLabel(0,short_name); //--- check for input parameters if(InpDivPeriod<=1) { Print("Wrong input parameters DIV Period=",InpDivPeriod); return(INIT_FAILED); } //--- SetIndexDrawBegin(0,InpDivPeriod); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Divergence //+------------------------------------------------------------------+ 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& tick_volume[], const long& volume[], const int& spread[]) { int counted_bars = prev_calculated; if(counted_bars < 0) { return(-1); } if(counted_bars > 0) { counted_bars--; } int limit=MathMin(rates_total-counted_bars,rates_total-1); double dio[]; double EmaB[]; double EmaBB[]; double EmaBB2[]; double diod[]; double EmaBd[]; double EmaBBd[]; double EmaBB2d[]; double DiffNum[]; double DiffDen[]; ArrayResize(dio,limit+1); ArrayResize(EmaB,limit+1); ArrayResize(EmaBB,limit+1); ArrayResize(EmaBB2,limit+1); ArrayResize(diod,limit+1); ArrayResize(EmaBd,limit+1); ArrayResize(EmaBBd,limit+1); ArrayResize(EmaBB2d,limit+1); ArrayResize(DiffNum,limit+1); ArrayResize(DiffDen,limit+1); for(int i=limit; i>=0; i--) { // DiffNum[i]= (close[i]-open[i]); DiffDen[i]= MathAbs((close[i]-open[i])); //numertore dio[i]=iMAOnArray(DiffNum,0,2,0,MODE_EMA,i); EmaBB[i] = iMAOnArray(dio,0,2,0,MODE_EMA,i); EmaBB2[i] = iMAOnArray(EmaBB,0,2,0,MODE_EMA,i); //denomi diod[i]=iMAOnArray(DiffDen,0,2,0,MODE_EMA,i); EmaBBd[i] = iMAOnArray(diod,0,2,0,MODE_EMA,i); EmaBB2d[i] = iMAOnArray(EmaBB,0,2,0,MODE_EMA,i); if(EmaBB2d[i]!= 0) { MAGradBuff[i]= (EmaBB2[i]/EmaBB2d[i])*100; Print("DEMA DE EEE "+(EmaBB2[i]/EmaBB2d[i])*100); } } return(rates_total); } //+------------------------------------------------------------------+ back test questions Universal MA Cross EA why not enter in cicle for ? William Roeder 2020.12.03 16:55 #1 Set your arrays to as-series before filling them (so iMAOnArray knows how to read them), or make them buffers. Stefano Cerbioni 2020.12.04 14:14 #2 Thank you so much I bow to your genius thank you again holy immediately New comment
hi guys i have a questions
i have indicator at end of this indicator i divide two double and after i multiplay for constant 100 why return 100 ?????????
if i print a single double return number little like 0.000232335 or 9.88888 but when i divide return always 1 how is possible that ???