Horizontal line determine before and after price

 

Hello everybody,

Can somebody point me in the right direction with my problem?

I already have a Horizontal line on chart, and I will move it manually with drag and drop.

I need to find the starting price of the line (first price position). I tried all the properties that i could find.

OBJECT_PRICE and OBJECT_PRICE1 are equal to last position price.

Here is my code:

void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
{
   if(id==CHARTEVENT_OBJECT_DRAG)
     {
      if (sparam == "test"){

            if (ObjectFind(sparam) != -1){
               double p1 =  ObjectGetDouble(0,sparam,OBJPROP_PRICE,0);
               double p2 =  ObjectGetDouble(0,sparam,OBJPROP_PRICE1,0);
               double p4 =  ObjectGetDouble(0,sparam,OBJPROP_DEVIATION,0);
               double p3 =  ObjectGetDouble(0,sparam,OBJPROP_PRICE2,0);
            }
     }
}

Any ideas?

Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types
Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types
  • www.mql5.com
Object Types - Objects Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
no luck till now, I haven't found a solution, if I found one, I will post it here
 
YellowstoneBridge:

Hello everybody,

Can somebody point me in the right direction with my problem?

I already have a Horizontal line on chart, and I will move it manually with drag and drop.

I need to find the starting price of the line (first price position). I tried all the properties that i could find.

OBJECT_PRICE and OBJECT_PRICE1 are equal to last position price.

Here is my code:

Any ideas?

at any time the horizontal line object only has a single price, so you will only ever get the current price.

Simply store the starting price from when you created the line or moved it before then you will have before and after

 
Paul Anscombe:

at any time the horizontal line object only has a single price, so you will only ever get the current price.

Simply store the starting price from when you created the line or moved it before then you will have before and after

Yellowstone could use the price as a string in the object description. Obviously this would have to be done when the object is created.

Then when the line is moved, get the object description, convert it back to a double and set the object description to the new price.

 
Paul Anscombe:

at any time the horizontal line object only has a single price, so you will only ever get the current price.

Simply store the starting price from when you created the line or moved it before then you will have before and after

thank you, for the clarification

I thought that I could develop this without additional variables

I will try your solution thank you

 
Keith Watford:

Yellowstone could use the price as a string in the object description. Obviously this would have to be done when the object is created.

Then when the line is moved, get the object description, convert it back to a double and set the object description to the new price.

this is a nice workaround, I like this, but I'll use a separate variable for achieving this functionality

thank you