EA will not trade

 

I have an EA of a breakout strategy that no longer places trades. I stopped using it a year or so ago but changed the beginning and end times of the range which are both external variables. I have not changed the trading code since it ran successfully. Now it will trigger the Alerts in the code that tell the specifics of a trade when it happens, but the trade does not happen....only the alerts. The following shows where the alerts trigger and where the trading code is just not executed. The complete file is attached. Any ideas?

if(Bid >= High[h] + 1*Point)
{
if(SL > 0)
sl = Ask - SL*Point;
if(TP > 0)
tp = Ask + TP*Point;
if(BrokerECN)
{
iTicket = OrderSend(Symbol(), OP_BUY, GetLots(SL), Ask, Slippage, 0, 0, "", MagicNumber, 0, Blue);
if(iTicket > 0)
{
OrderModify(iTicket, OrderOpenPrice(), sl, tp, 0, CLR_NONE);
}

}
else
{
OrderSend(Symbol(), OP_BUY, GetLots(SL), Ask, Slippage, sl, tp, "", MagicNumber, 0, Blue);
}
lasttrade = Time[0];
SLMoved = 0;

Alert("* Price: ", Ask," SL: ",sl," TP: ",tp);
Alert(Symbol(),"DD:HH:MM ",DayOfWeek(),":",Hour(),":",Minute()," Buy ", GetLots(SL)," Lots");

Files:
mtcf_4a.mq4  12 kb
 

Please use this to post code . . . it makes it easier to read.


So if the Order fails, iTicket < 0, what do you do ? nothing, why don't you report the error then you might know what is going on . . .

What are Function return values ? How do I use them ?

 
iTicket = OrderSend(Symbol(), OP_BUY, GetLots(SL), Ask, Slippage, 0, 0, "", MagicNumber, 0, Blue);
if(iTicket > 0)
{
    OrderModify(iTicket, OrderOpenPrice(), sl, tp, 0, CLR_NONE);
}
And you can NOT use OrderOpenPrice() until you do a OrderSelect()
 
RaptorUK:

Please use this to post code . . . it makes it easier to read.
So if the Order fails, iTicket < 0, what do you do ? nothing, why don't you report the error then you might know what is going on . . .

What are Function return values ? How do I use them ?


What editor are you using
RaptorUK:

Please use this to post code . . . it makes it easier to read.
So if the Order fails, iTicket < 0, what do you do ? nothing, why don't you report the error then you might know what is going on . . .

What are Function return values ? How do I use them ?


What toolbar has the SRC button?
 
bluesman:

What editor are you using
What toolbar has the SRC button?

I am confused...I see the toolbar but what is the trick to getting code to format correctly? Sorry...I've done this before but just can't friggin remember....
 
bluesman:

1. What editor are you using
2. What toolbar has the SRC button?

1. For coding ? MetaEditor

2. The toolbar just above when you compose a message on this Forum . . .

 
bluesman:

I am confused...I see the toolbar but what is the trick to getting code to format correctly? Sorry...I've done this before but just can't friggin remember....

Compose a message, click the SRC button, paste your code into the window/box that appears, then click Insert at the bottom right.

 
RaptorUK:

Compose a message, click the SRC button, paste your code into the window/box that appears, then click Insert at the bottom right.

Ah...thank you. I will have time tomorrow....thanks again. Also, I can't seem to find the switch to be notified of responses by email..I know it is here somewhere, but I could not locate it. thanks again, Raptor....
 
bluesman:
Also, I can't seem to find the switch to be notified of responses by email..I know it is here somewhere, but I could not locate it. thanks again, Raptor....

Click Subscribe to topic . . . I don't get email notifications though even if I subscribe . . .
 
Trades are not executed but the Alerts execute fine....it worked fine about a year ago......????
         if(SL > 0)
            sl = Ask - SL*Point;
         if(TP > 0)
            tp = Ask + TP*Point;
         if(BrokerECN)
         {
            iTicket = OrderSend(Symbol(), OP_BUY, GetLots(SL), Ask, Slippage, 0, 0, "", MagicNumber, 0, Blue);
            if(iTicket > 0)
            {
               OrderModify(iTicket, OrderOpenPrice(), sl, tp, 0, CLR_NONE);
            }
                      
         }
         else
         {
            OrderSend(Symbol(), OP_BUY, GetLots(SL), Ask, Slippage, sl, tp, "", MagicNumber, 0, Blue);
         }
         lasttrade = Time[0];
         SLMoved = 0;
         
         Alert(Symbol(),"* Price: ", Ask," SL: ",sl," TP: ",tp);
         Alert(Symbol(),"DD:HH:MM  ",DayOfWeek(),":",Hour(),":",Minute()," Buy ", GetLots(SL) ," Lots");
 
bluesman:
Trades are not executed but the Alerts execute fine....it worked fine about a year ago......????

A year ago you were on a 4 digit non-ECN broker. Now you are not.

  1. You didn't check return code before and you still aren't as requested.
  2. You are still useing OrderOpenPrice you can't
  3. You're not modify tp, sl and SLIPPAGE for 5 digit brokers.

If you're not going to modify your code when we answer your question, NOBODY can help you.

Reason: