Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.
From the list below, select the forum that you want to visit and register to post, as many times you want. Its absolutely free. Click here for registering on Forex-TSD.
Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
Elite Section
Get access to private discussions, specialized support, indicators and trading systems reported every week.
Advanced Elite Section
For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
I'm trying to adjust the precision of what I get back on OBJPROP_PRICE within ObjectGet. But, it's not working. The code below does not adjust the precision to 4 as expected.
Am I doing something wrong?
PHP Code:
string name1;
double normprice;
for(int i=0;i<ObjectsTotal();i++)
{
name1=ObjectName(i);
normprice=ObjectGet(ObjectName(i),NormalizeDouble(OBJPROP_PRICE1,4));
Print("Object #"+i+" name is "+"\""+name1+"\" and price is "+normprice);
string name1;
double normprice;
for(int i=0;i<ObjectsTotal();i++)
{
name1=ObjectName(i);
normprice=NormalizeDouble(ObjectGet(ObjectName(i),OBJPROP_PRICE1),4);
Print("Object #"+i+" name is "+"\""+name1+"\" and price is "+normprice);
you can also replace "4" in Second NormalizeDouble function parameter with Digits, because in each currency pair, your digits are different and you sometimes you only want first 2 digits not 4
Good Luck
__________________
there wil be nothig for a person exept his efforts (Emam Ali Alayhesalam)
M.A.Gh
string name1;
double normprice;
for(int i=0;i<ObjectsTotal();i++)
{
name1=ObjectName(i);
normprice=NormalizeDouble(ObjectGet(ObjectName(i),OBJPROP_PRICE1),4);
Print("Object #"+i+" name is "+"\""+name1+"\" and price is "+normprice);
you can also replace "4" in Second NormalizeDouble function parameter with Digits, because in each currency pair, your digits are different and you sometimes you only want first 2 digits not 4
Good Luck
U can use MarketInfo(Symbol(),MODE_DIGITS) to check what precision do u have on your currency and use it as a param to NormalizeDouble function.
If u will get something like : 1.2345000000 then just use DoubleToStr and then StringSubstr to cut those nulls.
__________________
You need proffesional mql coder? Contact me! I will help you!
........................................ http://www.fxservice.eu/
........................................
I see where you moved the right paren over. But, that still doesn't work. I'm getting the same number of digits (all of them). Likewise, changing the param to Digits yields the same result.
Quote:
Originally Posted by intelligent_14
Change your codes as below:
PHP Code:
string name1;
double normprice;
for(int i=0;i<ObjectsTotal();i++)
{
name1=ObjectName(i);
normprice=NormalizeDouble(ObjectGet(ObjectName(i),OBJPROP_PRICE1),4);
Print("Object #"+i+" name is "+"\""+name1+"\" and price is "+normprice);
you can also replace "4" in Second NormalizeDouble function parameter with Digits, because in each currency pair, your digits are different and you sometimes you only want first 2 digits not 4
Are you saying that one needs to do this to adjust the precision rather than realy on the far-less verbose method of using either a precision number or Digits as the precision parameter within NormalizeDouble()?
I'm not getting the precision control within NormalizeDouble() to work and was hoping to not go the route of using string routines to trim the digits.
Quote:
Originally Posted by Kalenzo
U can use MarketInfo(Symbol(),MODE_DIGITS) to check what precision do u have on your currency and use it as a param to NormalizeDouble function.
If u will get something like : 1.2345000000 then just use DoubleToStr and then StringSubstr to cut those nulls.
Last edited by billworld2; 08-03-2006 at 01:36 AM.
I'm trying to adjust the precision of what I get back on OBJPROP_PRICE within ObjectGet. But, it's not working. The code below does not adjust the precision to 4 as expected.
Am I doing something wrong?
PHP Code:
string name1;
double normprice;
for(int i=0;i<ObjectsTotal();i++)
{
name1=ObjectName(i);
normprice=ObjectGet(ObjectName(i),NormalizeDouble(OBJPROP_PRICE1,4));
Print("Object #"+i+" name is "+"\""+name1+"\" and price is "+normprice);
__________________
You need proffesional mql coder? Contact me! I will help you!
........................................ http://www.fxservice.eu/
........................................
I see where you moved the right paren over. But, that still doesn't work. I'm getting the same number of digits (all of them). Likewise, changing the param to Digits yields the same result.
Figured it out. In addition to fixing the placement of NormalizeDouble(), the the Print() line was off. Instead of:
Print("Object #"+i+" name is "+"\""+name1+"\" and price is "+normprice);
it needs to be:
Print("Object #",i," name is ","\"",name1,"\" and price is ",normprice);