If I've understood you correctly ...
Yes, several ways
A) to use the value for some purpose, use double myVal = XXXX; // where XXXX is iMA(..) or iMACD(...) or iRSI(...) etc
B) to display them, set up any of the 8 indicators available to you in a Custom Indicator as, say, myBuff[i] = XXXX; // where XXXX is iMA(..) or iMACD(...) or iRSI(...) etc
C) use double myVal = iCustom(NULL, 0, "MACD", mFast, mSlow, mSig, mMode, i); // I wouldn't recommend this as a first option, but it should work and follows similar logic as loading another Custom indicator value.
NB all code just typed & not compiled nor checked.
For information on specifics, I recommend that you read the manual, or at least the Help feature of MetaEditor.
is there a way to get,or programming, the internal mt4 indicators visible on the chart ?
- Attach indicators to the chart, save with a template. Con: If you change EA's parameters, they won't match
- Have the EA plot the values on the chart.
//+------------------------------------------------------------------+ //| EA equivalent of indicator buffers | //+------------------------------------------------------------------+ /* Example 1: * if (...) Ordermodify(...); * Polyline("SL"+(oo.ticket%99), oo.SL, Color.SL, 0); * * Example 2: * double ELineCurr = iMA(NULL,0, ELine.Period, 0, MODE_EMA, PRICE_CLOSE, 1); * Polyline("ELine", ELineCurr, Color.ELine, 1); ******************************************************************************/ #define POLYLINE_MAX 20 // Must match priceMM[] void Polyline(string name, double price, color clr, int shift=0){ if (!Show.Objects) return; static int LRU[POLYLINE_MAX]; static string lineName[POLYLINE_MAX]; for (int idx=0; idx < POLYLINE_MAX; idx++){ bool new = lineName[idx] != name; if (!new) break; } if (new){ for (idx=0; idx < POLYLINE_MAX; idx++) LRU[idx]++; idx=ArrayMaximum(LRU); lineName[idx]=name; } LRU[idx] = 0; double price00[], price01[], price02[], price03[], price04[], price05[], price06[], price07[], price08[], price09[], price10[], price11[], price12[], price13[], price14[], price15[], price16[], price17[], price18[], price19[]; switch (idx){ case 0: PLHelper(name, price, clr, idx, new, shift, price00); return; case 1: PLHelper(name, price, clr, idx, new, shift, price01); return; case 2: PLHelper(name, price, clr, idx, new, shift, price02); return; case 3: PLHelper(name, price, clr, idx, new, shift, price03); return; case 4: PLHelper(name, price, clr, idx, new, shift, price04); return; case 5: PLHelper(name, price, clr, idx, new, shift, price05); return; case 6: PLHelper(name, price, clr, idx, new, shift, price06); return; case 7: PLHelper(name, price, clr, idx, new, shift, price07); return; case 8: PLHelper(name, price, clr, idx, new, shift, price08); return; case 9: PLHelper(name, price, clr, idx, new, shift, price09); return; case 10: PLHelper(name, price, clr, idx, new, shift, price10); return; case 11: PLHelper(name, price, clr, idx, new, shift, price11); return; case 12: PLHelper(name, price, clr, idx, new, shift, price12); return; case 13: PLHelper(name, price, clr, idx, new, shift, price13); return; case 14: PLHelper(name, price, clr, idx, new, shift, price14); return; case 15: PLHelper(name, price, clr, idx, new, shift, price15); return; case 16: PLHelper(name, price, clr, idx, new, shift, price16); return; case 17: PLHelper(name, price, clr, idx, new, shift, price17); return; case 18: PLHelper(name, price, clr, idx, new, shift, price18); return; case 19: PLHelper(name, price, clr, idx, new, shift, price19); return; } } void PLHelper( string name, double price, color clr, int idx, bool new , int shift, double& mem[] ){ datetime t0 = Time[shift]; int firstBar = ArraySize(mem)-1; static datetime time0[POLYLINE_MAX]; if (time0[idx] < Time[shift+1]) new = true; // Missing bars, leave a gap. if (new){ firstBar = -1; static int segNo[POLYLINE_MAX]; segNo[idx]++; static datetime time1[POLYLINE_MAX]; time1[idx] = t0; } string objName=name+"-"+segNo[idx]; if (new || t0 != time0[idx]){ ArraySetAsSeries(mem, false); // Shift values m[2]=m[1]; m[1]=m[0] firstBar=ArrayResize(mem, firstBar+2)-1; if (firstBar < 0){ Alert( "ArrayResize failed: ",GetLastError()); return;} ArraySetAsSeries(mem, true); } time0[idx]=t0; mem[0]=price; if (t0 == time1[idx]) t0 += 60*Period(); // Minimum 1 bar wide. /**/ if(ObjectMove(objName, 1, t0, price)) ObjectMove(objName, 0, time1[idx], mem[firstBar]); // New or tmplt. else if (!ObjectCreate( objName, OBJ_TREND, WINDOW_MAIN , time1[idx], mem[firstBar], t0, price )){ Alert( "ObjectCreate(", objName, "Trend) [1] failed: ",GetLastError());return;} else if (!ObjectSet( objName, OBJPROP_COLOR, clr )) Alert( "ObjectSet(", objName, "Color) [3] failed: ", GetLastError()); else if (!ObjectSet( objName, OBJPROP_RAY, false )) Alert( "ObjectSet(", objName, "Ray) [1] failed: ", GetLastError()); double maxError=0; int maxBar; for (int pos=1; pos < firstBar; pos++){ double error=MathAbs(ObjectGetValueByShift(objName, pos+shift)-mem[pos]); if (error > maxError){ maxError=error; maxBar=pos; } } if (maxError >= pips2dbl){ // Split the line into two segments at the max. if (!ObjectMove(objName, 1, Time[shift+maxBar], mem[maxBar])) Alert( "ObjectMove(", objName, "Trend) failed: ", GetLastError()); segNo[idx]++; objName=name+"-"+segNo[idx]; ArrayResize(mem, maxBar+1); // Drop firstBar..(maxBar+1) time1[idx] = Time[shift+maxBar]; /**/ if(ObjectMove(objName, 0, time1[idx], mem[maxBar])) ObjectMove(objName, 1, t0, price); else if (!ObjectCreate( objName, OBJ_TREND, WINDOW_MAIN , time1[idx], mem[maxBar], t0, price )){ Alert( "ObjectCreate(", objName, "Trend) [2] failed: ",GetLastError()); } else if (!ObjectSet( objName, OBJPROP_COLOR, clr )) Alert( "ObjectSet(", objName, "Color) [4] failed: ", GetLastError()); else if (!ObjectSet( objName, OBJPROP_RAY, false )) Alert( "ObjectSet(", objName, "Ray) [3] failed: ", GetLastError()); } // Split the line into two segments at the max. } // PLHelper //++++ These are adjusted for 5 digit brokers. double pips2points, // slippage 3 pips 3=points 30=points pips2dbl; // Stoploss 15 pips 0.0015 0.00150 int Digits.pips; // DoubleToStr(dbl/pips2dbl, Digits.pips) int init(){ if (Digits == 5 || Digits == 3){ // Adjust for five (5) digit brokers. pips2dbl = Point*10; pips2points = 10; Digits.pips = 1; } else { pips2dbl = Point; pips2points = 1; Digits.pips = 0; } // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl ...
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hello,
is there a way to get,or programming, the internal mt4 indicators visible on the chart ?
KR