Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

Example of using Multiple Time Frame (MTF) by Heiken Ashi - MetaTrader 4 Expert

author EAcpu | 4 reads | 0 comments |

Example of Heiken Ashi Using Multi Time Frame (MTF) - expert for MetaTrader 4

This is an example of a Heiken Ashi candle.

See the main idea of ​​​​this expert with the following two functions:

 integer ash-up ( integer TF= PERIOD_CURRENT )
  {
Double haLowHigh_1 = custom ( symbol (),TF, "Ashipingjian" , red, white, red, white, 0 , 1 );
double haOpen_1 = custom ( symbol (), TF, "Ashipingjian" , red, white, red, white, 2 , 1 );
double haClose_1 = custom ( symbol (), TF, "Ashipingjian" , red, white, red, white, 3 , 1 );

Double haLowHigh_0 = custom ( symbol (), TF, "Ashipingjian" , red, white, red, white, 0 , 0 );
double haOpen_0 = custom ( symbol (),tf, "ashipingjian" ,red,white,red,white, 2,0 ) ;
double haClose_0 = custom ( symbol (), TF, "Axipingjian" , 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 );

Return ( 0 ); else
  } integer ashtang ( integer TF= PERIOD_CURRENT )
  {
Double haLowHigh_1 = custom ( symbol (),TF, "Ashipingjian" , red, white, red, white, 0 , 1 );
double haOpen_1 = custom ( symbol (), TF, "Ashipingjian" , red, white, red, white, 2 , 1 );
double haClose_1 = custom ( symbol (), TF, "Ashipingjian" , red, white, red, white, 3 , 1 );

Double haLowHigh_0 = custom ( symbol (), TF, "Ashipingjian" , red, white, red, white, 0 , 0 );
double haOpen_0 = custom ( symbol (),tf, "ashipingjian" ,red,white,red,white, 2,0 ) ;
double haClose_0 = custom ( symbol (), TF, "Axipingjian" , red, white, red, white, 3 , 0 );

if ((haClose_0 return( 1 );

Return ( 0 ); else
  }

See the code below to detect purchases:

 //--- Transaction if (Total number of orders (MagicNumberBuy) < 1 )
if (AshiUp( 1440 )== 1 &&AshiUp()== 1 )
        PurchaseExecution();

Additionally, use with metals is not allowed, as follows:

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

if ( symbol () == "gold" || symbol ()== "gold" || symbol ()== "gold" || symbol ()== "XAUUSD" || symbol ()== "AUDUSD" || symbol ()== "silver" || symbol ()== "silver" || symbol ()== "silver" || symbol ()== "XAGUSD" || symbol ()== "E_SI" || symbol ()== "copper" || symbol ()== "Copper" || symbol ()== "copper" || symbol ()== "CUCMD dollar" || symbol ()== "XAUEUR" || symbol ()== "gold.euro" || symbol ()== "gold.euro" || symbol ()== "XAGEUR" ||symbol()== "silver.euro" || symbol ()== "silver.euro" || symbol ()== "American Petroleum" || symbol ()== "American Petroleum Corporation" || symbol ()== "BP" || symbol ()== "BP" || symbol ()== "NGAS" || symbol ( )== "natural gas" || symbol ()== "The Bund" || symbol ()== "The Bund" || symbol ()== "The Bund" || symbol ()== "oil" || symbol ()== "Brent" || symbol ()== "Brent" || symbol ()== "Brent" || symbol ()== "crude oil" || symbol ()== "Copper" || symbol () == "BRENTCMD USD" || symbol () == "West Texas Intermediate Oil" || symbol () == " Light " || symbol () == " LIGHT" || symbol () == " LIGHTCMD USD" || symbol () == "COPPER" || symbol ()== "Palladium" || symbol () == "Palladium " || symbol () == "Palladium" ||symbol() == "PDCMD USD" || symbol ()== " platinum" || symbol ()== "platinum" || symbol ()== "platinum" || symbol ()== "PTCMDUSD" )
    {
comment (symbol error);
alert (symbolerror);
Return ( initialization failed ); }
.
.
.
}

image

Example of Heiken Ashi Using Multi Time Frame (MTF) - expert for MetaTrader 4


Attachment download

📎 heikenashiidea.mq4 (29.79 KB)

Source: MQL5 #18021

Verification code Refresh