Quote:
Originally Posted by ingvar_e
Hi,
I am new to Metatrader but very experienced in programming. I have created some sample Expert Advisors and some slightly complicated Indicators in MT. What is not clear is how to structure a rather complicated EA. I want the EA to call some "signal" functions to check for different setup condition.
How should I code these functions?
1. As "inline" functions in the EA
2. As "separate" Indicators that return a value instead of write on the screen?
3. some other "separate" function to call like calling iMA
If I choose alternative 1 can the inline function in the EA run thru the last 200 bars using Close[i] and call iMA?
Is alternative 2 OK?. When coding an indicator all bars "available" are processed which of course is not needed for the EA.
Alternative 3 to me seems like the logical choice but I am not sure how to structure it so it will work in backtesting and what I need to pass to it and what the function has access to by default, like for instance Close[i]
As an example of what I need to establish in the "signal" function is what is the current trend and when did it start. I have coded it in an indicator so I know how to do the actual code.
Grateful for any advice.
Ingvar
|
You probably already know how to do this, so sorry if you do.
Moving average of
current bar:
iMA(NULL,0,13,0,MODE_EMA,PRICE_CLOSE,
0);
Moving average of
200 bars ago.
iMA(NULL,0,13,0,MODE_EMA,PRICE_CLOSE,
200);
You can call the moving average from whatever bar you want form current to any bar in the past.