Create EA (iCustom) with MACHINE LEARNING ADAPTIVE SUPERTREND Scanner Indicator

Create EA (iCustom) with MACHINE LEARNING ADAPTIVE SUPERTREND Scanner Indicator

5 February 2025, 17:07
Duc Hoan Nguyen
0
193
To use the Machine Learning Adaptive Supertrend Scanner indicator (ver.2.00 - download link at the end of the article) for EA, you can see the instructions below:
a. The buffers in the indicator and their indexes:
0 – Buy Signal (arrow)
1 – Sell Signal (arrow)
2 – Buy Cluster Number
3 – Sell Cluster Number
4 – SuperTrend Value (Price)
b. Required input parameters:

- To use iCustom, you need to fill in all the parameters, because the indicator uses a scanner, so the parameters need to be entered appropriately to avoid conflicts. Below are the required and mandatory input parameters, you can change their default values ​​as you like:

input int iMaxBarsBack = 10000;//Max bars back (0=all)
input int atr_len = 10;//ATR Length
input double fact = 3;//Factor
input int training_data_period = 100;//Training Data Length
input double highvol = 0.75;//Initial High volatility Percentile Guess
input double midvol = 0.5;//Initial Medium volatility Percentile Guess
input double lowvol = 0.25;//Initial Low volatility Percentile Guess
c. iCustom:

MT4 Version 2.00:

double getValueMLAdaptiveSuperTrend(string fSymbol,           //Symbol (fill _Symbol to use symbol current)
                                    ENUM_TIMEFRAMES Timeframe,  //Timeframe (fill PERIOD_CURRENT to use current timeframe)
                                    int Index,             //index buffer (see section a)
                                    int Shift                //Shift (usually = 1 to get the previous bar value)
                                   )
  {
   string indicatorCustomName = "Market\\ML Adaptive SuperTrend MT4";//Path indicator
   return iCustom(fSymbol, Timeframe, indicatorCustomName, iMaxBarsBack, "", atr_len, fact, "", training_data_period, highvol, midvol, lowvol, 0, 0, 0, 0, false, 0, "", false, false, false, false, false, false, "", "", false, "", 0, 0, "", false, 0, 0, 0, false, 0, 0, 0, 0, 0, 0, 0, 0, "", 0, "", false, 0, 0, false, 0, 0, 0,
                  Index, Shift);
  }

MT5 Version 2.00:

double getValueMLAdaptiveSuperTrend(string fSymbol,           //Symbol (fill _Symbol to use symbol current)
                              ENUM_TIMEFRAMES Timeframe,  //Timeframe (fill PERIOD_CURRENT to use current timeframe)
                              int Index,             //index buffer (see section a)
                              int Shift                //Shift (usually = 1 to get the previous bar value)
                             )
  {
   string indicatorCustomName = "Market\\ML Adaptive SuperTrend MT5";//Path indicator
   int handle = iCustom(fSymbol,Timeframe,indicatorCustomName,iMaxBarsBack,"",atr_len,fact,"",training_data_period,highvol,midvol,lowvol,0,0,0,0,false,false,1,"",false,false,false,false,false,false,"","",false,"",0,0,"",false,0,0,0,false,0,0,0,0,0,0,0,0,"",0,"",false,0,0,false,0,0,0);
   if(handle < 0)
      return(EMPTY_VALUE);
   else
     {
      double buf[];
      if(CopyBuffer(handle, Index, Shift, 1, buf) > 0)
         return(buf[0]);
     }
   return EMPTY_VALUE;
  }

d. Use getValueMLAdaptiveSuperTrend function for EA

You use the getValueMLAdaptiveSuperTrend function to get the value needed to use for the EA.

To confirm that the buffer has a value, you need to compare it with EMPTY_VALUE.

Here are some examples to confirm that the previous bar buffers (shift = 1) have a value:

int shift  = 1;

0 – Buy Signal (arrow)

bool buySignal = getValueMLAdaptiveSuperTrend(_Symbol, PERIOD_CURRENT, 0, shift) != EMPTY_VALUE;

1 – Sell Signal (arrow)

bool sellSignal = getValueMLAdaptiveSuperTrend(_Symbol, PERIOD_CURRENT, 1, shift) != EMPTY_VALUE;

2 – Buy Cluster Number

double buyClusterNumber = getValueMLAdaptiveSuperTrend(_Symbol, PERIOD_CURRENT, 2, shift);

3 – Sell Cluster Number

double sellClusterNumber = getValueMLAdaptiveSuperTrend(_Symbol, PERIOD_CURRENT, 3, shift);

4 – SuperTrend Value (Price)

double superTrendPrice = getValueMLAdaptiveSuperTrend(_Symbol, PERIOD_CURRENT, 4, shift);

Hopefully this article can help you more easily automate signals from the Machine Learning Adaptive Supertrend Scanner indicator into EA.

You can download the indicator at: