Convert Indicator to EA

MQL4 Experts

Specification

Add conditional buy n sell code for opening a trade and reverse closing code in the following ea code

- entry of buy at onset of blue dot

- exit of buy at onset of Pink dot

- entry of Sell at onset of pink dot

- exit of Sell at onset of blue dot 

 Var MA Indicator

//+------------------------------------------------------------------+

//|                                                  var_mov_avg.mq4 |

//|                                 Copyright © 2016, Dmitri Migunov |

//|                                            sniper_dragon@mail.ru |

//|                                                                  |

//|          Thanks for previous version 2004, GOODMAN & Mstera è AF |

//+------------------------------------------------------------------+

#property copyright "Copyright © 2016, Dmitri Migunov"

#property link      "sniper_dragon@mail.ru"

#property version   "1.00"

      

#property indicator_chart_window

#property indicator_buffers 4

#property indicator_color1  clrSienna

#property indicator_color2  clrBlue

#property indicator_color3  clrMagenta

#property indicator_color4  clrYellow


//---- input parameters

input

  int

    periodAMA = 50, // period of AMA

    nfast     = 15, // first noise filter parameter. Higher values make indicator less sensitive to spikes.

    nslow     = 10; // second noise filter parameter. Higher values make indicator less sensitive to spikes.


input

  double

    G   = 1.0,  // the power of filtered part in the moving average. Another way to make the signal line smoother.

    dK  = 0.1;  // doesn't really influence anything much.


input

  bool

    UseAlert  = false,  // if true then alerts will be used.

    UseSound  = false;  // if true then sound will be used in alerts.


input

  string

    SoundFile = "expert.wav"; // name of the sound file for alerts.


input

  int

    offsetInPips = 30;  // maximal offset signal dots from current price


//---- buffers

double

  kAMAbuffer[],

  kAMAupsig[],

  kAMAdownsig[],

  signalBuffer[];


//+------------------------------------------------------------------+

int

  cbars     = 0;


double

  slowSC,

  fastSC,

  dSC,

  dKPoint;


bool

  SoundBuy  = false,

  SoundSell = false;


//+------------------------------------------------------------------+

//| Custom indicator initialization function                         |

//+------------------------------------------------------------------+

int OnInit(void){

//---- indicators

  SetIndexStyle( 0, DRAW_LINE, 0, 2 );

  SetIndexStyle( 1, DRAW_ARROW, STYLE_SOLID, 2 );

  SetIndexArrow( 1, 159 );

  SetIndexStyle( 2, DRAW_ARROW, STYLE_SOLID, 2 );

  SetIndexArrow( 2, 159 );

  SetIndexStyle( 3, DRAW_ARROW, STYLE_SOLID, 1 );

  SetIndexArrow( 3, 159 );

   

  SetIndexBuffer( 0, kAMAbuffer );

  SetIndexBuffer( 1, kAMAupsig );

  SetIndexBuffer( 2, kAMAdownsig );

  SetIndexBuffer( 3, signalBuffer );

   

  IndicatorDigits( Digits );

  

//--- calculate this variables when start

  slowSC  = 2.0 / ( nslow + 1 );

  fastSC  = 2.0 / ( nfast + 1 );

  dSC     = fastSC - slowSC;

  dKPoint = dK * Point;


//--- initialization done

  return(INIT_SUCCEEDED);

}


//+------------------------------------------------------------------+

//| Custom indicator iteration function                              |

//+------------------------------------------------------------------+

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

    pos = 0;

   

  double

    AMA,

    AMA0,

    signal,

    ER,

    ERSC,

    SSC,

    ddK;

  

  string

    message;

   

  if( prev_calculated == rates_total ) return( rates_total );

    

  cbars   = prev_calculated;

  

  if( rates_total <= ( periodAMA+2 ) ){

    return( rates_total );

  }


//---- check for possible errors

  if( cbars < 0 ) return(-1);


