Why this EA did not work

malincho99

Junior member
Messages
16
Likes
0
This is a EA for schedule trading i mean a specific hour but unfortunately did not work.Any suggestion or help?:!:
 
Sorry,here is code
//+------------------------------------------------------------------+
//| TimeBasedEA.mq4 |
//| Copyright © 2008, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
//changed by: "[email protected]"

// Time frame: M5 and higher

extern int MagicNumber = 20080122;
extern int OpenHour = 8;
extern int OpenMinute = 55;
extern double TakeProfit = 10;
extern double StopLoss = 10;
extern double Lots = 0.1;
extern bool OpenBuy = true;
extern bool OpenSell = false;
extern int NumBuys = 2;
extern int NumSells = 2;
extern int Slippage = 3;

//+------------------------------------------------------------------+
//| S T A R T |
//+------------------------------------------------------------------+
int start()
{
int cnt, ticket, total;
//int ct;
//-------------------------------------+
if(Bars<100)
{
Print("bars less than 100");
return(0);
}
//-------------------------------------+
if(TakeProfit<10)
{
Print("TakeProfit less than 10");
return(0); // check TakeProfit
}
//-------------------------------------+
//ct = Hour() * 100 + Minute();
total=OrdersTotal();
if(total<1)
{
// no opened orders identified
if(AccountFreeMargin()<(1*Lots))
{
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}
// check for long position (BUY) possibility
if (Hour()==OpenHour && Minute()>=OpenMinute && OpenBuy)
//if(ct == StartHour && Close[1]>Open[1] && OpenBuy)
//if(ct == StartHour && High[1]<Open[0] && OpenBuy)
{
for ( cnt = 0; cnt < NumBuys; cnt++)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Bid-StopLoss*Point,Ask+TakeProfit*Point,"",MagicNumber,0,Blue);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
}
return(0);
}
// check for short position (SELL) possibility
if (Hour()==OpenHour && Minute()>=OpenMinute && OpenSell)
//if(ct == StartHour && Close[1]<Open[1] && OpenSell)
//if(ct == StartHour && Low[1]>Open[0] && OpenSell)
{
for ( cnt = 0; cnt < NumSells; cnt++)
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,Ask+StopLoss*Point,Bid-TakeProfit*Point,"",MagicNumber,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
}
else Print("Error opening SELL order : ",GetLastError());
}
return(0);
}
}
return(0);
}

// the end
 
I suspect that you have some error messages in the Experts or Journal tab of MT4.
A possible area for issue is the "stoploss and targets" they may be below the minimums for your broker *and* Alpari for example my SL and TPs need to be multiplied by a factor of 10 as its a 5 digit broker.

so 10pips would be 100pipettes

look at your logs or try running it in the strategy builder

Sorry,here is code
//+------------------------------------------------------------------+
//| TimeBasedEA.mq4 |
//| Copyright © 2008, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
//changed by: "[email protected]"

// Time frame: M5 and higher

extern int MagicNumber = 20080122;
extern int OpenHour = 8;
extern int OpenMinute = 55;
extern double TakeProfit = 10;
extern double StopLoss = 10;
extern double Lots = 0.1;
extern bool OpenBuy = true;
extern bool OpenSell = false;
extern int NumBuys = 2;
extern int NumSells = 2;
extern int Slippage = 3;

//+------------------------------------------------------------------+
//| S T A R T |
//+------------------------------------------------------------------+
int start()
{
int cnt, ticket, total;
//int ct;
//-------------------------------------+
if(Bars<100)
{
Print("bars less than 100");
return(0);
}
//-------------------------------------+
if(TakeProfit<10)
{
Print("TakeProfit less than 10");
return(0); // check TakeProfit
}
//-------------------------------------+
//ct = Hour() * 100 + Minute();
total=OrdersTotal();
if(total<1)
{
// no opened orders identified
if(AccountFreeMargin()<(1*Lots))
{
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}
// check for long position (BUY) possibility
if (Hour()==OpenHour && Minute()>=OpenMinute && OpenBuy)
//if(ct == StartHour && Close[1]>Open[1] && OpenBuy)
//if(ct == StartHour && High[1]<Open[0] && OpenBuy)
{
for ( cnt = 0; cnt < NumBuys; cnt++)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Bid-StopLoss*Point,Ask+TakeProfit*Point,"",MagicNumber,0,Blue);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
}
return(0);
}
// check for short position (SELL) possibility
if (Hour()==OpenHour && Minute()>=OpenMinute && OpenSell)
//if(ct == StartHour && Close[1]<Open[1] && OpenSell)
//if(ct == StartHour && Low[1]>Open[0] && OpenSell)
{
for ( cnt = 0; cnt < NumSells; cnt++)
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,Ask+StopLoss*Point,Bid-TakeProfit*Point,"",MagicNumber,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
}
else Print("Error opening SELL order : ",GetLastError());
}
return(0);
}
}
return(0);
}

// the end
 
I suspect that you have some error messages in the Experts or Journal tab of MT4.
A possible area for issue is the "stoploss and targets" they may be below the minimums for your broker *and* Alpari for example my SL and TPs need to be multiplied by a factor of 10 as its a 5 digit broker.

so 10pips would be 100pipettes

look at your logs or try running it in the strategy builder

after running on Alpari I'd say its the stoploss thats causing an issue... you must be on a 5 digit broker also.
 
Unfortunately advice did not work,a am used 4 digit broker,and there is no info in journal tab
 
hmm I ran it on alpari and it does print errors if it fails to trade..... are you sure that you have it "enabled" for live trading?
 
All option is on for live trading and enable expert advisor , i have a demo account in Admirall which is 4 digit broker
 
Hello
I am sort of new. I was considering buying the Pro Forex Robot or one other. Now that Pro Forex Robot has been released, it doesn’t seem like a good idea to try it? I was shocked to see the pictures about the model who is possing as a trader and developer.

So its time that I ask around, And see if any one heard of Pips In The Bank EA.com ?

Someone in a chat had told me about it and I was thinking about getting it and thought I ask if anyone had known any info on it

Thanks.
 
Top