Need some advise on converting my Heiken Ashi strategy into an mt4 EA

 

Hi all, I developed a tradingview strategy that uses the heinken ashi candle patterns for entry with a vwap trend filter. The strategy can be 50% win ratio and profitable. I would like to convert it into an mt4 ea so that i can properly backtest it. 

Please does anyone have any advise. I\ve used chat GPT but its inconclusive. 

Some questions i have: Would i need to search for an existing mt4 Heineken ashi candle indicator and vwap indicator in order for the conversion to be possible. 

< Improperly formatted post. Please use the CODE button (Alt-S) when inserting code — https://www.mql5.com/en/articles/24#insert-code >

MQL5.community - User Memo
MQL5.community - User Memo
  • www.mql5.com
You have just registered and most likely you have questions such as, "How do I insert a picture to my a message?" "How do I format my MQL5 source code?" "Where are my personal messages kept?" You may have many other questions. In this article, we have prepared some hands-on tips that will help you get accustomed in MQL5.community and take full advantage of its available features.
 

Don't use chatGPT if you are beginner you won't be able to correct its errors - imho.

Instead search for Heiken Ashi EA - there are plenty!

Then search for "add indicator to EA" or read this article: https://www.mql5.com/en/articles/10329.

 

Hi

If you don’t know how to code in mq4 it would be best to hire some freelancer who will code this for you according to your specification. If you want to try it by yourself – please write your code and parts where you have some problems and we can try to give you some hints and tips what to do.

Heiken Ashi is available in the mt4 platform, as for the other indicator you would probably need the mt4 version or write it by yourself (or include in the code of your final indicator). There might be some free versions available online – check the forum. But you cannot use the tradingview version directly in mt4.

Best Regards

 
salemtrading5:

Hi all, I developed a tradingview strategy that uses the heinken ashi candle patterns for entry with a vwap trend filter. The strategy can be 50% win ratio and profitable. I would like to convert it into an mt4 ea so that i can properly backtest it. 

Please does anyone have any advise. I\ve used chat GPT but its inconclusive. 

Some questions i have: Would i need to search for an existing mt4 Heineken ashi candle indicator and vwap indicator in order for the conversion to be possible. 

< Improperly formatted post. Please use the CODE button (Alt-S) when inserting code — https://www.mql5.com/en/articles/24#insert-code >

Here is a Template you can use for the heiken ashi. 

//+------------------------------------------------------------------+
//|                                     Heiken Ashi Trend EA Example |
//|                                                                  |
//|                                                    Salemtrading  |
//+------------------------------------------------------------------+
#property strict

// Input parameters
extern double LotSize = 0.1;
extern int StopLoss = 100;  // Stop loss in pips
extern int TakeProfit = 200;  // Take profit in pips
extern int MA_Period = 14;   // Period for calculating Heiken Ashi

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
    // Initialization code here
    return INIT_SUCCEEDED;
}

//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
    // Deinitialization code here
}

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
    // Calculate Heiken Ashi candles
    double haOpen = iMA(Symbol(), 0, MA_Period, 0, MODE_SMMA, PRICE_OPEN, 0);
    double haHigh = iMA(Symbol(), 0, MA_Period, 0, MODE_SMMA, PRICE_HIGH, 0);
    double haLow = iMA(Symbol(), 0, MA_Period, 0, MODE_SMMA, PRICE_LOW, 0);
    double haClose = iMA(Symbol(), 0, MA_Period, 0, MODE_SMMA, PRICE_CLOSE, 0);

    // Trend identification
    bool bullishTrend = haClose > haOpen;
    bool bearishTrend = haClose < haOpen;

    // Entry and exit conditions
    if (bullishTrend)
    {
        // Place buy order
        int ticket = OrderSend(Symbol(), OP_BUY, LotSize, Ask, 3, 0, 0, "Buy order", 0, 0, Green);
        if (ticket > 0)
        {
            Print("Buy order placed successfully. Ticket: ", ticket);
        }
        else
        {
            Print("Error placing buy order. Error code: ", GetLastError());
        }
    }
    else if (bearishTrend)
    {
        // Place sell order
        int ticket = OrderSend(Symbol(), OP_SELL, LotSize, Bid, 3, 0, 0, "Sell order", 0, 0, Red);
        if (ticket > 0)
        {
            Print("Sell order placed successfully. Ticket: ", ticket);
        }
        else
        {
            Print("Error placing sell order. Error code: ", GetLastError());
        }
    }
}

It uses the bearish and bullish trend of the heiken ashi when it starts with the swap of color candles. No one will code a complete expert for you here, unless you go to freelance or people who codes for free, but they will want your strategy. i have set the example above so you can work from it. Once you come back and you have shown effort in trying, we will consider helping you further.