Problem with initiating >2 indicators

To add comments, please log in or register
JosephRael
11
JosephRael  

I'm writing an EA that uses momentum for trading. For this I use 4 indicators in pairs of 2. Pair one evaluates for example H1, the second pair M10. I'm using the iMA() function to init it, see the code below. But when running, the second pair both return invalid handles. What am I doing wrong here? (Please assume all the used variables are initiated prior to this.


int p1LargeTrendPanel = iMA(_Symbol, myP1, p1LargeTrendPeriod, 0, p1LargeTrendSMAMethod, PRICE_CLOSE);
if(p1LargeTrendPanel == INVALID_HANDLE)
        Print("p1LargeTrendPanel: Failed to create a handle: ",GetLastError());
int p1SmallTrendPanel = iMA(_Symbol, myP1, p1SmallTrendPeriod, 0, p1SmallTrendSMAMethod, PRICE_CLOSE);
if(p1SmallTrendPanel == INVALID_HANDLE)
        Print("p1SmallTrendPanel: Failed to create a handle: ",GetLastError());
        
int p2LargeTrendPanel = iMA(_Symbol, myP2, p2LargeTrendPeriod, 0, p2LargeTrendSMAMethod, PRICE_CLOSE);
if(p2LargeTrendPanel == INVALID_HANDLE)
        Print("P2LargePanel: Failed to create a handle: ",GetLastError());
int p2SmallTrendPanel = iMA(_Symbol, myP2, p2SmallTrendPeriod, 0, p2SmallTrendSMAMethod, PRICE_CLOSE);
if(p2SmallTrendPanel == INVALID_HANDLE)
        Print("p2SmallPanel: Failed to create a handle: ",GetLastError());
Code2219 or probably 2319
277
Code2219 or probably 2319  
JosephRael:

I'm writing an EA that uses momentum for trading. For this I use 4 indicators in pairs of 2. Pair one evaluates for example H1, the second pair M10. I'm using the iMA() function to init it, see the code below. But when running, the second pair both return invalid handles. What am I doing wrong here? (Please assume all the used variables are initiated prior to this.


use _LastError to see why your handles are invalid... most probably internal parameters are wrong

whroeder1
17993
whroeder1  
Create your handles in OnIinit. use them in OnTick.
JosephRael
11
JosephRael  
Code2219 or probably 2319:

use _LastError to see why your handles are invalid... most probably internal parameters are wrong

As you can see, that is already in there. The error message simply reads: "Failed to create a handle: 4002". Not much to go by unfortunately. I think I'll just build a quick  MA algo myself and call that instead.
Code2219 or probably 2319
277
Code2219 or probably 2319  
JosephRael:
As you can see, that is already in there. The error message simply reads: "Failed to create a handle: 4002". Not much to go by unfortunately. I think I'll just build a quick  MA algo myself and call that instead.
error codes


which means at least one of the parameters passed to iMA is wrong :

myP2
p2LargeTrendPeriod
p2LargeTrendSMAMethod
To add comments, please log in or register