Let's discuss video "EMA-Heiken Ashi | This is The Trading Strategy The Top 5% Use"

Yashar Seyyedin  
Strategy Tester Report
FIBOGroup-MT5 Server (Build 3550)
Settings
Expert: EA_HA_EMA
Symbol: XAUUSD
Period: H1 (2020.03.01 - 2023.03.05)
Inputs: magic_number=1234
risk_percentage=1.0
Company: FIBO Group, Ltd.
Currency: USD
Initial Deposit: 100 000.00
Leverage: 1:100
Results
History Quality: 55%
Bars: 17735 Ticks: 2407806 Symbols: 1
Total Net Profit: 4 925.88 Balance Drawdown Absolute: 1 269.87 Equity Drawdown Absolute: 1 594.32
Gross Profit: 102 689.03 Balance Drawdown Maximal: 20 371.09 (16.26%) Equity Drawdown Maximal: 21 429.03 (16.96%)
Gross Loss: -97 763.15 Balance Drawdown Relative: 16.26% (20 371.09) Equity Drawdown Relative: 16.96% (21 429.03)
Profit Factor: 1.05 Expected Payoff: 16.15 Margin Level: 1095.46%
Recovery Factor: 0.23 Sharpe Ratio: 0.39 Z-Score: 1.33 (81.65%)
AHPR: 1.0002 (0.02%) LR Correlation: 0.52 OnTester result: 0
GHPR: 1.0002 (0.02%) LR Standard Error: 5 656.25
Total Trades: 305 Short Trades (won %): 134 (35.82%) Long Trades (won %): 171 (34.50%)
Total Deals: 610 Profit Trades (% of total): 107 (35.08%) Loss Trades (% of total): 198 (64.92%)
Largest profit trade: 6 894.62 Largest loss trade: -1 266.00
Average profit trade: 959.71 Average loss trade: -493.75
Maximum consecutive wins ($): 5 (3 055.46) Maximum consecutive losses ($): 10 (-5 349.80)
Maximal consecutive profit (count): 7 213.44 (2) Maximal consecutive loss (count): -5 349.80 (10)
Average consecutive wins: 1 Average consecutive losses: 3



Yashar Seyyedin  
input int magic_number=1234; //magic number
input double risk_percentage = 1; //Risk per trade %

double Ask,Bid;

#include <Trade\Trade.mqh>
CTrade trade;

ENUM_TIMEFRAMES HTF=PERIOD_H4;
ENUM_TIMEFRAMES LTF=PERIOD_H1;

int htf_handle=0;
int ltf_handle=0;

int OnInit()
  {
   htf_handle=iCustom(_Symbol, HTF, "HAEMA");
   ltf_handle=iCustom(_Symbol, LTF, "HAEMA");
   return(INIT_SUCCEEDED);
  }

datetime timer=NULL;
void OnTick()
  {
      if(timer==NULL){}
      else if(timer==iTime(_Symbol, LTF, 0)) return;
      timer=iTime(_Symbol, LTF, 0);
/////////////////////////////////////////////////////
      if(BuyCount()>0 && OHA_LTF(1)==HHA_LTF(1))
         CloseAll();
      if(SellCount()>0 && OHA_LTF(1)==LHA_LTF(1))
         CloseAll();
  
      bool buy_condition=true;
      buy_condition &= (BuyCount()==0);
      buy_condition &= (OHA_HTF(1)==LHA_HTF(1));
      buy_condition &= (OHA_HTF(1)<CHA_HTF(1));
      buy_condition &= (EMA10_HTF(1)>EMA30_HTF(1));
      buy_condition &= (OHA_LTF(1)==LHA_LTF(1));
      buy_condition &= (OHA_LTF(1)<CHA_LTF(1));
      buy_condition &= (EMA10_LTF(1)>EMA30_LTF(1));
      if(buy_condition) Buy();

      bool sell_condition=true;
      sell_condition &= (SellCount()==0);
      sell_condition &= (OHA_HTF(1)==HHA_HTF(1));
      sell_condition &= (OHA_HTF(1)>CHA_HTF(1));
      sell_condition &= (EMA10_HTF(1)<EMA30_HTF(1));
      sell_condition &= (OHA_LTF(1)==HHA_LTF(1));
      sell_condition &= (OHA_LTF(1)>CHA_LTF(1));
      sell_condition &= (EMA10_LTF(1)<EMA30_LTF(1));
      if(sell_condition) Sell();
   
  }

double OHA_HTF(int i)
{
   double array[];
   ArraySetAsSeries(array, true);
   CopyBuffer(htf_handle, 0, i, 1, array);
   return array[0];
}
double HHA_HTF(int i)
{
   double array[];
   ArraySetAsSeries(array, true);
   CopyBuffer(htf_handle, 1, i, 1, array);
   return array[0];
}
double LHA_HTF(int i)
{
   double array[];
   ArraySetAsSeries(array, true);
   CopyBuffer(htf_handle, 2, i, 1, array);
   return array[0];
}
double CHA_HTF(int i)
{
   double array[];
   ArraySetAsSeries(array, true);
   CopyBuffer(htf_handle, 3, i, 1, array);
   return array[0];
}


double OHA_LTF(int i)
{
   double array[];
   ArraySetAsSeries(array, true);
   CopyBuffer(ltf_handle, 0, i, 1, array);
   return array[0];
}
double HHA_LTF(int i)
{
   double array[];
   ArraySetAsSeries(array, true);
   CopyBuffer(ltf_handle, 1, i, 1, array);
   return array[0];
}
double LHA_LTF(int i)
{
   double array[];
   ArraySetAsSeries(array, true);
   CopyBuffer(ltf_handle, 2, i, 1, array);
   return array[0];
}
double CHA_LTF(int i)
{
   double array[];
   ArraySetAsSeries(array, true);
   CopyBuffer(ltf_handle, 3, i, 1, array);
   return array[0];
}

double EMA10_HTF(int i)
{
   double array[];
   ArraySetAsSeries(array, true);
   CopyBuffer(htf_handle, 5, i, 1, array);
   return array[0];
}
double EMA30_HTF(int i)
{
   double array[];
   ArraySetAsSeries(array, true);
   CopyBuffer(htf_handle, 6, i, 1, array);
   return array[0];
}

double EMA10_LTF(int i)
{
   double array[];
   ArraySetAsSeries(array, true);
   CopyBuffer(ltf_handle, 5, i, 1, array);
   return array[0];
}
double EMA30_LTF(int i)
{
   double array[];
   ArraySetAsSeries(array, true);
   CopyBuffer(ltf_handle, 6, i, 1, array);
   return array[0];
}

void CloseAll()
{
   for(int i=0;i<PositionsTotal();i++)
   {
      PositionSelectByTicket(PositionGetTicket(i));
      if(PositionGetInteger(POSITION_MAGIC) == magic_number)
      {
         trade.PositionClose(PositionGetTicket(i), -1);
         i--;
      }
   }  
}


void Buy()
{
   Ask=SymbolInfoDouble(_Symbol, SYMBOL_ASK);
   double sl=iLow(_Symbol, LTF, iLowest(_Symbol, LTF, MODE_LOW, 10, 0));
   double points = (Ask-sl)/_Point;
   double lot = AccountInfoDouble(ACCOUNT_EQUITY)*risk_percentage*0.01/(SymbolInfoDouble(Symbol(), SYMBOL_TRADE_TICK_VALUE)*points);
   double vol_step=SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP);
   lot=int(lot / vol_step)*vol_step;
   trade.SetExpertMagicNumber(magic_number);
   if(!trade.Buy(lot, _Symbol, Ask, sl, 0, ""))
   {
      Alert("Error executing order: " + (string)GetLastError());
      //ExpertRemove();
   }
}


void Sell()
{
   Bid=SymbolInfoDouble(_Symbol, SYMBOL_BID);
   double sl=iHigh(_Symbol, LTF, iHighest(_Symbol, LTF, MODE_HIGH, 10, 0));
   double points = (sl-Bid)/_Point;
   double lot = AccountInfoDouble(ACCOUNT_EQUITY)*risk_percentage*0.01/(SymbolInfoDouble(Symbol(), SYMBOL_TRADE_TICK_VALUE)*points);
   double vol_step=SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP);
   lot=int(lot / vol_step)*vol_step;
   trade.SetExpertMagicNumber(magic_number);
   if(!trade.Sell(lot, _Symbol, Bid, sl, 0, ""))
   {
      Alert("Error executing order: " + (string)GetLastError());
      //ExpertRemove();
   }
}

int BuyCount()
{
   int buy=0;
   for(int i=0;i<PositionsTotal();i++)
   {
      PositionSelectByTicket(PositionGetTicket(i));
      if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY && PositionGetInteger(POSITION_MAGIC) == magic_number)
         buy++;
   }  
   return buy;
}

int SellCount()
{
   int sell=0;
   for(int i=0;i<PositionsTotal();i++)
   {
      PositionSelectByTicket(PositionGetTicket(i));
      if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL && PositionGetInteger(POSITION_MAGIC) == magic_number)
         sell++;
   }  
   return sell;
}