Want to convert strategy to MT5 EA

Can anyone help me with MT5 Expert Advisor

Before diving into the strategy, let’s first understand the indicators:

  1. Supertrend (7,0.9) and Supertrend (7,1.8) - These are trend-following indicators that use the average true range (ATR) to calculate stop-loss levels. The Supertrend (7,0.9) has a smaller multiplier, making it more sensitive to price changes, while Supertrend (7,1.8) has a larger multiplier, making it less sensitive.

  2. EMA (99) - This is a trend-following indicator that calculates the average price of a security over a specified period, with more weight given to the most recent prices.

  3. RSA (9) - This is a momentum indicator that measures the strength of a trend using the relative strength index (RSI) formula.

  4. ADX(9) - This is a trend strength indicator that measures the strength of a trend, regardless of direction.

Now, let’s outline the strategy:

  1. Buy signal: A buy signal is generated when the Supertrend (7,0.9) indicator changes from red to green, the Supertrend (7,1.8) is already green, and the EMA (99) is sloping upwards. Additionally, the RSA (9) should be above 50, indicating strong momentum in the uptrend.

  2. Exit signal: An exit signal is generated when either of the Supertrend indicators changes from green to red, or the EMA (99) begins sloping downwards.

  3. Sell signal: A sell signal is generated when the Supertrend (7,1.8) changes from green to red, the Supertrend (7,0.9) is already red, and the EMA (99) is sloping downwards. Additionally, the RSA (9) should be below 50, indicating strong momentum in the downtrend.

  4. Exit signal: An exit signal is generated when either of the Supertrend indicators changes from red to green, or the EMA (99) begins sloping upwards.

  5. Trend confirmation: To confirm the trend, we can use the ADX(9) indicator. If the ADX(9) is above 25, it indicates a strong trend, and we can follow the signals generated by the Supertrend and EMA indicators. If the ADX(9) is below 25, it indicates a weak trend, and we should avoid trading until the trend becomes stronger.

  6. Risk management: To manage risk, we can use a stop-loss order at the Supertrend (7,0.9) level. If the Supertrend (7,0.9) changes from green to red, we can exit the trade and set a stop-loss at the Supertrend (7,0.9) level. Similarly, for short trades, we can use the Supertrend (7,1.8) level as a stop-loss.

Note: This strategy is a guideline, and it’s always important to backtest and validate the strategy before using it in live trading. Additionally, it’s essential to monitor the market conditions regularly and adjust the strategy as needed.

Can anyone help me with MT5 Expert Advisor

For free or are you buying? Companies charge hundreds of dollars for custom EAs.

I’m testing this strategy for now, hence will be looking for free…

Supertrend isn’t a built in MT5 indicator, so you need to code that as well as the strategy.

You can probably do this easily without anybody’s help on tradingview.

I’m far too busy in real work to do this atm, but maybe one day I will. But I’ll unlikely be giving it to anybody for free unless they have done the work in testing the strategy to verify it’s worth my time making an EA. I can throw out 200 strategy ideas that I haven’t tested and hope that somebody makes me something that’s profitable, but that’s not a system until there’s at least some evidence to suggest it will work.

2 Likes

Thank you @chesterjohn.

You are right, supertrend is not inbuilt in the MT5.

hello Chester, was wondering if you knew how to use order blocks.
like the proper setting and sequence that makes them work or fail.

I’m not sure what you mean. What do you mean by order blocks and their settings?

Are you talking about order blocks as in price action? I thought you were asking about something EA related.

I’d look for price reversing or breaking out from that level. Wait for a confirmation candle that’s clearly away from the block and go that way

i seem to understand why and when they fail. the sell side is easy for me. like when i see how price interacts with an order block for the first time, i can predict if that order block will hold or fail.

the EA i need is one that can be programmed to takeout partials automatically without me being there just like some EA’s can trail stops.

Hi @chesterjohn,
I’ve tried to create indicator with the strategy mentioned above, but finding some error with the code. can you please help me with it?

Request your support.

//±-----------------------------------------------------------------+ //| Custom indicator initialization function | //±-----------------------------------------------------------------+ int OnInit() { //— indicator buffers mapping

//—
return(INIT_SUCCEEDED);
}

//— Define indicator buffers
double Buy_Arrow[];
double Sell_Arrow[];
double Buy_Exit_Symbol[];
double Sell_Exit_Symbol[];

//±-----------------------------------------------------------------+
//| Custom indicator iteration function |
//±-----------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//—

//— return value of prev_calculated for next call
return(rates_total);
}
//±-----------------------------------------------------------------+
//Supertrend (7,0.9) indicator
int supertrend1_period = 7;
double supertrend1_multiplier = 0.9;
double supertrend1_factor = supertrend1_multiplier + 1.0;
double supertrend1_ATR = iATR(Symbol(), PERIOD_CURRENT, supertrend1_period);
double supertrend1_upper = (iHigh(Symbol(), PERIOD_CURRENT, 1) + iLow(Symbol(), PERIOD_CURRENT, 1)) / 2.0 + supertrend1_multiplier * supertrend1_ATR;
double supertrend1_lower = (iHigh(Symbol(), PERIOD_CURRENT, 1) + iLow(Symbol(), PERIOD_CURRENT, 1)) / 2.0 - supertrend1_multiplier * supertrend1_ATR;
double supertrend1_value = 0.0;

//Supertrend (7,1.8) indicator
int supertrend2_period = 7;
double supertrend2_multiplier = 1.8;
double supertrend2_factor = supertrend2_multiplier + 1.0;
double supertrend2_ATR = iATR(Symbol(), PERIOD_CURRENT, supertrend2_period);
double supertrend2_upper = (iHigh(Symbol(), PERIOD_CURRENT, 1) + iLow(Symbol(), PERIOD_CURRENT, 1)) / 2.0 + supertrend2_multiplier * supertrend2_ATR;
double supertrend2_lower = (iHigh(Symbol(), PERIOD_CURRENT, 1) + iLow(Symbol(), PERIOD_CURRENT, 1)) / 2.0 - supertrend2_multiplier * supertrend2_ATR;
double supertrend2_value = 0.0;

//EMA (9) indicator
int ema_period = 9;
double ema_value = iMA(Symbol(), PERIOD_CURRENT, ema_period, 0, MODE_EMA, PRICE_CLOSE);

//ADX (9) indicator
int adx_period = 9;
//double adx_value = iADX(Symbol(), PERIOD_CURRENT, adx_period, PRICE_CLOSE, MODE_MAIN, 0);
double adx_value = iADX(Symbol(), PERIOD_CURRENT, adx_period);

//RSI (9) indicator
int rsi_period = 9;
//double rsi_value = iRSI(Symbol(), PERIOD_CURRENT, rsi_period, PRICE_CLOSE, 0);
double rsi_value = iRSI(Symbol(), PERIOD_CURRENT, rsi_period, PRICE_CLOSE);

//Buy signal
if(supertrend1_value < Low[1] && supertrend1_upper > High[1] && supertrend2_value < Low[1] && supertrend2_upper > High[1] && ema_value > ema_value[1] && adx_value > 25 && rsi_value > 50)
{
//Place buy order
ArraySetAsSeries(Buy_Arrow, true);
Buy_Arrow[0] = High[0] + (iATR(NULL, 0, 14, 0) * 0.5);
PlotArrow(_Symbol, PERIOD_CURRENT, Buy_Arrow);
SetIndexBuffer(0, Buy_Arrow);
SetIndexArrow(0, 233);
}

//Buy exit signal
if((supertrend1_value > High[1] || supertrend2_value > High[1]) || ema_value < ema_value[1])
{
//Close buy order.
ArraySetAsSeries(Buy_Exit_Symbol, true);
Buy_Exit_Symbol[0] = High[0] + (iATR(NULL, 0, 14, 0) * 1.5);
PlotText(“B Exit”, _Symbol, PERIOD_CURRENT, Buy_Exit_Symbol[0], 0, 0, “Wingdings”, clrWhite, clrGreen);
SetIndexBuffer(2, Buy_Exit_Symbol);
SetIndexStyle(2, DRAW_NONE);
}

//Sell signal
if(supertrend1_value > High[1] && supertrend1_lower < Low[1] && supertrend2_value > High[1] && supertrend2_lower < Low[1] && ema_value < ema_value[1] && adx_value > 25 && rsi_value < 50)
{
//Place sell order
ArraySetAsSeries(Sell_Arrow, true);
Sell_Arrow[0] = Low[0] - (iATR(NULL, 0, 14, 0) * 0.5);
PlotArrow(_Symbol, PERIOD_CURRENT, Sell_Arrow);
SetIndexBuffer(1, Sell_Arrow);
SetIndexArrow(1, 234);
}

//Sell exit signal
if((supertrend1_value < Low[1] || supertrend2_value < Low[1]) || ema_value > ema_value[1])
{
//Close sell order
ArraySetAsSeries(Sell_Exit_Symbol, true);
Sell_Exit_Symbol[0] = Low[0] - (iATR(NULL, 0, 14, 0) * 1.5);
PlotText(“S Exit”, _Symbol, PERIOD_CURRENT, Sell_Exit_Symbol[0], 0, 0, “Wingdings”, clrWhite, clrRed);
SetIndexBuffer(3, Sell_Exit_Symbol);
SetIndexStyle(3, DRAW_NONE);
}

What’s the problem with it? I’m working 60 hours a week right now, so I’ll look when I get time.

You aren’t using the indicators properly, you need to copy the buffer from the definition into an array. Looks like loads of variables aren’t set to anything before you’re checking their value

I’m not good at coding, but will try to check as per your advice.

Thanks for checking in and apology to ask you in your busy schedule. Much appreciate for your support :slight_smile: