Forex



Go Back   Forex Trading > Programming > MetaTrader
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 12-30-2008, 04:10 PM
Senior Member
 
Join Date: Mar 2006
Posts: 124
ZTrader is on a distinguished road
Seriously pesky bug!! :(

I've been programming a long time and this is one of the most confusing bugs I've come across. It almost seems like a flaw in MT4 but I know from experience that it's most likely a mistake on my part. Try as I will, though, I can't for the life of me figure out what's wrong.

The offending indicator code is attached - BEWARE THAT IT WILL CRASH MT4!!

I've isolated the problem to line 107:
Code:
      for (g = 0; g < dSmoothDomPeriod[k] / 2; g ++)
         {I3 += Q3[g];}
It seems that MT4 gakks when I try to use the expression 'dSmoothDomPeriod[k] / 2' as a limit for the for() statement.

I tried putting the value into a separate variable of int type:
Code:
      int temp = dSmoothDomPeriod[k] / 2;
      for (g = 0; g < temp; g ++)
         {I3 += Q3[g];}
But it didn't help.

I tried using the MathFloor() function to explicitly truncate the expression:
Code:
      int temp = MathFloor(dSmoothDomPeriod[k] / 2);
      for (g = 0; g < temp; g ++)
         {I3 += Q3[g];}
Again, no dice.

I tried explicitly casting the value into an int type (rather clumsy):
Code:
      int temp = StrToInt(DoubleToStr(MathFloor(dSmoothDomPeriod[k] / 2), 0));
      for (g = 0; g < temp; g ++)
         {I3 += Q3[g];}
Strike three.

If I replace the expression with a constant or with a variable loaded by a constant, everything is fine:
Code:
      for (g = 0; g < 50; g ++)
         {I3 += Q3[g];}
-->this works fine...

      int temp = 50;
      for (g = 0; g < temp; g ++)
         {I3 += Q3[g];}
-->this also works fine...
But of course that's not what I need...

I even tried changing to a while() statement, using all the same variations as above:
Code:
      int g = 0;
      while (g < dSmoothDomPeriod[k] / 2)
         {I3 += Q3[g];
         g ++;}
Still no go.

Please take a look at the code and see if you can figure out what I need to get it to iterate using the results of the required expression without locking up the host application. This code is for a Hilbert Signal To Noise Ratio indicator, and if I can get it to work, it should be pretty cool... Seems like a very big if right now...

Z--
Attached Files
File Type: mq4 Hilbert SNR - BUGG.mq4 (4.0 KB, 19 views)
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 12-30-2008, 08:10 PM
Senior Member
 
Join Date: Feb 2006
Posts: 587
Michel is on a distinguished road
several small bugs; the main one concerns indeed the line:
PHP Code:
      for (0dSmoothDomPeriod[k] / 2++)
         
I3 += Q3[g]; 
which should be (I think):
PHP Code:
for (0dSmoothDomPeriod[k] / && k+Bars++) I3 += Q3[k+g]; 
Attached is the fixed version.
Attached Files
File Type: mq4 Hilbert SNR.mq4 (4.2 KB, 58 views)
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 12-30-2008, 09:27 PM
Senior Member
 
Join Date: Oct 2005
Posts: 455
Perky is on a distinguished road
maybe you have a divide by zero in there crashing it all
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 12-31-2008, 12:33 AM
Senior Member
 
Join Date: Oct 2008
Location: Vancouver, BC
Posts: 158
Roger09 is on a distinguished road
You have:
Code:
double dSmoothDomPeriod[];
should be
Code:
int dSmoothDomPeriod[];
or
Code:
double dSmoothDomPeriod[];
....
int x=dSmoothDomPeriod[k]/2;

Last edited by Roger09; 12-31-2008 at 12:49 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
  #5 (permalink)  
Old 12-31-2008, 02:21 AM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 297
ralph.ronnquist is on a distinguished road
Perhaps the bug would go away if you added "SetIndexEmptyValue(1,0);" to the init() method.
My guess is that without this, dSmoothDomPeriod[k] may be a quite large number for some k. Then the Q array becomes too large for the computer memory and bad things happen.
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 12-31-2008, 03:46 AM
Senior Member
 
Join Date: Oct 2008
Location: Vancouver, BC
Posts: 158
Roger09 is on a distinguished road
I tryed to realized your logic and couldn't. Lots of uncertainty as a:
I1[k] = dDeTrend[k + 3].
if k=Bars-6, you don't know dDeTrend[k + 3] because you didn't calculate it yet.
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 12-31-2008, 05:38 AM
Kenny Rogers's Avatar
Senior Member
 
Join Date: Oct 2008
Posts: 685
Kenny Rogers is on a distinguished road
I'm putting my money on Michel, he's a good coder.
__________________
Life is a Gamble. You win some. You lose some. And life goes on.
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
  #8 (permalink)  
Old 12-31-2008, 05:45 AM
Senior Member
 
Join Date: Mar 2006
Posts: 124
ZTrader is on a distinguished road
Yes, Michel gets the nod. I had already noticed that I needed to use Q3[k + g] and not just Q3[g], but I hadn't realized that the algorithm was invalid at some values of k + g. Michel's fix did the trick, and now the whole world can easily determine the signal to noise ratio of their favorite charts...

Thanks, Michel!!
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
  #9 (permalink)  
Old 01-01-2009, 09:18 AM
Senior Member
 
Join Date: May 2006
Posts: 156
waltini is on a distinguished road
a quick question

A quick coding question whilst everyone is around if that is ok.

I want my ea to take a trade every time the price is at a round number for example 1.4000 and when that trade is complete wait for the price to reach another round number to initiate another trade.

So its not a grid which is easy but I need the ea to recognise the price ends in 00.

I have tried using a few different things, I am even dividing the price by 100 and counting the length of the answer using stringlen() but the string function keeps adding zeros to the price.

Many thanks
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
  #10 (permalink)  
Old 01-01-2009, 11:31 AM
Senior Member
 
Join Date: Feb 2006
Posts: 587
Michel is on a distinguished road
PHP Code:
bool IsRoundPrice MathMod(Bid/Point,100) < 1
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


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



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