Creating EA with custom indicators

 

Hello everyone

please i am in need of serious help

I have been trying to build an EA with this custom indicator Supertrend oma histo that i downloaded free from the market.

I am still learning the MQL5 programming language, all i intend doing is getting the EA to pick signals with the custom indicator from the indicator window and users should be able to change the indicator inputs and modify them according their observations.

who has an idea on how to write the code to pick the parameters from the indicator inside the indicator window and pick trades as the values change?

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_plots   1
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrDodgerBlue
#property indicator_label1  "Supertrend oma histo"

enum Prices
  {
   pr_close,      // Close
   pr_open,       // Open
   pr_high,       // High
   pr_low,        // Low
   pr_median,     // Median
   pr_median_body,
   pr_typical,    // Typical
   pr_weighted,   // Weighted
   pr_average,    // Average (high+low+open+close)/4
   pr_tbiased,    // Trend biased price
   pr_tbiased_HL,   // Trend biased (extreme) price
  };
 
enum Averagesmethods
  {
   Simple_Moving_Average,       // SMA
   Exponential_Moving_Average,       // EMA
   Double_EMA,        // DoubleEMA
   Tripple_EMA,     // Tripple EMA
   Smoothed_MA,    // Smoothed MA
   Linear_weigthed_MA,   // Linear weigthed MA
   Parabolic_weighted_MA,    // Parabolic weighted MA
   Alexander_MA,    // Alexander MA
   Volume_weighted_MA,    // Volume weighted MA
   Hull_MA,   // Hull MA
   Triangular_MA,    // Triangular MA
   sine_weighted_MA,     // sine_weighted_MA
   Linear_regression_value,     // Linear regression value
   Non_lag_MA,   // Non_lag_MA
   Zero_lag_EMA,  // Zero_lag_EMA
   Leader_EMA, // Leader_EMA
};



input double AveragesPeriod = 15;
input Averagesmethods Averagesmethod = Parabolic_weighted_MA;
input Prices  Price        = pr_close; // Price
input double ATRperiod      = 14;
input double ATRmultiplier  = 1.6;

input double Lots = 0.01;
int handle;
int barsTotal;

input double    InpTakeProfitPts    =  200;
input double    InpStopLossPts      =  200;

input string PathIndicator = "Market\\Supertrend oma histo.ex5";

#include <Trade/Trade.mqh>
CTrade trade;

int OnInit(){
   
   handle = iCustom(_Symbol,PERIOD_CURRENT,PathIndicator);
   barsTotal = iBars(_Symbol,PERIOD_CURRENT);

   return(INIT_SUCCEEDED);
  }

void OnDeinit(const int reason){

   
  }

void OnTick(){
   int bars = iBars(_Symbol,PERIOD_CURRENT);
   if(bars > barsTotal){
      barsTotal = bars;
      
      double Matze-Supertrend(oma)[];
      CopyBuffer(handle,1,1,2,Matze-Supertrend(oma));
      
      if(Matze-Supertrend(oma)[1.000] != 0 && Matze-Supertrend(oma)[1.000] <= 1){
        
         trade.Buy(Lots,_Symbol,InpTakeProfitPts,InpStopLossPts);
        }else if(Matze-Supertrend(oma)[2.000] != 1 && Matze-Supertrend(oma)[2.000] >= 2){
                 
                  trade.Sell(Lots,_Symbol,InpTakeProfitPts,InpStopLossPts);

                }
      
     

     }
   
   
   
  }
How to Order a Trading Robot in MQL5 and MQL4
How to Order a Trading Robot in MQL5 and MQL4
  • www.mql5.com
"Freelance" is the largest freelance service for ordering MQL4/MQL5 trading robots and technical indicators. Hundreds of professional developers are ready to develop a custom trading application for the MetaTrader 4/5 terminal.
 
  1. Go to the CodeBase and look for an EA and amend it according to your ideas.
  2. Search for articles like: https://www.mql5.com/en/articles/100
  3. Here is the list of all function (for a keyword search with Ctrl+F) even iCustom that enables an EA to request the data of custom indicators.
Step-By-Step Guide to writing an Expert Advisor in MQL5 for Beginners
Step-By-Step Guide to writing an Expert Advisor in MQL5 for Beginners
  • www.mql5.com
The Expert Advisors programming in MQL5 is simple, and you can learn it easy. In this step by step guide, you will see the basic steps required in writing a simple Expert Advisor based on a developed trading strategy. The structure of an Expert Advisor, the use of built-in technical indicators and trading functions, the details of the Debug mode and use of the Strategy Tester are presented.