Vertical Lines

 

How a expert put vertical line in chart, every time to open order.

I tried this code, but it works only for the first order, not work in the next orders.

  //---------------------
  if(ScalpSignal()==1)//buy
  {
  ObjectCreate("Buy_Signal",OBJ_HLINE,0,TimeCurrent(),Ask);
  ObjectSet("Buy_Signal",OBJPROP_STYLE, STYLE_DASH);
  ObjectSet("Buy_Signal",OBJPROP_COLOR,MediumSpringGreen);
  }
  //---------------------

Please help me!!

 
pannek:

How a expert put vertical line in chart, every time to open order.

I tried this code, but it works only for the first order, not work in the next orders.

Please help me!!

If you call the same function, with the same object name, it cannot work as there can only be one object of a given name. You will have to add something to each new line name to make them unique.
 

Thanks, you help me.

But I have one more problem, if open limit orders and modify limit order, the line mοdify with order.

I want the arrows not modify.

 
pannek:

Thanks, you help me.

But I have one more problem, if open limit orders and modify limit order, the line mοdify with order.

I want the arrows not modify.

What arrows? You haven't mentioned arrows before.
 
I mean lines, vertical lines
 
pannek:

How a expert put vertical line in chart, every time to open order.

I tried this code, but it works only for the first order, not work in the next orders.

  ObjectCreate("Buy_Signal",OBJ_HLINE,0,TimeCurrent(),Ask);

Of course it doesn't.

  1. You're creating a HORIZONTAL line not a vertical one.
  2. Once it is created, the subsequent ObjectCreate calls fail
  3. Always test return codes so you find out WHY
    if (!ObjectCreate(..) Alert("ObjectCreate failed: ", GetLastError());

Either you must use unique names or move the line

int ticket = OrderSend(..)
if (ticket < 0) Alert("OrderSend failed: ", GetLastError());
else Vline("Buy_Signal"+ticket, TimeCurrent(), MediumSpringGreen);
void HLine(string name, double P0, color clr){  //      #define WINDOW_MAIN 0
    if (!Show.Objects)  return;
    /**/ if (ObjectMove( name, 0, Time[0], P0 )){}
    else if(!ObjectCreate( name, OBJ_HLINE, WINDOW_MAIN, Time[0], P0 ))
        Alert("ObjectCreate(",name,",HLINE) failed: ", GetLastError() );
    if (!ObjectSet(name, OBJPROP_COLOR, clr )) // Allow color change
        Alert("ObjectSet(", name, ",Color) [1] failed: ", GetLastError() );
    if (!ObjectSetText(name, PriceToStr(P0), 10))
        Alert("ObjectSetText(",name,") [1] failed: ", GetLastError());
}
void VLine(string name, datetime T0, color clr){    //  #define WINDOW_MAIN 0
    if (!Show.Objects)  return;
    if      (ObjectMove( name, 0, T0, 0 )){}
    else if (!ObjectCreate( name, OBJ_VLINE, WINDOW_MAIN, T0, 0 ))
        Alert("ObjectCreate(",name,",VLINE) failed: ", GetLastError() );
    if (!ObjectSet(name, OBJPROP_COLOR, clr )) // Allow color change
        Alert("ObjectSet(", name, ",Color) [1] failed: ", GetLastError() );
    if (!ObjectSetText(name, TimeToStr(T0, TIME_MINUTES), 10))
        Alert("ObjectSetText(",name,") [4] failed: ", GetLastError());
}
See my code.
Reason: