Trailing Stop OBJ_HLINE

 
if(OrdersTotalMagicbuy(Magicbuy)>=1)
{
ObjectCreate("HLine", OBJ_HLINE,0,Time[0],OrderOpenPrice()-50*Point);
}
if(OrdersTotalMagicbuy(Magicbuy)>=2)
{
ObjectSet ("HLine", OBJ_HLINE,High[0]-50*Point);
}

Hi, I'd like to create a trailingstop function, I've created these lines of code that work, only if the price goes down the line keeps changing, how can I stop it if the price goes back?

 
signal.it: how can I stop it if the price goes back?
  1. When in doubt think? Test the current value vs. new value.

  2. ObjectSet ("HLine", OBJ_HLINE,High[0]-50*Point);
    No such function in MT5. Why did you post your MT4 question in the Root / MT5 Systems section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

  3. OBJ_HLINE is not a property. Perhaps you should read the manual.
              Object Properties - Objects Constants - Standard Constants, Enumerations and Structures - MQL4 Reference
Reason: