Is this expert advisor safe to use?

 

Hi. I'm new to this expert advisor thing and also to the language of MQL4 can anyone help to check and see any errors or anything that can be improved? Here is the code for it:

//+------------------------------------------------------------------+
//| TrendBuyer v1.mq4 |
//| Copyright © 2011, MetaQuotes Software Corp. |
//| https://www.metaquotes.net// |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, MetaQuotes Software Corp."
#property link "https://www.metaquotes.net//"
//int OrderSend (Trading currency (symbol), buy/sell (OP_BUY/OP_SELL), volume of bar,
//price amt (Use Ask for buy and use Bid for sell), slippage value (int 0-3), stoploss value, takeprofit value)

int TicksWithLowADX = 0;
bool ExplosiveIsReady = False;
bool ExplosiveIsBought = False;
double Price1,Price2,Price3,Price4,Price5;

int init()
{
Alert("TrendBuyer v2.1 is loaded. Please check the Forex list trade order errors if any error occurs.");
return(0);
}

int start()
{
double MacdCurrent, MacdPrev, ADXValue, SignalCurrent, SignalPrev, MacdSelfValue;
int ticket;

MacdCurrent=iMACD("EURUSD",0,12,26,9,PRICE_CLOSE,MODE_MAIN,0);
MacdPrev=iMACD("EURUSD",0,12,26,9,PRICE_CLOSE,MODE_MAIN,1);
ADXValue=iADX("EURUSD",0,14,PRICE_CLOSE,MODE_MAIN,0);
SignalCurrent=iMACD("EURUSD",0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0);
SignalPrev=iMACD("EURUSD",0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1);
MacdSelfValue=0.00001;
Price1 = iClose(Symbol(),0,0);
Price2 = iClose(Symbol(),0,1);
Price3 = iClose(Symbol(),0,2);
Price4 = iClose(Symbol(),0,3);
Price5 = iClose(Symbol(),0,4);

Print("Current MACD value: ",MacdCurrent);
Print("Current MACD signal: ",SignalCurrent);
Print("Current ADX value: ",ADXValue);
Print("Ticks with low ADX value: ",TicksWithLowADX);
Print("Price1: ",Price1," Price2: ",Price2," Price3: ",Price3);

if(OrdersTotal()<1)
{
Print("Total orders < 1");
if(AccountFreeMargin()>100.0)
{
Print("Account free margin > 100.0");
if(ADXValue>39.0)
{
TicksWithLowADX=0;
ExplosiveIsReady = False;
Print("ADX>33; Trend strength is good!");
if(MacdCurrent<-1*MacdSelfValue)
{
Print("MACD<-0.00001: BUY STEP 1");
if(MacdCurrent>SignalCurrent)
{
Print("MACD>Signal: BUY STEP 2");
if(MacdPrev<SignalPrev)
{
Print("MACD1<Signal1: BUY STEP 3");
Print("Order is in progress...");
ticket=OrderSend(Symbol(),OP_BUY,0.1,Ask,2,Ask-6*Point,Ask+4*Point,"TrendBuyer_BUY",1000,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
{
Alert("BUY order opened @ ",OrderOpenPrice(),", with ticket no. ",ticket,". Order sent successfully!");
}
} else { Alert("Error opening BUY order : ",GetLastError()); }
}
}
}

if(MacdCurrent>1*MacdSelfValue)
{
Print("MACD>0.00001 SELL STEP 1");
if(MacdCurrent<SignalCurrent)
{
Print("MACD>SIGNAL: SELL STEP 2");
if(MacdPrev>SignalPrev)
{
Print("MACD1>SIGNAL1: SELL STEP 3");
Print("Order is in progress...");
ticket=OrderSend(Symbol(),OP_SELL,0.1,Bid,2,Bid+6*Point,Bid-4*Point,"TrendBuyer_SELL",1001,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
{
Alert("BUY order opened @ ",OrderOpenPrice(),", with ticket no. ",ticket,". Order sent successfully!");
}
} else { Alert("Error opening SELL order : ",GetLastError()); }
}
}
}
}
else
{
TicksWithLowADX++;
if(TicksWithLowADX>60)
{
Print("Preparing to buy/sell using explosive method...");
ExplosiveIsReady = True;
}
}
if(ExplosiveIsReady)
{
Print("Explosive is ready: LOOP HANDLING");

if(Price1>Price2&&MacdCurrent>SignalCurrent&&MacdCurrent>0*MacdSelfValue)//&&Price2>Price3&&Price3>Price4&&Price4>Price5)
{
Print("Order is in progress...");
ticket=OrderSend(Symbol(),OP_BUY,0.1,Ask,2,Ask-6*Point,Ask+5*Point,"TrendBuyer_BUY_EXPLODE",1002,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
{
Alert("BUY explosive order opened @ ",OrderOpenPrice(),", with ticket no. ",ticket,". Order sent successfully!");
ExplosiveIsBought = True;
}
} else { Alert("Error opening BUY EXPLOSIVE order : ",GetLastError()); }
}

if(Price1<Price2&&MacdCurrent<SignalCurrent&&MacdCurrent<0*MacdSelfValue)//&&Price2<Price3&&Price3<Price4&&Price4<Price5)
{
Print("Order is in progress...");
ticket=OrderSend(Symbol(),OP_SELL,0.1,Bid,2,Bid+6*Point,Bid-5*Point,"TrendBuyer_SELL_EXPLODE",1003,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
{
Alert("SELL explosive order opened @ ",OrderOpenPrice(),", with ticket no. ",ticket,". Order sent successfully!");
ExplosiveIsBought = True;
}
} else { Alert("Error opening SELL EXPLOSIVE order : ",GetLastError()); }
}

if(ExplosiveIsBought)
{
ExplosiveIsReady = False;
TicksWithLowADX = 0;
}
}
}
}
return(0);
}

int deinit()
{
Alert("TrendBuyer v2.1 unititialised because of reason ",UninitializeReason());
return(0);
}

 

Is this expert advisor safe to use?

No.

 

  1. SignalPrev=iMACD("EURUSD",0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1);
    Price1 = iClose(Symbol(),0,0);
    Can't put the EA on any other chart other than EURUSD
  2. ticket=OrderSend(Symbol(),OP_BUY,0.1,Ask,2,Ask-6*Point,Ask+4*Point,"TrendBuyer_BUY",1000,0,Green);
    
    Won't work on most 5 digit brokers (stoplevel==30, you're using 4. ) EA's must adjust TP, SL, AND slippage. On ECN brokers you must open and THEN set stops.
    //++++ These are adjusted for 5 digit brokers.
    int     pips2points;    // slippage  3 pips    3=points    30=points
    double  pips2dbl;       // Stoploss 15 pips    0.0015      0.00150
    int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)
    int     init(){
        if (Digits == 5 || Digits == 3){    // Adjust for five (5) digit brokers.
                    pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
        } else {    pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; }
        // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
    

  3. Is this expert advisor safe to use?
    The moment conditions are right, the EA will open a trade. Next tick open a trade. Next tick...
 

Ok... But is there any exact code that I can use?

 
matt28:

Ok... But is there any exact code that I can use?


Don't code cut-&&-paste. If you have the time then learn to do it properly from the book. To make a save program, you'll want to understand most of the concepts presented here.
 
matt28:
Ok... But is there any exact code that I can use?
No slaves here, learn to code or pay someone.