How to get number with decimal place [need help]

Back to topics list To post a new topic, please log in or register
avatar
5
forextime8 2015.02.11 10:04
 

i am creating an one click trading

the question is .... how to get number with decimal place  ?

for point, no decimal place => okay

   TakeProfitPoint = (int)StringToInteger(ObjectGetString(0,"ButtonEditTpPoint",OBJPROP_TEXT));
   ChartRedraw();
   Print("ButtonEditTpPoint : ", DoubleToString(TakeProfitPoint,0));

 for sl / tp target, 

the result come out with decimal place, but can't get those decimal place for result.

let say i keyin 1.12345, result out with 1.00000

   TakeProfitDecimal = (int)StringToInteger(ObjectGetString(0,"ButtonEditTpDecimal",OBJPROP_TEXT));
   ChartRedraw();
   Print("ButtonEditTpDecimal : ", DoubleToString(TakeProfitDecimal,5));

 

so, what should i add or i miss something there ? 

 

avatar
2017
gooly 2015.02.11 10:08 #
 

I don't understand what you want!

In case you have e.g. 1.23456 do you want 1, or 1.23456 or 23456?

Your code converts the double 1.23456 to an integer so you get 1.

avatar
5
forextime8 2015.02.11 10:12 #
 
gooly:

I don't understand what you want!

In case you have e.g. 1.23456 do you want 1, or 1.23456 or 23456?

Your code converts the double 1.23456 to an integer so you get 1.

the whole number which i keyin, 

[ 1.12345 ] is what i want.

 

avatar
5
forextime8 2015.02.11 10:14 #
 
gooly:

I don't understand what you want!

In case you have e.g. 1.23456 do you want 1, or 1.23456 or 23456?

Your code converts the double 1.23456 to an integer so you get 1.

StringToDouble

is what i need ? 

avatar
735
honest_knave 2015.02.11 10:49 #
 

If I understand your request: you have an edit box where you manually enter a price. You then want to use this price as an order TP?

If so, this should do what you ask:

// TakeProfitPoint = (int)StringToInteger(ObjectGetString(0,"ButtonEditTpPoint",OBJPROP_TEXT));
TakeProfitPoint = NormalizeDouble((double)ObjectGetString(0,"ButtonEditTpPoint",OBJPROP_TEXT),Digits));

Note: make sure that TakeProfitPoint is declared as a double.

avatar
5
forextime8 2015.02.11 17:37 #
 
honest_knave:

If I understand your request: you have an edit box where you manually enter a price. You then want to use this price as an order TP?

If so, this should do what you ask:

Note: make sure that TakeProfitPoint is declared as a double.

thanks, done for this part.

 i created edit box tp / sl for pips and for decimal price.

 

Back to topics list  

To add comments, please log in or register