Colocando ordem e status

 

Boa tarde pessoal. Estou começando em MQL5 e estou tentando contruir algo basico para fins de teste. A ideia é colocar uma ordem e verificar o status dela e ao inicio de um novo candle, cancelar as ordens pendentes. Fiz um codigo:


//+------------------------------------------------------------------+
//|                                                    Candle.mq5 |
//|                                                   Copyright 2020 |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020"
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| INCLUDES                                                         |
//+------------------------------------------------------------------+
#include <Trade/Trade.mqh>


//+------------------------------------------------------------------+
//| GLOBAIS                                                          |
//+------------------------------------------------------------------+
//--- declara variáveis de libs
CTrade trade;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   

            
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   if(isNewBar()){
        trade.BuyStop(1,69000,_Symbol,68900,69100,ORDER_TIME_DAY,0,"Buy Stop");
   }
 
   

   
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool isNewBar()
  {
//--- memorize the time of opening of the last bar in the static variable
   static datetime last_time=0;
//--- current time
   datetime lastbar_time=(datetime)SeriesInfoInteger(Symbol(),Period(),SERIES_LASTBAR_DATE);

//--- if it is the first call of the function
   if(last_time==0)
     {
      //--- set the time and exit
      last_time=lastbar_time;
      return(false);
     }

//--- if the time differs
   if(last_time!=lastbar_time)
     {
      //--- memorize the time and return true
      last_time=lastbar_time;
      return(true);
     }
//--- if we passed to this line, then the bar is not new; return false
   return(false);
  }



Dessa maneira eu consegui colocar uma ordem porém fiquei com algumas dúvidas:

1-Como eu sei se a ordem está pendente ou em execução?

2-Se ela estiver pendente, como posso cancelar ela?

3-É possivel colocar 1 ordem de buy e outra de sell ao mesmo tempo usando uma conta Netting?


Obrigado!

Razão: