Script to attach to EA help please

Hi guys, please I need help to plug these two things together…

I have this EA (mql4), which is monitoring the account Balance, Equity and Profit. When the set profit or the set loss % is reached the robot closes all open trades.

I also want the Autotrade in Mt4 to be turned off to prevent the main EA to open new trades.

I have a Script for that, but I don’t know how to plug it in to EA. Can somebody please help me?

The EA


//If sett loss or profit reached close all trades and stop EA

extern double equity_percent_from_balances=0.9;
extern int profit_target=200;

int start()
{

if(AccountEquity()<(AccountBalance()*equity_percent_from_balances) || (AccountProfit()>profit_target))
{
int total=OrdersTotal();

  for(int i=total-1;i&gt;=0;i--)
    {
     if(OrderSelect(i,SELECT_BY_POS)==true)
       {
        int type=OrderType();

        bool result=false;

        switch(type)
          {
           case OP_BUY       : result=OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),5,Red);
           break;
           case OP_SELL      : result=OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),5,Red);
          }

        if(result==false)
          {
           Sleep(0);
          }
       }
    }
 }

return(0);
}


The script


#include <WinUser32.mqh>

extern bool DisableAllEAs = TRUE;

void DisableEA() {
keybd_event(17, 0, 0, 0);
keybd_event(69, 0, 0, 0);
keybd_event(69, 0, 2, 0);
keybd_event(17, 0, 2, 0);
}

int start() {

if (DisableAllEAs == TRUE) {
DisableEA();
return (0);*
}}

Thanks very much!!!