User Input Dialog box on running Expert Advisor

 

Hello, champs!

Tried to search around and couldn't find a proper solution.

I'm trying to create an EA that detects pending orders I place from my mobile terminal.

It will extract some information from the order and close it. It will instead remember the details, and calculate new entries and exits based on my strategy once on every new candle.

It will trail the price until the price reverses and breaches the latest entry level and we can open the trade by market execution.

Each trade instance can be in three statuses, active, inactive, and invalidated.

private:
   // other fields
   int               status; // 1 - active 2 - Inactive 3 - Invalidated
   double            invalidationPrice;

On the creation of a new trade instance, status is initially set to inactive (2)

public:
                     Chaser(string _symbol, ENUM_ORDER_TYPE _orderType, ENUM_TIMEFRAMES _TF)
     {
      // Other initializing
      this.status = 2; // inactive
      SetInvalidationPrice();
      CalculateTradeParameters();
     }

After trade parameters have been calculated status is set to active (1)

   void              CalculateTradeParameters()
     {
      // Calculation and updating fields
      status = 1; // active
     }

Now I want to set it to invalidated on either of the two conditions:

  • A trade is taken by market
  • Price breaches an invalidation level - which is the extreme boundary of the my zone of interest

   void              CheckAndExecuteTrade()
     {

      if(status == 1) // active
        {
         // take a trade if conditions are met
            status = 3; //then set the instance to invalid
           }
         else
            if(an extra condition for inactive)
              {
               status = 2; //set inactive
              }
            else
               if((orderType == ORDER_TYPE_BUY_STOP && currentPrice < invalidationPrice) ||
                  (orderType == ORDER_TYPE_SELL_STOP && currentPrice > invalidationPrice))
                 {
                  status = 3; //Set to invalid if invalidation price is breached.
                 }
        }
     }

My problem is that, the invalidation price isn't something the EA can calculate. These are levels I set at my discretion and on different charts. I want to implement a way it will ask me for the invalidation price every time a new instance is created. I tried the MessageBox but it wont work with user input fields.

   void               SetInvalidationPrice()
     {
      //Prompt the user to input invalidation price
      // Set the InvalidationPrice field with the input
      // int ret = MessageBox("Enter invalidation price", ...); wont work
     }

Is there a proper way to do this right? Thanks in advance.

 
Kevin Onsongo:
I want to implement a way it will ask me for the invalidation price every time a new instance is created.

Do you think using Comment section will help you to pass those levels.

 
Yashar Seyyedin #:

Do you think using Comment section will help you to pass those levels.

Hello, do you mean trade comments? I can't find a way they can help update the field since comments are only made when sending the trade request. And the trade server can change them.
 
Kevin Onsongo:

Hello, champs!

Tried to search around and couldn't find a proper solution.

I'm trying to create an EA that detects pending orders I place from my mobile terminal.

It will extract some information from the order and close it. It will instead remember the details, and calculate new entries and exits based on my strategy once on every new candle.

It will trail the price until the price reverses and breaches the latest entry level and we can open the trade by market execution.

Each trade instance can be in three statuses, active, inactive, and invalidated.

On the creation of a new trade instance, status is initially set to inactive (2)

After trade parameters have been calculated status is set to active (1)

Now I want to set it to invalidated on either of the two conditions:

  • A trade is taken by market
  • Price breaches an invalidation level - which is the extreme boundary of the my zone of interest

My problem is that, the invalidation price isn't something the EA can calculate. These are levels I set at my discretion and on different charts. I want to implement a way it will ask me for the invalidation price every time a new instance is created. I tried the MessageBox but it wont work with user input fields.

Is there a proper way to do this right? Thanks in advance.

I found a quick workaround, where I will set the invalidation price as a stop, SL or TP when I set pending orders from my phone. The downside is that, setting that will take a little bit more time and I may miss entry if price makes a quick turn. I wanted the trade instance to be already active as I am inputting the invalidation price.