Expert advisor sharing

 
I have an EA I have coded using a custom indicator and it's working well. Now here comes my problem I want to share the EA to a friend but I don't want to share the indicator ex4 file with them. Is there a way of incorporating the indicator then share the EA file with them. Note I don't want them to have access on my indicator just EA file. Kindly help
 
Ernest Akoyi:
I have an EA I have coded using a custom indicator and it's working well. Now here comes my problem I want to share the EA to a friend but I don't want to share the indicator ex4 file with them. Is there a way of incorporating the indicator then share the EA file with them. Note I don't want them to have access on my indicator just EA file. Kindly help

Yes

  • compile your indicator with the could compiler
  • place the indicator .ex5 in the same folder as the EA
  • include the line #resource and the indicator name in your EA
  • create a handle for the indicator using the prefix "::" and indicator file name
  • compile your EA with the cloud compiler too

Here is an example

#property version   "1.00"
#resource "blabla.ex5";

int handle=0;
bool setup=false;
datetime barStamp=0;
int OnInit()
  {
   setup=false;
   barStamp=0;
   return(INIT_SUCCEEDED);
  }

void OnDeinit(const int reason)
  {
  if(handle!=INVALID_HANDLE){
    IndicatorRelease(handle);
    }
  }
void OnTick()
  {
  if(setup){
    datetime now=iTime(_Symbol,_Period,0);
    if(now>barStamp){
      barStamp=now;
      double buff[];
      CopyBuffer(handle,0,0,1,buff);
      Print("Indicator ("+buff[0]+")");
      }
    }else{
    handle=iCustom(_Symbol,_Period,"::blabla.ex5",4,2.7);
    if(handle!=INVALID_HANDLE){
    setup=true;
    }
    }
  }
Files:
blabla.mq5  2 kb
 
Lorentzos Roussos #:

Yes

  • compile your indicator with the could compiler
  • place the indicator .ex5 in the same folder as the EA
  • include the line #resource and the indicator name in your EA
  • create a handle for the indicator using the prefix "::" and indicator file name
  • compile your EA with the cloud compiler too

Here is an example

Thank you for your assistance. How can I do it in mql4 since it's an ex4 file. I have little knowledge in coding mql5 language 

 
Ernest Akoyi #:

Thank you for your assistance. How can I do it in mql4 since it's an ex4 file. I have little knowledge in coding mql5 language 

Also I do not wish to share my indicator with anyone just EA  ex4 file how can I do it

 
Ernest Akoyi #:

Also I do not wish to share my indicator with anyone just EA  ex4 file how can I do it

Same process without the handle creation and you call straight up with iCustom to use it adding the "::" prefix in the name.

The indicator when you resource it , it is in the EA you don't need to send it (like when you order pizza the pepperoni is on the pizza ,they don't have to send a pack of pepperonis with the order) , but , you have to be careful :

  • When you edit the indicator you must make sure you edited the one on the proper folder
  • When you edit the indicator you must also hit compile on the EA
 
Lorentzos Roussos #:

Same process without the handle creation and you call straight up with iCustom to use it adding the "::" prefix in the name.

The indicator when you resource it , it is in the EA you don't need to send it (like when you order pizza the pepperoni is on the pizza ,they don't have to send a pack of pepperonis with the order) , but , you have to be careful :

  • When you edit the indicator you must make sure you edited the one on the proper folder
  • When you edit the indicator you must also hit compile on the EA

Thank you I also with to get your assistance on this grid function, currently it opens orders after the specified distance if they are running negative. I want the function to only open grid orders once a signal is triggered at the specified distance. That is if specified distance is 55 pips then at 55 pips the condition for either sell or buy is met the  grid will trigger the order

void Grid()
  {
    
     if(use_marti == true)
       {
            
            if(data.buys > 0)
               {
                  if(Ask <= data.buy_open_price - marti_Distance * Point())
                     {
                        double lots = data.buy_lots;
                        if(use_marti && multiplier > 0)lots = lots * multiplier;
                        
                        BUY(lots);
                        
                        data = GetData(data);
                        ModifyTP();
                     }
               }
               
            if(data.sells > 0)
               {
                  if(Bid >= data.sell_open_price + marti_Distance * Point())
                     {
                        double lots = data.sell_lots;
                        if(use_marti && multiplier > 0)lots = lots * multiplier;
                        
                            data = GetData(data);
                            SELL(lots);
                            ModifyTP();
                             
                     }
               }
              
       }         
  } 
 
Ernest Akoyi #:

Thank you I also with to get your assistance on this grid function, currently it opens orders after the specified distance if they are running negative. I want the function to only open grid orders once a signal is triggered at the specified distance. That is if specified distance is 55 pips then at 55 pips the condition for either sell or buy is met the  grid will trigger the order

It depends 

You can check if the distance has been breached only if you receive a buy or sell signal from the indicator..

Or you can carry the switches after the check until they change , and if the distance is breached and the switch is active , take the trade .

(and don't forget to reset the switches after the trade)

 
Lorentzos Roussos #:

It depends 

You can check if the distance has been breached only if you receive a buy or sell signal from the indicator..

Or you can carry the switches after the check until they change , and if the distance is breached and the switch is active , take the trade .

(and don't forget to reset the switches after the trade)

Thank you

 
Your topic has been moved to the section: MQL4 and MetaTrader 4
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Forum rules and recommendations
Forum rules and recommendations
  • 2023.03.12
  • www.mql5.com
Each language has its own forum, and it is therefore forbidden to communicate in any language other than that of the forum in question...
Reason: