Experts: Smoothing Average

 

Smoothing Average:

This EA is based on 1 moving average indicator, the exit and entry points are determined by a "smoothing factor".

SmoothingAverage Expert Advisor MetaTrader 4

Author: Rietsuiker

 

I modified your ea and tried using a % smoothing factor. 

 

//+------------------------------------------------------------------+
//|                                             SmoothingAverage.mq4 |
//|                                                       Rietsuiker |
//|                                                     http://ak.fm |
//+------------------------------------------------------------------+
#property copyright "Rietsuiker"
#property link      "http://ak.fm"
#property version   "0.01"

//--- input parameters
input int      Period_MA=200;
input double      Risk=10;
input double      SmoothingPerc=1.4;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int CurrentOrder;

double MA;
double MA2;
double highpoint;

double Lots=(AccountEquity()*Point*Risk);
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   Print("You're gonna get bankrupt m8");
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   Print(AccountEquity());
   Print(Lots);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---

   MA=iMA(NULL,0,Period_MA,0,MODE_SMA,PRICE_CLOSE,0);
   double Smoothing = SmoothingPerc*Ask/100.0;
   int ot= OrdersTotal();
   if(ot==0)
     {
     
      if(Bid<MA+Smoothing)
        {
         OrderSend(Symbol(),OP_SELL,Lots,Bid,10,0,0);
           } else if(Ask>MA-Smoothing){
         OrderSend(Symbol(),OP_BUY,Lots,Ask,10,0,0);    
        }
       return; 
     }
   
   if (ot>0)
   {
    OrderSelect(0,SELECT_BY_POS);
    if(OrderType()==OP_SELL && Bid>MA+Smoothing)
      {
       OrderClose(OrderTicket(),Lots,Ask,3,Red);
         } else if(OrderType()==OP_BUY && Ask<MA-Smoothing){
       OrderClose(OrderTicket(),Lots,Bid,3,Red);
     }
   }
  }
//+------------------------------------------------------------------+
Files:
 
Enoch:

I modified your ea and tried using a % smoothing factor. 

 

That's nice mate, you really improved it a bunch!

Using your modifications I altered some parameters and used it on the 5 minute chart:


Drawdown is still higher than you'd ultimately want, but it goes to show this EA has potential for different timeframes as it's definitely pointing upwards. The same settings also work well for USDCHF (M5).

Success at other currency pairs at present is patchy and inconsistent, I will have to implement better ways to manage risk in the future like an option for stoploss, takeprofit and trailingstop.

 

Interesting EA guys have you run any backtests or have any preferred settings etc?

 

 

 

Not too bad results i have to say, at least it is consistent :) 

 
Please enter SL, TP and Trailing. Thanks.
 

Could you also add the ability to set the magic number for the EA so we can test multiple versions of the EA on the same account and filter out the results per EA by magic number please?

 

Thanks 

 

This project has been on hiatus for a while, I no longer believe that trading purely on trend is profitable. Thanks for the interest though, here's magic, stoploss and takeprofit:

//+------------------------------------------------------------------+
//|                                             SmoothingAverage.mq4 |
//|                                                       Rietsuiker |
//|                                                     http://ak.fm |
//+------------------------------------------------------------------+
#property copyright "Rietsuiker, Enoch"
#property link      "http://ak.fm"
#property version   "0.01"

//--- input parameters
input int      Period_MA=200;
input double      Lots=10;
input double      SmoothingPerc=1.4;
input double      TakeProfit=0;
input double      StopLoss=0;
input double      Magic=96969;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int CurrentOrder;
double MA;

double SellTakeProfit;
double BuyTakeProfit;

double BuyStopLoss;
double SellStopLoss;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   Print(AccountEquity());
   Print(Lots);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---

   if(TakeProfit==0)
     {
      SellTakeProfit= 0;
      BuyTakeProfit = 0;
        } else{
      SellTakeProfit= Ask-TakeProfit * Point;
      BuyTakeProfit = Bid+TakeProfit * Point;
     }

   if(StopLoss==0)
     {
      BuyStopLoss= 0;
      SellStopLoss=0;
        } else{
      BuyStopLoss=Bid-StopLoss*Point;
      SellStopLoss=Ask+StopLoss*Point;
     }


   MA=iMA(NULL,0,Period_MA,0,MODE_SMA,PRICE_CLOSE,0);
   double Smoothing=SmoothingPerc*Ask/100.0;
   int ot=OrdersTotal();
   if(ot==0)
     {

      if(Bid<MA+Smoothing)
        {
         OrderSend(Symbol(),OP_SELL,Lots,Bid,10,SellStopLoss,SellTakeProfit,"SMA",Magic);
           } else if(Ask>MA-Smoothing){
         OrderSend(Symbol(),OP_BUY,Lots,Ask,10,BuyStopLoss,BuyTakeProfit,"SMA",Magic);
        }
      return;
     }

   if(ot>0)
     {
      OrderSelect(0,SELECT_BY_POS);
      if(OrderType()==OP_SELL && Bid>MA+Smoothing)
        {
         OrderClose(OrderTicket(),Lots,Ask,3,Red);
           } else if(OrderType()==OP_BUY && Ask<MA-Smoothing){
         OrderClose(OrderTicket(),Lots,Bid,3,Red);
        }
     }
  }
//+------------------------------------------------------------------+
 

Here's the latest rendition with modest and aggressive settings respectively:

 

 

Hi Rietsuiker,

Thanks for sharing.

How may I download the latest version?

Thanks. 

 
NAZMTAZ:

Hi Rietsuiker,

Thanks for sharing.

How may I download the latest version?

Thanks. 

Hi, right here:
Files:
 

Thanks.

It hasn't made any trades yet. I have it on M5 & H1 settings since last month maybe doesn't trade often?

Regards. 

Reason: