Orders opened without any arrow appearing

 

Hello,


I am coding an EA which is supposed to open trades only if my indicator draw an arrow but sometimes it opens order without any arrow.

Do you have an idea of this kind of issue?


Thank you!

 

Most likely the indicator repainted the current bar, and the arrow appeared only to disappear moments later.

 

I use this code. I guess I make sure an arrow is drawn.

But I still have the issue.

When I use the indicator, arrows are drawn but when I ask the EA to open trade with the indicator, there are orders when there is no arrow and some arrows have no order.


extern int Shift_Indicator = 1;

//Open Buy Order, instant signal is tested first

   if(isNewBar //Send order when new bar opens

   && iCustom(NULL, PERIOD_CURRENT, "EMA-JFTRADING", TOD_From_Hour, TOD_From_Min, TOD_To_Hour, TOD_To_Min, Send_Email, Audible_Alerts, Push_Notifications, 0, Shift_Indicator) != 0 && iCustom(NULL, PERIOD_CURRENT, "EMA-JFTRADING", TOD_From_Hour, TOD_From_Min, TOD_To_Hour, TOD_To_Min, Send_Email, Audible_Alerts, Push_Notifications, 0, Shift_Indicator) != EMPTY_VALUE //EMA-JFTRADING is not equal to fixed value

   )

     {

      RefreshRates();

      price = Ask;

      if(TradesCount(OP_BUY) + TradesCount(OP_SELL) > 0 || TimeCurrent() - LastCloseTime() < NextOpenTradeAfterHours * 3600) return; //next open trade after time after previous trade's close   

      if(IsTradeAllowed())

        {

         ticket = myOrderSend(OP_BUY, price, MM_Size(), "");

         if(ticket <= 0) return;

        }

      else //not autotrading => only send alert

         myAlert("order", "");

     }

   

   //Open Sell Order, instant signal is tested first

   if(isNewBar //Send order when new bar opens

   && iCustom(NULL, PERIOD_M15, "EMA-JFTRADING", TOD_From_Hour, TOD_From_Min, TOD_To_Hour, TOD_To_Min, Send_Email, Audible_Alerts, Push_Notifications, 1, Shift_Indicator) != 0 && iCustom(NULL, PERIOD_M15, "EMA-JFTRADING", TOD_From_Hour, TOD_From_Min, TOD_To_Hour, TOD_To_Min, Send_Email, Audible_Alerts, Push_Notifications, 1, Shift_Indicator) != EMPTY_VALUE //EMA-JFTRADING is not equal to fixed value

   )

     {

      RefreshRates();

      price = Bid;

      if(TradesCount(OP_BUY) + TradesCount(OP_SELL) > 0 || TimeCurrent() - LastCloseTime() < NextOpenTradeAfterHours * 3600) return; //next open trade after time after previous trade's close   

      if(IsTradeAllowed())

        {

         ticket = myOrderSend(OP_SELL, price, MM_Size(), "");

         if(ticket <= 0) return;

        }

      else //not autotrading => only send alert

         myAlert("order", "");

     }

  }
 
Jean Fils Mbende #:


Please edit and post your code properly using the code button

 
that looks like code from eabuilder? if so, there is many issues with using code from there. I often use eabuilder to build a typical template, but never use the code from there "as is". I think your issue is as was suggested in previous comment: your indicator repainted, removing the signal. But that does not mean the ea signal was bad. I often get same thing when using eabuilder code like this. It might just mean that your arrow disappeared at the last moment, but the ea had already sent the order to the broker.
 

try this... it might work faster with less resources, so it might catch change of signal faster...

extern int Shift_Indicator = 1;
bool buy = false, sell = false;
static double pnt = 1/pow(10,Digit);

//Open Buy Order, instant signal is tested first

if(isNewBar) //Send order when new bar opens
  {
   static datetime timeTradeAllowed;
   if(TimeCurrent() > timeTradeAllowed)
      timeTradeAllowed = LastCloseTime() + NextOpenTradeAfterHours * 3600;

   //if(TradesCount(OP_BUY) + TradesCount(OP_SELL) > 0 || TimeCurrent() - LastCloseTime() < NextOpenTradeAfterHours * 3600)
   if(OrdersTotal() > 0 || TimeCurrent() < timeTradeAllowed) // - lastclose < NextOpenTradeAfterHours * 3600)
      return; //next open trade after time after previous trade's close

   emaJFT();

   if(!buy && !sell)
      return;

   if(//iCustom(NULL, PERIOD_CURRENT, "EMA-JFTRADING", TOD_From_Hour, TOD_From_Min, TOD_To_Hour, TOD_To_Min, Send_Email, Audible_Alerts, Push_Notifications, 0, Shift_Indicator) != 0 && iCustom(NULL, PERIOD_CURRENT, "EMA-JFTRADING", TOD_From_Hour, TOD_From_Min, TOD_To_Hour, TOD_To_Min, Send_Email, Audible_Alerts, Push_Notifications, 0, Shift_Indicator) != EMPTY_VALUE //EMA-JFTRADING is not equal to fixed value
      buy)
     {
      RefreshRates();
      price = Ask;
      //if(TradesCount(OP_BUY) + TradesCount(OP_SELL) > 0 || TimeCurrent() - LastCloseTime() < NextOpenTradeAfterHours * 3600)
      //   return; //next open trade after time after previous trade's close
      if(IsTradeAllowed())
        {
         ticket = myOrderSend(OP_BUY, price, MM_Size(), "");
         if(ticket <= 0)
            return;
        }
      else //not autotrading => only send alert
         myAlert("order", "");
     }

//Open Sell Order, instant signal is tested first

//   if(isNewBar //Send order when new bar opens
   if(//iCustom(NULL, PERIOD_M15, "EMA-JFTRADING", TOD_From_Hour, TOD_From_Min, TOD_To_Hour, TOD_To_Min, Send_Email, Audible_Alerts, Push_Notifications, 1, Shift_Indicator) != 0 && iCustom(NULL, PERIOD_M15, "EMA-JFTRADING", TOD_From_Hour, TOD_From_Min, TOD_To_Hour, TOD_To_Min, Send_Email, Audible_Alerts, Push_Notifications, 1, Shift_Indicator) != EMPTY_VALUE //EMA-JFTRADING is not equal to fixed value
      sell)
     {
      RefreshRates();
      price = Bid;
      //if(TradesCount(OP_BUY) + TradesCount(OP_SELL) > 0 || TimeCurrent() - LastCloseTime() < NextOpenTradeAfterHours * 3600) return; //next open trade after time after previous trade's close
      //   return;
      if(IsTradeAllowed())
        {
         ticket = myOrderSend(OP_SELL, price, MM_Size(), "");
         if(ticket <= 0)
            return;
        }
      else //not autotrading => only send alert
         myAlert("order", "");
     }
   buy = sell = false;
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void emaJFT()
  {
   buy = iCustom(NULL, PERIOD_CURRENT, "EMA-JFTRADING", TOD_From_Hour, TOD_From_Min, TOD_To_Hour, TOD_To_Min, Send_Email, Audible_Alerts, Push_Notifications, 0, Shift_Indicator) > pnt ?true:false;
   sell = iCustom(NULL, PERIOD_CURRENT, "EMA-JFTRADING", TOD_From_Hour, TOD_From_Min, TOD_To_Hour, TOD_To_Min, Send_Email, Audible_Alerts, Push_Notifications, 1, Shift_Indicator) > pnt ?true:false;
  }
//+------------------------------------------------------------------+
 

Thank you I will try and let you know.

Yes this from eabuilder. What do you call template?

 
Jean Fils Mbende #: Yes this from eabuilder.

EA builder, EA Builder Pro, EATree, Etasoft forex generator, Forex Strategy Builder, ForexEAdvisor STRATEGY BUILDER, ForexRobotAcademy.com, FX EA Builder, fxDreema, Forex Generator, FxPro, Molanis, Octa-FX Meta Editor, Online Forex Expert Advisor Generator, Strategy Builder FX, Strategy Quant, Visual Trader Studio, MQL5 Wizard, etc., are all the same. You will get something quick, but then you will spend a much longer time trying to get it right, than if you learned the language up front, and then just wrote it.

  1. Since you haven't learned MQL4/5, therefor there is no common language for us to communicate.
    If we tell you what you need, you can't code it.
    If we give you the code, you don't know how to integrate it into yours.
    We are willing to HELP you when you post your attempt (using Code button) and state the nature of your problem, but we are not going to debug your hundreds of lines of code. You are essentially going to be on your own.

  2. EA builder makes bad code counting up while closing multiple orders.
    EA builder makes bad code Bars is unreliable (Max bars in chart), volume is unreliable (miss ticks.) Always use time.
    EA builder makes bad code, not adjusting for 4/5 digit brokers, TP/SL and slippage.
    EA builder makes bad code, not adjusting for ECN brokers. pre-Build 500)
    EA builder makes bad code, not checking return codes.

  3. EATree uses objects on chart to save values — not persistent storage (files or GV+Flush.) No recovery (crash/power failure.)

  4. FX EA Builder makes bad code, not checking return codes.
    FX EA Builder makes bad code, loosing open tickets on terminal restart. No recovery (crash/power failure.)
    FX EA Builder makes bad code, not adjusting stops for the spread.
    FX EA Builder makes bad code, using OrdersTotal directly.

  5. FOREXEADVISOR STRATEGY BUILDER makes bad code, non-updateing global variables.
    FOREXEADVISOR STRATEGY BUILDER makes bad code, compilation errors.
    FOREXEADVISOR STRATEGY BUILDER makes bad code, not checking return codes.

Learn to code it, or pay someone (Freelance) someone to code it.
          Hiring to write script - General - MQL5 programming forum #1 (2019)

Reason: