Are experienced programmers getting what I'm saying? I've noticed that the code in an EA seems to be a recreation of an indicator --- for example a call to iMA with the parameters of the indicator but not a direct call from say iCustom.. Can I create an EA with reference to iCustom to reference a specific buffer rather than recreating the indicator within the EA? and if this is possible is there an existing EA I can look at...
Thank you kindly, Sincerely Neal
Hi, Thank you for response...
Is there an example in code of an EA that you know of? I've looked through the codebase and can't find any...
Hi, Thank you for response...
Is there an example in code of an EA that you know of? I've looked through the codebase and can't find any...
yes here

- reviews: 1
- www.mql5.com
Thank you Marco! I'll have a look...
It depends on the output of the indicator so you have to analyze that first.
Usually it is a price level.
It depends on the output of the indicator so you have to analyze that first.
Usually it is a price level.
I guess you are looking for an EA which translates indicator values to tradeable signals, right? Which indicators to you want to use, maybe I can help.
For the sake of example a stop loss based on a manually entered trade of a moving average would suffice. For example, if I'm long I want the stop loss to move with the MA as long as price stayed above it and the opposite for a short--- stay short until the price goes above the moving average.. basically a stop loss based upon the moving average of each new buffer value of the moving average.
This indicator could be used as the example.
//+------------------------------------------------------------------+ //| TEMA.mq5 | //| Copyright 2010, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "2010, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property description "Triple Exponential Moving Average" #include <MovingAverages.mqh> //--- indicator settings #property indicator_chart_window #property indicator_buffers 4 #property indicator_plots 1 #property indicator_type1 DRAW_LINE #property indicator_color1 DarkBlue #property indicator_width1 1 #property indicator_label1 "TEMA" #property indicator_applied_price PRICE_CLOSE //--- input parameters input int InpPeriodEMA=14; // EMA period input int InpShift=0; // Indicator's shift //--- indicator buffers double TemaBuffer[]; double Ema[]; double EmaOfEma[]; double EmaOfEmaOfEma[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,TemaBuffer,INDICATOR_DATA); SetIndexBuffer(1,Ema,INDICATOR_CALCULATIONS); SetIndexBuffer(2,EmaOfEma,INDICATOR_CALCULATIONS); SetIndexBuffer(3,EmaOfEmaOfEma,INDICATOR_CALCULATIONS); //--- sets first bar from what index will be drawn PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,3*InpPeriodEMA-3); //--- sets indicator shift PlotIndexSetInteger(0,PLOT_SHIFT,InpShift); //--- name for indicator label IndicatorSetString(INDICATOR_SHORTNAME,"TEMA("+string(InpPeriodEMA)+")"); //--- name for index label PlotIndexSetString(0,PLOT_LABEL,"TEMA("+string(InpPeriodEMA)+")"); //--- initialization done } //+------------------------------------------------------------------+ //| Triple Exponential Moving Average | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const int begin, const double &price[]) { //--- check for data if(rates_total<3*InpPeriodEMA-3) return(0); //--- int limit; if(prev_calculated==0) limit=0; else limit=prev_calculated-1; //--- calculate EMA ExponentialMAOnBuffer(rates_total,prev_calculated,0,InpPeriodEMA,price,Ema); //--- calculate EMA on EMA array ExponentialMAOnBuffer(rates_total,prev_calculated,InpPeriodEMA-1,InpPeriodEMA,Ema,EmaOfEma); //--- calculate EMA on EMA array on EMA array ExponentialMAOnBuffer(rates_total,prev_calculated,2*InpPeriodEMA-2,InpPeriodEMA,EmaOfEma,EmaOfEmaOfEma); //--- calculate TEMA for(int i=limit;i<rates_total && !IsStopped();i++) TemaBuffer[i]=3*Ema[i]-3*EmaOfEma[i]+EmaOfEmaOfEma[i]; //--- OnCalculate done. Return new prev_calculated. return(rates_total); } //+------------------------------------------------------------------+

- www.mql5.com

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
that I could see as an example?
So far all I've seen is EA's that have conditions written into the EA but not actually done by calling the buffer of an indicator...