Forex



Go Back   Forex Trading > Training > Metatrader > Metatrader 4 mql 4 - Development course > Questions
Forex Forum Register More recent Blogs Calendar Advertising Others Help






Register
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. It’s 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.
See more

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 08-02-2006, 12:26 AM
Member
 
Join Date: Dec 2005
Posts: 31
billworld2 is on a distinguished road
Precision problem with OBJPROP_PRICE

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); 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #2 (permalink)  
Old 08-02-2006, 01:05 PM
intelligent_14's Avatar
Junior Member
 
Join Date: Mar 2006
Location: Tehran/Iran
Posts: 24
intelligent_14 is on a distinguished road
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

Good Luck
__________________
there wil be nothig for a person exept his efforts (Emam Ali Alayhesalam)
M.A.Gh
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #3 (permalink)  
Old 08-02-2006, 03:17 PM
Kalenzo's Avatar
Senior Member
 
Join Date: Dec 2005
Location: Bydgoszcz - Poland
Posts: 723
Kalenzo is on a distinguished road
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

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/
........................................
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #4 (permalink)  
Old 08-03-2006, 12:22 AM
Member
 
Join Date: Dec 2005
Posts: 31
billworld2 is on a distinguished road
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

Good Luck
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #5 (permalink)  
Old 08-03-2006, 12:27 AM
Member
 
Join Date: Dec 2005
Posts: 31
billworld2 is on a distinguished road
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #6 (permalink)  
Old 08-03-2006, 06:20 AM
Kalenzo's Avatar
Senior Member
 
Join Date: Dec 2005
Location: Bydgoszcz - Poland
Posts: 723
Kalenzo is on a distinguished road
Quote:
Originally Posted by billworld2
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); 
It should be like that:


normprice=NormalizeDouble(ObjectGet(ObjectName(i), OBJPROP_PRICE1),4);
__________________
You need proffesional mql coder? Contact me! I will help you!
........................................
http://www.fxservice.eu/
........................................
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #7 (permalink)  
Old 08-03-2006, 04:03 PM
Member
 
Join Date: Dec 2005
Posts: 31
billworld2 is on a distinguished road
Quote:
Originally Posted by billworld2
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);
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with .ex4................. EFX General Discussion 4 10-21-2006 08:23 AM
iTime problem danielpasono Expert Advisors - Metatrader 4 3 07-06-2006 05:29 AM
My First EA problem demag Questions 4 02-10-2006 09:18 AM
I've a Problem here hellkas Metatrader 4 6 11-04-2005 01:30 AM


All times are GMT. The time now is 01:51 AM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.