Horizontal line determine before and after price

YellowstoneBridge
27
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:

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
YellowstoneBridge
27
YellowstoneBridge  
no luck till now, I haven't found a solution, if I found one, I will post it here
Paul Anscombe
5684
Paul Anscombe  
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

Keith Watford
Moderator
28892
Keith Watford  
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.

YellowstoneBridge
27
YellowstoneBridge  
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

YellowstoneBridge
27
YellowstoneBridge  
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