Can anybody explain this abnormal circumstance ?

 

I have coded the following function


      void Drawframe5 (double price)
            {
             int levelA, levelB;
             static int LastA=0, LastB=0;
             
             
             levelA=Rup5(MathRound(price));
             levelB=Rdown5(MathRound(price));
             
             if (ObjectFind("levelA")==-1)   {  ObjectCreate("levelA",OBJ_HLINE,0,30,levelA); return; }
             if (LastA==0)  { LastA=levelA;  return;  }
             if (LastA!=levelA)  {  ObjectMove("levelA",0,30,levelA);   LastA=levelA;  return;  }
             
             if (ObjectFind("levelB")==-1)   {  ObjectCreate("levelB",OBJ_HLINE,0,30,levelB); return; }
             if (LastB==0)  { LastB=levelB;  return;  }
             if (LastB!=levelB)  {  ObjectMove("levelB",0,30,levelB);   LastB=levelB;  return;  }
             
             }

And I have called the above function by

Drawframe5(Bid);

And the output is shown as PrintScreen file attached.

The strange thing is that when I put the mouse cursor on the line named level B on the chart, it show of uneven double value (1594.99)

instead of the even double value as shown at the price tick (1595.00)

why is there this differrence ?

Remark that I declare "levelB" variable as "int type"

 
 
sonthanhthuytu:


The strange thing is that when I put the mouse cursor on the line named level B on the chart, it show of uneven double value (1594.99)

instead of the even double value as shown at the price tick (1595.00)

why is there this differrence ?

The value you see when you put your cursor close to the line is just an indicative value . . . zoom in or out and do the same thing again, the value will change . . . if you want to see the actual value of the line first select it then right click on it and click Horizontal line properties then click Parameters
 
Or what I do in my code (TLine/HLine) is place the actual value using ObjectSetText
 
Thank you.
Reason: