How to mark with arrow, all Open Orders on a chart, at the open of the bar and not at OrderOpenPrice?

 

I'm trying to show on a chart, an arrow for each open trade. However, I want it to appear at the open of the bar it occurred, and not at the actual OrderOpenPrice.

I have a script (attached) that puts an arrow and price box at the OrderOpenTime (great), but puts it at the OrderOpenPrice. I want it to be showing at the open of the bar.

I can't work out how to get the Open() value for a bar from the OrderOpenTime. Any ideas?

David

  int i, LiveTotal = OrdersTotal();
  
  for(i=0; i<LiveTotal; i++)
  
    {
     if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
       {
        ObjectCreate("e" + i,  OBJ_ARROW, 0, OrderOpenTime(), OrderOpenPrice()); 
        ObjectCreate("ep" + i, OBJ_ARROW, 0, OrderOpenTime(), OrderOpenPrice());
         
        if (OrderType() == OP_BUY)
         {
          ObjectSet("e" + i,  OBJPROP_ARROWCODE, SYMBOL_ARROWUP);
          ObjectSet("e" + i,  OBJPROP_COLOR, BuyColor);
          ObjectSet("ep" + i, OBJPROP_ARROWCODE, SYMBOL_LEFTPRICE);
          ObjectSet("ep" + i, OBJPROP_COLOR, BuyColor);
         }
      
     else if (OrderType() == OP_SELL)
         {
          ObjectSet("e" + i,  OBJPROP_ARROWCODE, SYMBOL_ARROWDOWN);
          ObjectSet("e" + i,  OBJPROP_COLOR, SellColor);
          ObjectSet("ep" + i, OBJPROP_ARROWCODE, SYMBOL_RIGHTPRICE);
          ObjectSet("ep" + i, OBJPROP_COLOR, SellColor);
         }
       }
     
     else
      {
       Print("Access to orders failed with error (",GetLastError(),")");
       break;
      }
      // some work with orders
    }

 
davidb_012:

I can't work out how to get the Open() value for a bar from the OrderOpenTime. Any ideas?

David

Use iBarShift() and Open[] or iOpen()
 
RaptorUK:
Use iBarShift() and Open[] or iOpen()

Thanks RaptorUK, that helped. Got it sorted with iBarShift as below.

        int shift = iBarShift(0,0,OrderOpenTime());       
        
        //ObjectCreate("e" + i,  OBJ_ARROW, 0, OrderOpenTime(), OrderOpenPrice());  // Original
        //ObjectCreate("ep" + i, OBJ_ARROW, 0, OrderOpenTime(), OrderOpenPrice());  // Original
        
        ObjectCreate("e" + i,  OBJ_ARROW, 0, Time[shift], Open[shift]);           
        ObjectCreate("ep" + i, OBJ_ARROW, 0, Time[shift], Open[shift]);
 
Check your code for the iBarShift call . . . the first 0 should be NULL to be correct to the documentation.
Reason: