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

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_0return( 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

Attachment download
📎 heikenashiidea.mq4 (29.79 KB)
Source: MQL5 #18021
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •