ObjectMove usage to update horizontal line with new value

 

Hi,

Hi ,

How to use ObjectMove function to update existing horizontal line created using ObjectCreate  with new closing price.

I  try using 

ObjectMove("Reversal_line",2,0,Reversal_line_val);

to update an existing line without success , should the 

parameter be 1 or 2 as Horizontal line has three parameters , 0 for window ,1 for datetime, 2 for price I thnik.

In fact I have try putting 0 or 1  in place of 2 also without success not sure what went wrong in the  ini init() block.

Thanks
 

Use

ObjectSet("Reversal_Line", OBJPROP_PRICE1, Reversal_line_val) ;

 
phy:

Use

ObjectSet("Reversal_Line", OBJPROP_PRICE1, Reversal_line_val) ;

Hi,

Thanks,

May I know what is the difference between objectset and objectmove usage on the existing object like OBJ_HLINE?

 

ObjectMove() changes only the time and price properties of an object.

ObjectSet() changes any single property of an object.

A horizontal line moves when you change its price, so you can use ObjectSet() more conveniently than ObjectMove().

 
phy:

ObjectMove() changes only the time and price properties of an object.

ObjectSet() changes any single property of an object.

A horizontal line moves when you change its price, so you can use ObjectSet() more conveniently than ObjectMove().

Hi,

Thanks,


Is it recommended to destroy an existing object created using objectCreate before recreate all over again the same object deleted earlier ? I am not sure will the processing time be significantly affected or consider this as a coding resource redundant task where objectmove and objectSet could actually update the existing object.





 

No need to delete.

You can if you like.

Processing time is minimal even for thousands of objects.

 
I used the following pattern with no problems
static string   TKcLow  = "Tokyo Channel Low";                         {
if(!ObjectMove(TKcLow, 0, TimeWellington, TKcPrcLow))
    if (!ObjectCreate( TKcLow, OBJ_HLINE, WINDOW_MAIN
                     , TimeWellington, TKcPrcLow))  Alert(
        "ObjectCreate(", TKcLow,",HLINE) [2] failed: ",GetLastError() );
    else if (!ObjectSet( TKcLow, OBJPROP_COLOR, Color.TKc ))    Alert(
        "ObjectSet(", TKcLow, ",Color) [3] failed: ", GetLastError() );}
 

Too much late But.. Somebody if Finding This Problem..

Just Use.

0 -> TimeCurrent()

It is Working..

ObjectMove("Reversal_line",2,TimeCurrent(),Reversal_line_val);

 
Object move works fine. From here:
void TLine( string name, datetime T0, double P0, datetime T1, double P1
          , color clr, bool ray=false ){                #define WINDOW_MAIN 0
    if (!Show.Objects)  return;
    /**/ if(ObjectMove( name, 0, T0, P0 ))      ObjectMove(name, 1, T1, P1);
    else if(!ObjectCreate( name, OBJ_TREND, WINDOW_MAIN, T0, P0, T1, P1 ))
        Alert("ObjectCreate(",name,",TREND) failed: ", GetLastError() );
    else if (!ObjectSet( name, OBJPROP_RAY, ray ))
        Alert("ObjectSet(", name, ",Ray) failed: ", GetLastError());
    if (!ObjectSet(name, OBJPROP_COLOR, clr )) // Allow color change
        Alert("ObjectSet(", name, ",Color) [2] failed: ", GetLastError());
    string  P0t = PriceToStr(P0);           if (MathAbs(P0 - P1) >= Point)
            P0t = StringConcatenate(P0t, " to ", PriceToStr(P1));
    if (!ObjectSetText(name, P0t, 10))
        Alert("ObjectSetText(",name,") [2] failed: ", GetLastError());
}
void HLine(string name, double P0, color clr){  //      #define WINDOW_MAIN 0
    if (!Show.Objects)  return;
    /**/ if (ObjectMove( name, 0, Time[0], P0 )){}
    else if(!ObjectCreate( name, OBJ_HLINE, WINDOW_MAIN, Time[0], P0 ))
        Alert("ObjectCreate(",name,",HLINE) failed: ", GetLastError() );
    if (!ObjectSet(name, OBJPROP_COLOR, clr )) // Allow color change
        Alert("ObjectSet(", name, ",Color) [1] failed: ", GetLastError() );
    if (!ObjectSetText(name, PriceToStr(P0), 10))
        Alert("ObjectSetText(",name,") [1] failed: ", GetLastError());
}
Reason: