MetaTrader 4 MT4 Expert Advisors Three White Soldiers and Three Black Crows for Chart Symbol – expert advisor for MetaTrader 4

Three White Soldiers and Three Black Crows for Chart Symbol – expert advisor for MetaTrader 4



This script is a trading strategy called “Three White Soldiers and Three Black Crows” implemented in MQL4.

It identifies patterns in price action known as “Three White Soldiers” and “Three Black Crows” and executes buy or sell trades accordingly.

Here’s a brief description of the key components of your script:

  • The script is designed to run in the MetaTrader 4 (MT4) trading platform.
  • It defines input parameters, including the period for the RSI calculation.
  • The OnInit() function is the initialization function, which is executed once when the script is initialized.
  • The OnTick() function is the main function that runs on every tick (price change) of the chart. It checks for the occurrence of the Three White Soldiers and Three Black Crows patterns and executes buy or sell trades accordingly.
  • The IsThreeWhiteSoldiers() function checks whether the current price action forms the Three White Soldiers pattern.
  • The IsThreeBlackCrows() function checks whether the current price action forms the Three Black Crows pattern.
  • The BuySignal() function executes a buy trade when the Three White Soldiers pattern is identified.
  • The SellSignal() function executes a sell trade when the Three Black Crows pattern is identified.

The script also includes copyright and version information, along with a warning message about using the software at your own risk.

If you have any specific questions or need further assistance with this script, feel free to ask!


ATTENTION: Entire strategy won’t pass the test to be posted running out of memory on website tester:

Copy entire strategy below and paste it to  Meta Trader 4  Editor:


//+——————————————————————+

//|                Three White Soldiers and Three Black Crows V1.mq4 |

//|                                  Copyright 2023, MetaQuotes Ltd. |

//|                                              |

//+——————————————————————+

#property copyright     “Copyright 2024, MetaQuotes Ltd.”

#property link          “”

#property version       “1.01”

#property description   “persinaru@gmail.com”

#property description   “IP 2024 – free open source”

Alternative:   Market Way - indicator for MetaTrader 4

#property description   ”  Three White Soldiers and Three Black Crows for Chart Symbol “

#property description   “”

#property description   “WARNING: Use this software at your own risk.”

#property description   “The creator of this script cannot be held responsible for any damage or loss.”

#property description   “”

#property strict

#property show_inputs

#property script_show_inputs



// Input parameters

extern int period = 14; // Period for the RSI calculation

extern double lotSize = 0.1;

//+——————————————————————+

//| Expert initialization function                                   |

//+——————————————————————+

int OnInit()

{

    return INIT_SUCCEEDED;

}


//+——————————————————————+

//| Expert tick function                                             |

//+——————————————————————+

void OnTick()

{

    // Check for Three White Soldiers pattern

    if (IsThreeWhiteSoldiers())

    {

        // Execute buy trade

        BuySignal();

    }

    // Check for Three Black Crows pattern

    else if (IsThreeBlackCrows())

    {

        // Execute sell trade

        SellSignal();

    }

}


//+——————————————————————+

//| Check for Three White Soldiers pattern                           |

//+——————————————————————+

bool IsThreeWhiteSoldiers()

{

    // Get closing prices for the last three bars

    double close[3];

    ArraySetAsSeries(close, true);

    CopyClose(Symbol(), Period(), 0, 3, close);


    // Check if the last three bars form a Three White Soldiers pattern

    if (close[0] > close[1] && close[1] > close[2])

        return true;

    

    return false;

}


//+——————————————————————+

//| Check for Three Black Crows pattern                              |

//+——————————————————————+

bool IsThreeBlackCrows()

{

    // Get closing prices for the last three bars

    double close[3];

    ArraySetAsSeries(close, true);

    CopyClose(Symbol(), Period(), 0, 3, close);


    // Check if the last three bars form a Three Black Crows pattern

Alternative:   Average Stocastic indicator for several timeframes - indicator for MetaTrader 4

    if (close[0] < close[1] && close[1] < close[2])

        return true;

    

    return false;

}


//+——————————————————————+

//| Execute buy trade                                                |

//+——————————————————————+

void BuySignal()

{

    // Example: Buy 1 lot

    lotSize = 1.0;

    double slippage = 3; // Slippage in pips


    // Buy order

    int ticket = OrderSend(Symbol(), OP_BUY, lotSize, Ask, (int)slippage, 0, 0, “Three White Soldiers”, 0, 0, Green);


    // Check if the order was executed successfully

    if (ticket > 0)

    {

        Print(“Buy order executed successfully”);

    }

    else

    {

        Print(“Error executing buy order: “, GetLastError());

    }

}


//+——————————————————————+

//| Execute sell trade                                               |

//+——————————————————————+

void SellSignal()

{

    // Example: Sell 1 lot

    lotSize = 1.0;

    double slippage = 3; // Slippage in pips


    // Sell order

    int ticket = OrderSend(Symbol(), OP_SELL, lotSize, Bid, (int)slippage, 0, 0, “Three Black Crows”, 0, 0, Red);


    // Check if the order was executed successfully

    if (ticket > 0)

    {

        Print(“Sell order executed successfully”);

    }

    else

    {

        Print(“Error executing sell order: “, GetLastError());

    }

}








    📈 ROBOTFX MetaTrader Expert Advisors and Indicators to maximize profits and minimize the risks