Forex
Google

Go Back   Forex Trading > Programming > Metatrader Programming
Forex Forum Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-23-2007, 10:50 PM
wolfe's Avatar
wolfe wolfe is offline
Senior Member
 
Join Date: Jan 2006
Posts: 673
wolfe is on a distinguished road
Driving me crazy

I'm trying to call the custom indicator CC_1. (attached)

Here's my code:

CC_USD=iCustom(NULL,0,"CC_1",0,0);
Print(" CC_USD =",CC_USD);
CC_EUR=iCustom(NULL,0,"CC_1",1,0);
Print(" CC_EUR =",CC_EUR);
CC_GBP=iCustom(NULL,0,"CC_1",2,0);
Print(" CC_GBP =",CC_GBP);
CC_CHF=iCustom(NULL,0,"CC_1",3,0);
Print(" CC_CHF =",CC_CHF);
CC_JPY=iCustom(NULL,0,"CC_1",4,0);
Print(" CC_JPY =",CC_JPY);
CC_AUD=iCustom(NULL,0,"CC_1",5,0);
Print(" CC_AUD =",CC_AUD);
CC_CAD=iCustom(NULL,0,"CC_1",6,0);
Print(" CC_CAD =",CC_CAD);
CC_NZD=iCustom(NULL,0,"CC_1",7,0);
Print(" CC_NZD =",CC_NZD);

In the experts file I keep getting this error:

CC_1 EURUSD,H1: unknown subwindow number -1 for ObjectCreate function

I'm not sure what's wrong.

My other problem is that it sometimes returns the proper info:
CC_EUR =0.0016

But a lot of the time the info returned is:
CC_EUR =2147483647

I can't figure out why it's returning this number. Could anyone who is better at this than me have a look and try to help? Thanks!
Attached Files
File Type: mq4 CC_1.mq4 (16.7 KB, 15 views)

Last edited by wolfe : 09-23-2007 at 10:52 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 09-24-2007, 04:24 AM
ralph.ronnquist's Avatar
ralph.ronnquist ralph.ronnquist is offline
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
Not sure I'm better at this, but WindowFind - MQL4 Documentation
does tell you that -1 is what you get in the init() function....

Perhaps you should make a second init() function, to be called once from the start() function, and that second init() function (init2() maybe?) would include all the sl(..) calls.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-24-2007, 04:25 AM
wolfe's Avatar
wolfe wolfe is offline
Senior Member
 
Join Date: Jan 2006
Posts: 673
wolfe is on a distinguished road
I've figured out that the indicator is working fine until a new bar is formed, then the indicator is stopping. Can someone look at the code in the first post and see if they can fix this? It doesn't seem to be continuing when a new bar is formed.

Thank you to anyone that can help!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 09-24-2007, 04:28 AM
wolfe's Avatar
wolfe wolfe is offline
Senior Member
 
Join Date: Jan 2006
Posts: 673
wolfe is on a distinguished road
Quote:
Originally Posted by ralph.ronnquist View Post
Not sure I'm better at this, but WindowFind - MQL4 Documentation
does tell you that -1 is what you get in the init() function....

Perhaps you should make a second init() function, to be called once from the start() function, and that second init() function (init2() maybe?) would include all the sl(..) calls.
Thanks for the reply. I'm not exactly sure how to fix the problem, but I will try your suggestion.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 09-24-2007, 04:41 AM
ralph.ronnquist's Avatar
ralph.ronnquist ralph.ronnquist is offline
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
I was thinking a design like the following outline....
PHP Code:
bool inited false;
int init()
{
    .... 
// As before but all sl(..) calls moved to init2()
    
inited false;
}

void init2()
{
    if ( 
inited ) return;
    ... 
// All the sl(..) calls
    
inited true;
}

int start()
{
    
init2();
    ...

In that way, the WindowFind() function would not be called from the init() function but from the start() function, at which time it actually works.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 09-24-2007, 04:56 AM
ralph.ronnquist's Avatar
ralph.ronnquist ralph.ronnquist is offline
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
Quote:
Originally Posted by wolfe View Post
I've figured out that the indicator is working fine until a new bar is formed, then the indicator is stopping. Can someone look at the code in the first post and see if they can fix this? It doesn't seem to be continuing when a new bar is formed.

Thank you to anyone that can help!
Check the logic for "limit"...

As it currently stands: apart from at the first start() call, the counted_bars value will always be in the vicinity of Bars, while All_Bars by the looks of it remains 10, and therefore limit becomes a large negative number.

Maybe you wanted
PHP Code:
limit MathMinAll_BarsBars counted_bars); 
or something similar?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 09-24-2007, 05:42 AM
wolfe's Avatar
wolfe wolfe is offline
Senior Member
 
Join Date: Jan 2006
Posts: 673
wolfe is on a distinguished road
Quote:
Originally Posted by ralph.ronnquist View Post
Check the logic for "limit"...

As it currently stands: apart from at the first start() call, the counted_bars value will always be in the vicinity of Bars, while All_Bars by the looks of it remains 10, and therefore limit becomes a large negative number.

Maybe you wanted
PHP Code:
limit MathMinAll_BarsBars counted_bars); 
or something similar?
Thank you for your suggestions, I am going to change All_Bars to 0 and try your limit logic in place of what is currently there. I hope this will solve the problem. Thank you for taking your time to try and help me.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 09-25-2007, 01:01 AM
wolfe's Avatar
wolfe wolfe is offline
Senior Member
 
Join Date: Jan 2006
Posts: 673
wolfe is on a distinguished road
Ralph,

Your suggestions seem to have done the trick! Thank you for spending your time to help another. The indicator is now staying current with the current bar. I hope someday to be able to repay the favor. I've posted the working indicator for all who are interested.

Thanks again!
Attached Files
File Type: mq4 CC_1.mq4 (16.8 KB, 24 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 09-25-2007, 02:39 AM
ElectricSavant's Avatar
ElectricSavant ElectricSavant is offline
Senior Member
 
Join Date: Jun 2007
Posts: 2,387
ElectricSavant is on a distinguished road
How do you read it?


Quote:
Originally Posted by wolfe View Post
Ralph,

Your suggestions seem to have done the trick! Thank you for spending your time to help another. The indicator is now staying current with the current bar. I hope someday to be able to repay the favor. I've posted the working indicator for all who are interested.

Thanks again!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 09-25-2007, 04:04 AM
wolfe's Avatar
wolfe wolfe is offline
Senior Member
 
Join Date: Jan 2006
Posts: 673
wolfe is on a distinguished road
Quote:
Originally Posted by ElectricSavant View Post
How do you read it?
Still experimenting with it. I want to incorporate it into an EA. Info about how it works can be found here.

Theoretical Basis of Building Cluster Indicators for FOREX - MQL4 Articles

Last edited by wolfe : 09-25-2007 at 04:08 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Documents Bureau-crazy in live account opening mpforex Metatrader brokers 4 04-12-2007 09:10 AM
invalid stop driving me nuts caldolegare Expert Advisors - Metatrader 4 11 05-04-2006 08:03 PM
Crazy Expert hosein9f Expert Advisors - Metatrader 4 10 03-09-2006 11:16 AM


All times are GMT. The time now is 02:51 PM.