//---- last counted bar will be recounted

  if( cbars > 0 ) cbars--;

  

  pos   = rates_total - periodAMA - 2;

  AMA0  = close[ pos+1 ];

  

  for( int p=pos; p>=0; p-- ){

    signal    = MathAbs( close[ p ] - close[ p+periodAMA ] );

    ER        = signal / getNoise( close, p );

    ERSC      = ER * dSC;

    SSC       = ERSC + slowSC;

    ddK       = MathPow( SSC, G ) * ( close[p] - AMA0 );

    AMA       = AMA0 + ddK;

    AMA0      = AMA;

    

    int

      offset  = ( high[p] - low[p] ) / Point() * 2;


    if( offset < 5 )            offset = 5;

    if( offset > offsetInPips ) offset = offsetInPips;

    

    kAMAbuffer[p]   = AMA;

    kAMAupsig[p]    = 0;

    kAMAdownsig[p]  = 0;

    signalBuffer[p] = 0;


    if( MathAbs( ddK ) <= dKPoint )  continue;

    

    if( ddK > 0 ) kAMAupsig[p]    = AMA;

    if( ddK < 0 ) kAMAdownsig[p]  = AMA;


    if( kAMAupsig[p] != EMPTY_VALUE && kAMAupsig[p] != 0 && SoundBuy ){

      SoundBuy        = false;

      signalBuffer[p] = MathMin( close[p+1], low[p] ) - offset * Point;

      if( 0 == p )  showAlert( "BUY @ " + Ask );

    } 

  

    if ( !SoundBuy && ( EMPTY_VALUE == kAMAupsig[p] || 0 == kAMAupsig[p] ) ){

      SoundBuy = true;

    }

    

    if ( kAMAdownsig[p] != EMPTY_VALUE && kAMAdownsig[p] != 0 && SoundSell ){

      SoundSell       = false;

      signalBuffer[p] = MathMax( close[ p+1 ], high[p] ) + offset * Point;

      if( 0 == p )  showAlert( "Sell @" + Bid );

    }

  

    if( !SoundSell && ( EMPTY_VALUE == kAMAdownsig[p] || 0 == kAMAdownsig[p] )){

      SoundSell = true;

    }

  }

  


  return( rates_total );

}


double  getNoise( const double &close[], const int pos ){

  double

    noise = 0.000000001;

    

  for( int i=0; i<periodAMA; i++ ){

    noise += MathAbs( close[ pos+i ] - close[ pos+i+1 ] );

  }

  

  return noise;

}


void  showAlert( string message ){

  message  = TimeCurrent() + " " + Symbol() + " " + Period() + "M " + message;

  Comment( message );


  if( ! UseAlert ) return;

  if( UseSound ) PlaySound( SoundFile );

   

  Alert( message );

}


Thanks 

Responded

1
Developer 1
Rating
(769)
Projects
1033
44%
Arbitration
50
8% / 50%
Overdue
117
11%
Free
2
Developer 2
Rating
(414)
Projects
478
40%
Arbitration
7
43% / 29%
Overdue
16
3%
Free
3
Developer 3
Rating
(39)
Projects
44
16%
Arbitration
1
100% / 0%
Overdue
7
16%
Free
4
Developer 4
Rating
(68)
Projects
111
26%
Arbitration
17
6% / 71%
Overdue
15
14%
Free
5
Developer 5
Rating
(121)
Projects
134
66%
Arbitration
36
25% / 56%
Overdue
22
16%
Free
Similar orders
I have an EA and want to add few new logic to fetch profit taking factors and other values from an external master data and use it in existing EA
Hello Every one, Good day, I want from someone professional to create an EA is working on Mt5, This EA is working by depend on some indicators, and all those indicators must be working on MACD window, not on the chart, for more details please read my attached pdf file carefully. Many Thanks
I'm looking for an expert MQL5 developer that can create an EA that's based on my price action trading strategy with no indicators. The EA must analyze trades based on my price action rules, enter trades based on my price action rules, manage trades based on my price action rules and exit trades based on my price action rules
hi hi there i have an strategy on tradingview and i want to automate it like metatrader EA so i want the strategy to open and close trade automaticlly on tradingview
We are looking for an experienced Expert Advisor Developer who can build a customized MT5 Expert Advisor for us. The Expert Advisor would use two built-in indicators as entry/exit signals and our own risk management strategy with customizable inputs. The goal is to create a reliable and efficient trading tool that can automate our trading process on the MT5 platform. Skills required: - Strong understanding of
I need stochastic div (hidden &regular ea) that should perform task in all tf's ..divergence is a repaint stly so i want to use it with candlestick flips .. so bet for it
Hello, I have an indicator from a friend and I'd like to replicate it on my own TradingView or MT5 platform. Could you assist me with that?. Here is the link
so basically I have an EA(mql5), AI script(python), flask server and socket server both on python. Now this is an experimental script as I am trying to learn. However the EA is not entering any trades. How much would it cost for you to troubleshoot this for me? Thank you in advance
NEW FUNCTION 50+ USD
La idea es la siguiente, sería un EA semi automático. Yo como trader opero en zonas. En adelante las vamos a denominar ``zonas calientes´´. El EA debe que necesito debe operar conforme a 4 zonas calientes que yo configure en el mismo. ¿Qué hará el EA en cada una de esas zonas calientes que yo he configurado? En cada una de estas zonas el EA debe realizar hedging (crear un rango en el cual el EA entrara en sell o en
I have the bot just over half made, from another developer who let me down and decided they no longer wished to finish the project, so I have a basic example of the fundamentals of what it could look like, although multiple functions I require do not work, but I can show this to you on request. There are multiple features that I require, so please read the in depth requirement sheet on the attachment. Function: To

Project information

Budget
10 - 20 USD
For the developer
9 - 18 USD
Deadline
from 1 to 2 day(s)