Exit arrows

 

I've tried to come up with a solution for this but not successful. I want the code to draw arrows on every closed trade so that I track all of my opened trades. Below is the code I've written but not working the way I want. Kindly help

void DrawExitArrow()
  {
         double lastclose_price = 0;
         datetime lastclose_time = 0;
         int arrow_code;
         int type = -1;
         for(int i = OrdersHistoryTotal()-1;i>=0;i--)
            {
                if(!OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))break;
                if(OrderSymbol() != Symbol())continue;
                if(OrderMagicNumber() != Magic) continue;
                if(OrderCloseTime() > lastclose_time)
                  {
                     lastclose_price = OrderClosePrice();
                     lastclose_time = OrderCloseTime();
                  }
            } 
         if(type == OP_BUY) 
           {
               arrow_code = SYMBOL_ARROWUP; 
           }
        else if(type == OP_SELL)   
           {
               arrow_code = SYMBOL_ARROWDOWN;
           } 
           
       if(lastclose_price > 0)
         {
              string arrow_name = "ExitArrow_" + IntegerToString(1);
              int arrow_index = ObjectCreate(0, arrow_name, OBJ_ARROW, 0, TimeCurrent(), lastclose_price);
              if(OrdersTotal() == 0)
                {
                     ObjectCreate(0,"exit", OBJ_ARROW,0,Time[0],lastclose_price);
                     ObjectSet("exit", OBJPROP_ARROWCODE,1);
                   
                }
         }   
  }
 
Ernest Akoyi:

I've tried to come up with a solution for this but not successful. I want the code to draw arrows on every closed trade so that I track all of my opened trades. Below is the code I've written but not working the way I want. Kindly help

Not sure how drawing arrows on closed trades will help you track the open trades but I have written an indicator like this before.

https://www.mql5.com/en/code/45988

Plot History
Plot History
  • www.mql5.com
Plot trade history levels on the chart for MT4
 
Chioma Obunadike #:

Not sure how drawing arrows on closed trades will help you track the open trades but I have written an indicator like this before.

https://www.mql5.com/en/code/45988

Thank you for this but I want the function to draw an arrow on the exit of every trade 

 
Ernest Akoyi #:

Thank you for this but I want the function to draw an arrow on the exit of every trade 

write function to detect when a position is closed, then add it to the indicator

Reason: