How to Create Custom Plugin

This post I will describe how to create custom plugin for develop your own strategy to open initial trade in CAP Zone Recovery EA. For do that you have to develop custom indicator (we call it custom plugin) so cap zone recovery EA can get initial trade signal from your custom plugin.

Actually custom plugin is just a indicator, EA use iCustom function to get signal from your custom indicator to open initial trade.

You have to Minimum CAP Zone Recovery EA version 5.50 and above. Below 5.50 will not work this example.

You can develop your own Plugin and upload on market place and earn money.

 


 

 

To active Custom Plugin into CAP Zone Recovery EA

  1. Custom PlugIn: Under this method the EA will automatically open initial trade from your own developed indicator.
    • Place both the CAP Zone Recovery EA on charts of the instrument to be traded.
    • Select Custom Plugin Trade under Initial Trade Type.
    • Configure necessary input setting from Initial Trade Custom Plugin) section.
    • PluginName – Put you custom indicator name.
    • PluginInputSetting – You can send data to your custom indicator. Basically you can send indicator setting separate by “;”.

When you select Initial trade Type = Custom Plugin, CAP Zone Recovery EA Use below Function to get data from your custom indicator. I give the function from CAP Zone Recovery EA so you can get idea how EA get data form custom indicator

void Custom_Signal()
{
   
   int Signal =0;
   
   Signal     = (int)iCustom(_symbol,PERIOD_CURRENT,PluginName,PluginInputSetting,0,0);

   if(Signal==1)
   {
      if(!ReverseSignals){ 
        BuyCondition = true;
      }else{
        SellCondition = true;
      } 
   }
   
   if(Signal==2)
   {
      if(!ReverseSignals){ 
        SellCondition = true;
      }else{
        BuyCondition = true;
      } 
   }
}

IMPORTANT

 

  1. Your custom indicator must have to one Input that input you set data to your custom indicator.
  2. iCustom only use 0 buffer to get signal. So your custom indicator 0 buffer consider as signal buffer.
  3. iCustom only use only current bar to get signal.

 


How to Develop Indicator (Custom Plugin) for CAP Zone Recovery EA.

Download Example File from Attachment  below. I will try explain every code from example file, you can modify code by yourself as per your requirement or you can full code by yourself. Just keep in mean you have to fellow four rule –

 

  1. You have to send signal only BUFFER 0.
  2. Value 1 consider as BUY Signal
  3. Value 2 consider as SELL Signal
  4. Indicator must have minimum one string type input. You have set your custom indicator setting with this input.

 

In example code i use RSI indicator for custom strategy to open initial trade. Example i want CAP Zone Recovery EA will open initial trade like below –

 

  • To open  Buy trade when RSI Value < 30
  • To open  Sell trade when RSI Value > 70

 

//+------------------------------------------------------------------------+
//|                                      CAP_ZoneRecovery_Plugin.mq4       |
//|                               Copyright © 2010-2014, Capilta.com       |
//|                                          https://www.Capilta.com       |
//|                                                                        |
//|  This custom indicator is template of CAP Zone Recovery EA's plugin    |
//|  It is a sample code to make entry logic for initial open trade.       |
//|                                                                        |
//+------------------------------------------------------------------------+

#property copyright   "Copyright © 2010-2015, Capilta Business Solutions"
#property link        "http://www.capilta.com"
#property version     "1.00"
#property strict

–> Write your file name, copyright, like and file version.

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots   0

–> In this example i use indicator buffer 1 only. you can create several  buffer as per your requirements. but keep in mind in CAP Zone Recovery EA only get signal from buffer – 0. So have to send signal to CAP Zone Recovery EA only buffer [0]

//--- input parameters
input string PluginInputSetting = "";

–> “PluginInputSetting” is a input this is the input you can get data from CAP Zone Recovery EA.

//+------------------------------------------------------------------+
//|   Buffer for send signal to main EA                                
//|   ExtEntryBuffer - 
//                     1 - Value for BUY Signal  
//|                    2 - Value for SELL Signal                           
//+------------------------------------------------------------------+      
    
double ExtEntryBuffer[];

–> Create Variable from Indicator Buffer.  So when Buffer value 1 then CAP Zone Recovery EA will open BUY Trade and when Buffer Value 2 Then CAP Zone Recovery will SELL Signal.

//+------------------------------------------------------------------+
//| Variable for Indicator                                           |
//+------------------------------------------------------------------+
int                  RSIPeriod     = 14;
ENUM_APPLIED_PRICE   RSIPrice      = PRICE_CLOSE;
int                  RSISellLevel  = 70;
int                  RSIBuyLevel   = 30;

 

–> Set of variable for RSI.

 

/+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,ExtEntryBuffer,INDICATOR_CALCULATIONS);

    
//--- change the order of accessing elements of the indicator buffer 
   ArraySetAsSeries(ExtEntryBuffer,true); 
   
   
//--- get indicator setting data from EA by input  "PluginInputSetting"
//--- split data and separate value by ";" 
     
     if(PluginInputSetting!="")
     {
        string value[];
        StringSplit(PluginInputSetting,StringGetCharacter(";",0),value);
        
        if(ArraySize(value)>0)
        {
          if(value[0]!="")                     RSIPeriod = (int)value[0];
        }
        
        if(ArraySize(value)>1)
        {
           if(value[1]=="PRICE_CLOSE")          RSIPrice  = PRICE_CLOSE;
           else if(value[1]=="PRICE_HIGH")      RSIPrice  = PRICE_HIGH;
           else if(value[1]=="PRICE_LOW")       RSIPrice  = PRICE_LOW;
           else if(value[1]=="PRICE_MEDIAN")    RSIPrice  = PRICE_MEDIAN;
           else if(value[1]=="PRICE_OPEN")      RSIPrice  = PRICE_OPEN;
           else if(value[1]=="PRICE_TYPICAL")   RSIPrice  = PRICE_TYPICAL;
           else if(value[1]=="PRICE_WEIGHTED")  RSIPrice  = PRICE_WEIGHTED;
        }
        
        if(ArraySize(value)>2)
        {
           if(value[2]!="")                     RSISellLevel = (int)value[2];
        }
        
        if(ArraySize(value)>3)
        {
           if(value[3]!="")                     RSIBuyLevel  = (int)value[3];
        }
     }
 
//---
   return(INIT_SUCCEEDED);
  }

 

–> In OnInit() function i set Indicator buffers mapping.
–> Split and separate data that come from CAP Zone Recovery EA’s input.

 

//+------------------------------------------------------------------+
//| 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[])
  {
      
      ExtEntryBuffer[0] = 0;

      ExtEntryBuffer[0] = Signal_Entry(Symbol(),PERIOD_CURRENT);

      return(rates_total);
  }

 

 

–> In OnCalculate I set ExtEntryBuffer[0] = 0;
–> Then i set signal value to  ExtEntryBuffer[0] with function Signal_Entry();

//+------------------------------------------------------------------+
int Signal_Entry(string Sym,ENUM_TIMEFRAMES TF)
  {

      double RSI_Value=iRSI(Sym,TF,RSIPeriod,RSIPrice,0);
   
      if( RSI_Value < RSIBuyLevel )  return(1);
      if( RSI_Value > RSISellLevel ) return(2);
   
      return(0);

  }
  
//+------------------------------------------------------------------+

–> When RSI value below RSIBuyLevel will return 1. Because value 1 for BUY Signal
–> When RSI value above RSISellLevel will return 2. Because value 2 for SELL Signal

IMPORTANT 

Try to understand code by yourself. Keep in Mind you will give any support to education to understand MQL coding. Coding related any question will be ignore.