WindowFind() returns -1 if custom indicator searches itself when init() function works. ???
It means you can't use WindowFind() during init()...
put it inside start()
"The help file for windowfind() says that WindowFind() returns -1 if custom indicator searches itself when init() function works ... but I have no idea what this means"
It means you can't use WindowFind() during init()...
put it inside start()
See IndicatorShortName() along with WindowFind()
Then WindowFInd() is not finding an indicator subwindow registered with the shortname of "MTA MF Viewer". The return of -1 = fail.
See IndicatorShortName() along with WindowFind()
Within the init() section of the EA (and in the indicator that I created with the same code as I wasn't sure what to do) I have IndicatorShortName("MTF MA Viewer"); so as far as I can see a window is being created with this short name. If I load the indicater in the terminal then I can see in the top left 'MTA MF Viewer' so it does appear to me that I have an indicator with this short name.
I understand that returning -1 is a fail and it can't find this indicator name, but to me it seems that I have an indicator with this name so I don't understand why it's failing.
I tried looking for a function that would return an array of all Window Names but couldn't find one. Does this exist? If so then presumably I could just loop through the array and see what windows I could see .. maybe work backwards that way.
Could it be because I have a created an indicator with the EA code .. so all indicator code in the EA and an indicator? Seems unlikely as I was getting this problem before creating the indicator ... the problem was what led me to create the indicator in case that was the issue.
thanks
Build the EA as an EA.
If the EA needs information from the indicator, use iCustom() in the EA to retireve values from the indicator index buffer specified.
The only reason I know of that you need to know the window is to draw objects. If you are drawing objects as your "indication" then
iCustom() won't ncessarily be an option.
I have no idea what "three ducks" is about.
... rereading your original post now...
I have no idea what "three ducks" is about.
Thanks for the help so far ... guess I'm just not familiar enough with the software yet to figure out the problem
if( Bid > iMA(Symbol(), 5, 60, 0, 0, 0, 0) && Bid > iMA(Symbol(), 60, 60, 0, 0, 0, 0) && Bid > iMA(Symbol(), 240, 60, 0, 0, 0, 0)) LongSignal = true; if( Bid < iMA(Symbol(), 5, 60, 0, 0, 0, 0) && Bid < iMA(Symbol(), 60, 60, 0, 0, 0, 0) && Bid < iMA(Symbol(), 240, 60, 0, 0, 0, 0)) ShortSignal = true;
If you could provide some advice then that would be great. Have attached all files so it's clearer what I'm talking about. Als3ducks is my initial attempt and the rest is from the example I found i.e. with the windowfind() problem.
thanks
Hello,
I am new to MetaTrader and have been trying to write my first EA. I've done plenty of programming in the past (Java, php, etc) so I have no issues with that aspect, but I've been really stuggling with things like money management, optimising trade entry and exit.
Anyway, to cut a long story short the EA I was writing (based on the 3 ducks strategy) was going nowhere fast and I found a an EA online based on this and have been planning on working through the code to help my development. However, when I've tried to run it in strategy tester to see how it works initially I get an error
2008.02.09 19:40:43 2008.01.10 10:41 3-ducks-trading-system GBPUSD,M5: unknown subwindow number -1 for ObjectCreate function
Have traced this back in the code and it seems that the ObjectCreate function is calling WindowFind("MTA MF Viewer"). Now I have guessed that the mq4 file should also be used as an indicator and I've created an indiactor using the same code. It's made no difference.
The help file for windowfind() says that WindowFind() returns -1 if custom indicator searches itself when init() function works ... but I have no idea what this means? Is it referencing itself in some way that's causing a problem.
Can anyone help? I can upload the files if that helps?
p.s. All this is on the presumption that automated trading with MetaTrader can be profitable if you put the work in, and should be easier once you know the system/code ... if this isn't the case then soneone please tell me now !!
Many thanks,
Allan
I've run just run into this issue as well when backtesting... I added this code to the indy code & now it works fine! (no longer get error message)
----------
if(IsTesting() && !IsVisualMode() ) {}
// note: no indy object create while backtesting w/o VisualMode, if visual testing make sure indy on visual tester template
else
{
// [ ObjectCreate CODE.... ]
}
-----------
Good Fortune To All!
3 ducks is a fairly simple trading strategy that I thought would be "easy" to build an EA for as my first foray into automation. Simply have 60 period SMA on H4, H1, and M5 and go long or short when the "3 ducks" are in a line i.e. price is above or below all 3.
Thanks for the help so far ... guess I'm just not familiar enough with the software yet to figure out the problem
Was this problem ever resolved? For the life of me I can't get WindowFind to work correctly. Always returns as -1. Yet I am positive I am inputting the name correctly.
int WindowNumber = WindowFind(WindowExpertName()); //Print(WindowNumber); Print(WindowExpertName()); //Delete the previous label ObjectDelete(sBufferString); //if the object for some reason still exists create it if(ObjectFind(sBufferString) == -1) { ObjectCreate(sBufferString,OBJ_TREND,WindowNumber,0,0,0,0);
Any ideas?
I am new to MetaTrader and have been trying to write my first EA. I've done plenty of programming in the past (Java, php, etc) so I have no issues with that aspect, but I've been really stuggling with things like money management, optimising trade entry and exit.
Anyway, to cut a long story short the EA I was writing (based on the 3 ducks strategy) was going nowhere fast and I found a an EA online based on this and have been planning on working through the code to help my development. However, when I've tried to run it in strategy tester to see how it works initially I get an error
2008.02.09 19:40:43 2008.01.10 10:41 3-ducks-trading-system GBPUSD,M5: unknown subwindow number -1 for ObjectCreate function
Have traced this back in the code and it seems that the ObjectCreate function is calling WindowFind("MTA MF Viewer"). Now I have guessed that the mq4 file should also be used as an indicator and I've created an indiactor using the same code. It's made no difference.
The help file for windowfind() says that WindowFind() returns -1 if custom indicator searches itself when init() function works ... but I have no idea what this means? Is it referencing itself in some way that's causing a problem.
Can anyone help? I can upload the files if that helps?
p.s. All this is on the presumption that automated trading with MetaTrader can be profitable if you put the work in, and should be easier once you know the system/code ... if this isn't the case then soneone please tell me now !!
Many thanks,
Allan