Update horizontal line description while moving in MQL5

 

Hello everyone

I created a horizontal line with the button.

This H line can be selected and moved.

I want the price of the horizontal line to be updated on this line by moving this line by the user.

This is done when I release the line. But I want the text of the line to change continuously when the line is moved up or down by the user.


double LinePrice = NormalizeDouble(ObjectGetDouble(0, "Hline",OBJPROP_PRICE),5);

ObjectSetString(0,  "Hline" ,OBJPROP_TEXT,"          price changing to: " + LinePrice );

 
monfared92: I want the price of the horizontal line to be updated on this line by moving this line by the user.

The question makes no sense. User moves the line, the price updates.

 
Hello to all decent people of the Earth!
<1>
And the interest and intentions shown are absolutely clear and reasonable
<2>
I'd use for this the one of 14 main MQL5 functions => OnChartEvent()

<3>
Code Sample Variant   

= Begin Of Sample ==============================================================

..

// PART 1 //////////////////////////////////////////////////////////////////////

#define PLAIN void                                                        //<  >

#define LOGIC bool                                                        //<  >

                                                                          //<  >

#define INT_S  int                                                        //<  >

#define INT_U uint                                                        //<  >

                                                                          //<  >

LOGIC   Y = true                                                        ; //<  >

LOGIC   N = false                                                       ; //<  >

                                                                          //<  >

#define X  const long &L , const double &D , const string &S              //<  >

// PART 1 //////////////////////////////////////////////////////////////////////

..

// PART 2 //////////////////////////////////////////////////////////////////////

PLAIN  OnChartEvent ( const int I , X ) { AIS_CORE_RUN ( I )          ; } //<  >

// PART 2 //////////////////////////////////////////////////////////////////////

..

// PART 3 //////////////////////////////////////////////////////////////////////

PLAIN  AIS_CORE_RUN          ( INT_S EVENT_ID = -1 ) /* -1 UNDEFINED */ { //<  >

                                                                          //<  >

       AIS_CONTROL_RUN       (       EVENT_ID      )                    ; //<  >

                                                                          //<  >

       AIS_SPECIAL_RUN       ()                                         ; //<  >

                                                                        } //<  >

// PART 3 //////////////////////////////////////////////////////////////////////

..

// PART 4 //////////////////////////////////////////////////////////////////////

PLAIN  AIS_CONTROL_RUN       ( INT_S EVENT_ID )                         { //<  >

                                                                          //<  >

       FLAGS_SET             (       EVENT_ID )                         ; //<  >

                                                                          //<  >

// .. <other code of this function>                                       //<  >

                                                                        } //<  >

// PART 4 //////////////////////////////////////////////////////////////////////

..

// PART 5 //////////////////////////////////////////////////////////////////////

PLAIN  FLAGS_SET             ( INT_S EVENT_ID )                         { //<  >

                                                                          //<  >

       FLAG_OBJECT_DRAG    = ( EVENT_ID==CHARTEVENT_OBJECT_DRAG ? Y:N  ); //<  >

                                                                          //<  >

// .. <other code of this function>                                       //<  >

                                                                        } //<  >

// PART 5 //////////////////////////////////////////////////////////////////////

..

// and so on

//<Including further instant processing of the FLAG_OBJECT_DRAG state>

//<I mean that maybe is needed to detect dragged object concretely or maybe not>

//<And decide whether to change other objects in response to this event or not>

..

= End Of Sample ================================================================

Best regards

AIS Airat Safin

2022-07-18 04:50

 
Response pause is prolonging
Then => more explanations for more clarity


<1> In most cases I stop to read code when I see some certain constructions
=1= NormalizeDouble() in functions other than sending orders
=2= if ( LOT_SIZE < MIN_LOT ) LOT_SIZE = MIN_LOT ;
=3= and so on


<2> About =if ( LOT_SIZE < MIN_LOT ) LOT_SIZE = MIN_LOT ;=


<3> About =NormalizeDouble()=

=3/1= TRUTH
==============================================================
NormalizeDouble() was intended for correct work with servers
<and never for nothing else>
==============================================================

=3/2= PROOF
==============================================================
==============================================================

=3/3= FACTS
==============================================================
Most cases of using of NormalizeDouble() at least are useless
Many => harmful like this => mql5.com/ru/forum/160683/page1049
==============================================================

 
William Roeder #:

The question makes no sense. User moves the line, the price updates.

I solved it.

I just forgot about this setting

ChartSetInteger(0,CHART_EVENT_MOUSE_MOVE,true);
Reason: