drawing a line and simple math...

 

have a stupid question. Why this is working:

double price = 0.2;
ObjectCreate("line",OBJ_HLINE,0,0, price);

but something like that is not:

double price = 2/10;
ObjectCreate("line",OBJ_HLINE,0,0, price);

or

double tmp = 2;
double price = tmp / 10;
ObjectCreate("line",OBJ_HLINE,0,0, price);

? Is there a special trick for dividing two numbers? Sorry for that dumb question, just learning... :) Thanks

 

Yes, it's called typecasting. 2 is an integer. 10 is an integer. So 2/10 is pushed into an integer value(0, i guess) - and then saved in a double variable (as 0.0). Try using 2 / 10.0 or 2.0/10 I can't test it at the moment but also try double (double)2/10;

If in fact the line didn't appear at all (check Ctrl+B), then it's a different problem. As far as I remember, every object needs Price1, Time1, Price2 and Time2

I found out the hard (and long) way too

 
thanks guys, you are awesome!
Reason: