Improperly formatted code edited by moderator. In future, please use the CODE button (Alt-S) when inserting code.
Improperly formatted code edited by moderator. In future, please use the CODE button (Alt-S) when inserting code.
- What is the problem?
- You already access the arrays. You just didn't set them to non-series as your loop is. The passed arrays have no default direction, just like MT5.
To determine the indexing direction of time[], open[], high[], low[], close[], tick_volume[], volume[] and spread[], call ArrayGetAsSeries(). In order not to depend on default values, you should unconditionally call the ArraySetAsSeries() function for those arrays, which are expected to work with.
Event Handling Functions - Functions - Language Basics - MQL4 Reference
- What is the problem?
- You already access the arrays. You just didn't set them to non-series as your loop is. The passed arrays have no default direction, just like MT5.
thank you for your answer sir , there is the probleme i have this code who scan the hammer patterns and show theme on the graph with an arrow. This is the all codes down here, now i want to modify the code to scan the star pattern who needs the OCHL of the 3 last candles and i dont know how if you can help me please
int OnInit() { return(INIT_SUCCEEDED);} void OnDeinit (const int reason){ ObjectsDeleteAll(0,"Signal@"); ChartRedraw(0); } 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[]) { for(int i = prev_calculated-1; i < rates_total-1; i++){ if(i < 0 || i > rates_total -1) continue; getHammerSignal(0.1,0.7,time[i],high[i],low[i],open[i],close[i]); } return(rates_total); } int getHammerSignal(double maxRatioShortShadow,double minRatioLongShadow, datetime time,double high,double low,double open,double close){ double candleSize = high - low; //green Hammer buy formation if(open < close){ if (high - close < candleSize * maxRatioShortShadow){ if (open - low > candleSize * minRatioLongShadow){ creatObj(time,low,233,1,clrGreen,"Hammer"); return 1; }}} //Red hammer buy formation if(open > close){ if (high - open < candleSize * maxRatioShortShadow){ if (close - low > candleSize * minRatioLongShadow){ creatObj(time,low,233,1,clrGreen,"Hammer"); return 1; }}} //green Hammer sell formation if(open < close){ if (open - low < candleSize * maxRatioShortShadow){ if (high - close > candleSize * minRatioLongShadow){ creatObj(time,high,234,-1,clrRed,"Hammer"); return -1; }}} //red Hammer sell formation if( open>close ){ if (close - low < candleSize * maxRatioShortShadow){ if (high - open > candleSize * minRatioLongShadow){ creatObj(time,high,234,-1,clrRed,"Hammer"); return -1; }}} return 0;} void creatObj(datetime time ,double price, int arrowCode,int direction, color clr,string txt){ string ObjName = ""; StringConcatenate(ObjName,"Signal@" ,time,"at",DoubleToString(price,_Digits),"(",arrowCode,")"); if(ObjectCreate(0,ObjName,OBJ_ARROW,0,time,price)){ ObjectSetInteger(0,ObjName,OBJPROP_ARROWCODE,arrowCode); ObjectSetInteger(0,ObjName,OBJPROP_COLOR,clr); if (direction >0) ObjectSetInteger(0,ObjName,OBJPROP_ANCHOR,ANCHOR_TOP); if (direction <0) ObjectSetInteger(0,ObjName,OBJPROP_ANCHOR,ANCHOR_BOTTOM); } string ObjNameDesc = ObjName+txt; if(ObjectCreate(0,ObjNameDesc,OBJ_TEXT,0,time,price)){ ObjectSetString(0,ObjNameDesc,OBJPROP_TEXT," "+txt); ObjectSetInteger(0,ObjNameDesc,OBJPROP_COLOR,clr); if (direction >0) ObjectSetInteger(0,ObjNameDesc,OBJPROP_ANCHOR,ANCHOR_TOP); if (direction <0) ObjectSetInteger(0,ObjNameDesc,OBJPROP_ANCHOR,ANCHOR_BOTTOM); }}
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
i want to creat like this code but to scan engulfing configuration , the probleme is how to get the open high last and close for the 3 last candles pls.