Bid/Ask price is too long

 

Hello I have a little problem. I am trying to make an indicator which will show Bid/Ask price but it seems that for some symbols, they are just too long.


That's my code:

DoubleToStr(MarketInfo(Symbol(), MODE_ASK),Digits);

And same happens to iOpen/iHigh/iLow/iClose they are inaccurate too.

 
Show the code that actually prints the value.
 
Keith Watford:
Show the code that actually prints the value.


//----------- Ask Price
   if(MarketInfo(Symbol(), MODE_ASK) > pasks)          
     {                                                             
        AskColor = BullColor; 
     }                                                                   
   if(MarketInfo(Symbol(), MODE_ASK) < pasks)                
     {                                                                
        AskColor = BearColor; 
     } 
   pasks = DoubleToStr(MarketInfo(Symbol(), MODE_ASK),Digits);
   SetObjLabel    (del + "obj10", AskColor,  97,   2,  95,  33, FALSE, 1);
   if(StringLen(pbids) == 8)
   {
   SetLabel2 (del + "obj101", pasks, "Arial", White, 50, 18, "\n", 15, 1, ANCHOR_CENTER);
   }
   else{
   SetLabel2 (del + "obj101", pasks, "Arial", White, 50, 18, "\n", 17, 1, ANCHOR_CENTER);
   }
That's the code. As I said, it isn't wrong for all pairs and not all the time. The picture in first post shows USDCHF and sometimes it's normal and sometimes too long
 
 if(MarketInfo(Symbol(), MODE_ASK) > pasks)  

Here you are comparing a double value to your variable pasks.

pasks = DoubleToStr(MarketInfo(Symbol(), MODE_ASK),Digits);

Here you are assigning a string to  your variable pasks.

What is pasks? is it a double or is it a string?

It can't be both!

 
Keith Watford:

Here you are comparing a double value to your variable pasks.

Here you are assigning a string to  your variable pasks.

What is pasks? is it a double or is it a string?

It can't be both!

Oh thank you I didn't noticed, it was double (0.0) so I changed it to string and it fixed. Thanks again

 
mr-roma:

Oh thank you I didn't noticed, it was double (0.0) so I changed it to string and it fixed. Thanks again

Hopefully you have also changed

if(MarketInfo(Symbol(), MODE_ASK) > pasks)  

so that you are not comparing a double to a string.

 
Keith Watford:

Hopefully you have also changed

so that you are not comparing a double to a string.

No, I only changed it for label.

   string pbid = DoubleToStr(MarketInfo(Symbol(), MODE_BID),MarketInfo(Symbol(), MODE_DIGITS));
   string pask = DoubleToStr(MarketInfo(Symbol(), MODE_ASK),MarketInfo(Symbol(), MODE_DIGITS));
//----------- Bid Price
   if(MarketInfo(Symbol(), MODE_BID) > pbids)          
     {                                                             
        BidColor = BullColor; 
     }                                                                   
   if(MarketInfo(Symbol(), MODE_BID) < pbids)                
     {                                                                
        BidColor = BearColor; 
     }
   
   SetObjLabel (del + "obj9", BidColor,   236,   2,  95,  33, FALSE, 1);
   if(StringLen(pbids) == 8)
   {
   SetLabel2 (del + "obj91", pbid, "Arial", White, 190, 18, "\n", 15, 1, ANCHOR_CENTER);
   }
   else {
   SetLabel2 (del + "obj91", pbid, "Arial", White, 190, 18, "\n", 17, 1, ANCHOR_CENTER);
   }

Thanks for your reply.

Reason: