ObjectGetValueByShift

 

Hello everyone. 

I am trying to code buy order execution when the Bid reach above a price that ObjectGetValueByShift will get 

the object is a Trendline

double Price = ObjectGetValueByShift("Trendline",0);
   

   if( Bid >= Price)
        {
         int Ticket_Number1= OrderSend(Symbol(),OP_BUY,0.01,Ask,30,0,0,"Trade",0,0,clrAqua);

        }

the problem is orders keep executing although the bid is below the price, and I printed the price and it was correct and way above the bid and ask


Please advise


Thanks for the help

Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Order Properties
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Order Properties - Trade Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Michael: I am trying to code buy order execution when the Bid reach above a price that ObjectGetValueByShift will get the object is a Trendline.the problem is orders keep executing although the bid is below the price, and I printed the price and it was correct and way above the bid and ask. Please advise

You have not provided sufficient information, nor code, to be able to identify the problem.

However, please note that ObjectGetValueByShift will not work in the Strategy Tester during optimisations, and you will have to use other options.

Forum on trading, automated trading systems and testing trading strategies

How optimize objectget() / ObjectGetValueByShift() function in EA

Fernando Carreiro, 2022.04.19 11:29

Graphical objects are not used during optimisations, so instead use the equivalent math to calculate the value. This will also be much faster than using ObjectGetValueByShift().

For example, instead of using a trend-line object, just use the math for a line "y = m * x + c" to calculate the values.