Schau, wie man Roboter kostenlos herunterladen kann
Finden Sie uns auf Telegram!
und werden Sie Mitglied unserer Fangruppe
Interessantes Skript?
Veröffentliche einen Link auf das Skript, damit die anderen ihn auch nutzen können
Hat Ihnen das Skript gefallen?
Bewerten Sie es im Terminal MetaTrader 5
Expert Advisors

Example of Heiken Ashi Using Multi Time Frame (MTF) - Experte für den MetaTrader 4

Mohammad Soubra
Veröffentlicht:
Mohammed Abdulwadud Soubra
Ansichten:
26219
Rating:
(16)
Veröffentlicht:
2017.04.11 09:21
Benötigen Sie einen Roboter oder Indikator, der auf diesem Code basiert? Bestellen Sie ihn im Freelance-Bereich Zum Freelance

Description

This is an example for Heiken Ashi candles.

  • Only uses pending orders (Buy-Limit & Sell-Limit).
  • Hedging is possible (by using different magic numbers).
  • Filter is possible (by two time frames as the code below).

see the main idea of this expert in these following two functions:

int AshiUp(int TF=PERIOD_CURRENT)
  {
   double haLowHigh_1 = iCustom(Symbol(),TF,"Heiken Ashi",Red,White,Red,White,0,1);
   double haOpen_1    = iCustom(Symbol(),TF,"Heiken Ashi",Red,White,Red,White,2,1);
   double haClose_1   = iCustom(Symbol(),TF,"Heiken Ashi",Red,White,Red,White,3,1);

   double haLowHigh_0 = iCustom(Symbol(),TF,"Heiken Ashi",Red,White,Red,White,0,0);
   double haOpen_0    = iCustom(Symbol(),TF,"Heiken Ashi",Red,White,Red,White,2,0);
   double haClose_0   = iCustom(Symbol(),TF,"Heiken Ashi",Red,White,Red,White,3,0);

   if((haClose_0>haOpen_0 && haOpen_0==haLowHigh_0) && 
      (haClose_1>haOpen_1 && haOpen_1!=haLowHigh_1))
      return(1);

   else  return(0);
  }


int AshiDown(int TF=PERIOD_CURRENT)
  {
   double haLowHigh_1 = iCustom(Symbol(),TF,"Heiken Ashi",Red,White,Red,White,0,1);
   double haOpen_1    = iCustom(Symbol(),TF,"Heiken Ashi",Red,White,Red,White,2,1);
   double haClose_1   = iCustom(Symbol(),TF,"Heiken Ashi",Red,White,Red,White,3,1);

   double haLowHigh_0 = iCustom(Symbol(),TF,"Heiken Ashi",Red,White,Red,White,0,0);
   double haOpen_0    = iCustom(Symbol(),TF,"Heiken Ashi",Red,White,Red,White,2,0);
   double haClose_0   = iCustom(Symbol(),TF,"Heiken Ashi",Red,White,Red,White,3,0);

   if((haClose_0<haOpen_0 && haOpen_0==haLowHigh_0) && 
      (haClose_1<haOpen_1 && haOpen_1!=haLowHigh_1))
      return(1);

   else  return(0);
  }

see the code below for detect buy:

//--- Trading
   if(TotalOrdersCount(MagicNumberBuy)<1)
      if(AshiUp(1440)==1 && AshiUp()==1)
         BuyExecute();

In addition, it is not allowed to work with metals as you can see below:

//+------------------------------------------------------------------+
//| Expert initialization function
//+------------------------------------------------------------------+
int OnInit()
  {
   Comment(" ");

   if(Symbol()=="Gold" || Symbol()=="GOLD" || Symbol()=="gold" || Symbol()=="XAUUSD" || Symbol()=="AUCMDUSD"
      || Symbol() == "Silver" || Symbol() == "SILVER" || Symbol() == "silver" || Symbol() == "XAGUSD" || Symbol() == "E_SI"
      || Symbol() == "Copper" || Symbol() == "COPPER" || Symbol() == "copper" || Symbol() == "CUCMDUSD"
      || Symbol() == "XAUEUR" || Symbol() == "Gold.Euro"    || Symbol() == "Gold.Eur"
      || Symbol() == "XAGEUR" || Symbol() == "Silver.Euro"  || Symbol() == "Silver.Eur"
      || Symbol() == "USOil"  || Symbol() == "USOIL"  || Symbol() == "UKOil"  || Symbol() == "UKOIL"
      || Symbol() == "NGAS"   || Symbol() == "NGas"   || Symbol() == "Bund"   || Symbol() == "BUND"   || Symbol() == "bund"
      || Symbol() == "Oil" || Symbol() == "Brent" || Symbol() == "BRENT" || Symbol() == "brent"       || Symbol() == "Crude"  || Symbol() == "COPPER" || Symbol() == "BRENTCMDUSD"
      || Symbol() == "WTI" || Symbol() == "Light" || Symbol() == "LIGHT" || Symbol() == "LIGHTCMDUSD" || Symbol() == "COPPER"
      || Symbol() == "Palladium" || Symbol() == "PALLADIUM" || Symbol() == "palladium" || Symbol() == "PDCMDUSD"
      || Symbol() == "Platinum"  || Symbol() == "PLATINUM"  || Symbol() == "platinum"  || Symbol() == "PTCMDUSD" )
     {
      Comment(SymbolErr);
      Alert(SymbolErr);
      return(INIT_FAILED);
     }
.
.
.
}

Image

Example of Heiken Ashi Using Multi Time Frame (MTF)

Recommendations

  • This example code is only for coders/traders who are interested for free codes in order to learn/modify it in the future.
  • Don't use it on real money trading.
  • Use it only in Demo or Strategy Tester.
  • You can remove lines (from 55 to 70) in order to try it in metals.

Good Luck.

RSI Accumulated (Floating Levels) RSI Accumulated (Floating Levels)

Accumulated RSI that uses floating levels or quantile bands.

LRDegrees MT4 LRDegrees MT4

Forex indicator for MetaTrader 4 with show double line of linear regression with position degrees and trend alerts.

Auto Fibo Auto Fibo

Automatic Fibonacci with ZigZag Base.

Trade Multiplier Trade Multiplier

This expert will copy a trade with the preset volume on the same account, can be used with a signal. No cross-account functionality.