I want get OBJPROP_ANGLE from OBJ_TRENDBYANGLE

 

hi Dear

@Alain Verleyen

@whroeder1

I want get OBJPROP_ANGLE from OBJ_TRENDBYANGLE with this code in open any candel but  OBJPROP_ANGLE give me 0.0 value!?

please help me

void OnTick()
  {
//---
   
   ObjectDelete(0,"Trendbyangle");
   ObjectCreate("Trendbyangle",OBJ_TRENDBYANGLE,0,Time[5],Close[5],Time[1],Close[1]);
   
   if(iVolume(Symbol(),timeframe,0)<=1)
     {
      Comment(ObjectGet("Trendbyangle",OBJPROP_ANGLE));
     }

  }
Alain Verleyen
Alain Verleyen
  • 2021.08.07
  • www.mql5.com
Trader's profile
 
  1. Saeid Reza Bahman Abadi:   OBJPROP_ANGLE give me 0.0 value!?

       ObjectCreate("Trendbyangle",OBJ_TRENDBYANGLE,0,Time[5],Close[5],Time[1],Close[1]);

    All you've done is post the command to create the object. You never set the angle! Then, after you return, the object is created, and you can read the angle.


  2.    if(iVolume(Symbol(),timeframe,0)<=1)
         {

    For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart), volume is unreliable (miss ticks), Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.
              New candle - MQL4 programming forum #3 (2014.04.04)

    I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.
              Running EA once at the start of each bar - MQL4 programming forum (2011.05.06)

 

i want read with objectget

this is my problem

ObjectGet("Trendbyangle",OBJPROP_ANGLE)

but when i add this code it,s return 0.0

   ObjectDelete(0,"Trendbyangle");
 
Saeid Reza Bahman Abadi #: but when i add this code it,s return 0.0

You never set an angle. Only the first coordinate was used in the create.

Perhaps you should read the manual. Especially the example. OBJ_TRENDBYANGLE - Object Types - Objects Constants - Constants, Enumerations and Structures - MQL4 Reference
   How To Ask Questions The Smart Way. (2004)
      How To Interpret Answers.
         RTFM and STFW: How To Tell You've Seriously Screwed Up.