Moving a line

 

Can anyone help with the following. I want to create a horizontal line at the bid price, then allow the line to be moved and stay at the new price.

The following draws the line and allows moving, but when I changed time frames it moves the line back to bid.

Is there a way to stop it being moving back to bid when time frames are switched.


// H Line
   
   
   if(ObjectFind(0,"HLine")==-1)
   {
   
   double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
   
   ObjectCreate(0,"HLine",OBJ_HLINE,0,0,0,0,0); 
   ObjectSetDouble(0,"HLine",OBJPROP_PRICE,bid);
   ObjectSetInteger(0,"HLine",OBJPROP_STYLE,STYLE_DOT);
   ObjectSetInteger(0,"HLine",OBJPROP_BACK,true);
   ObjectSetInteger(0,"HLine",OBJPROP_SELECTABLE,true);
   ObjectSetInteger(0,"HLine",OBJPROP_COLOR,LineColour);
   ObjectSetInteger(0,"HLine",OBJPROP_TIMEFRAMES,OBJ_PERIOD_M12|OBJ_PERIOD_M15|OBJ_PERIOD_M20|OBJ_PERIOD_M30);
   
   double read_value;
   
   if (ObjectGetDouble(ChartID(),"HLine",OBJPROP_PRICE,0,read_value)) bid = read_value;
   
   ObjectSetDouble(0,"HLine",OBJPROP_PRICE,bid);
   
   }
 

Found a solution here,


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

PriceAlert
PriceAlert
  • www.mql5.com
The indicator displays the horizontal line that sets the signal actuating level.
 
Comments that do not relate to this topic, have been moved to "Off Topic Posts".
Reason: