Indicator shows signals, but EA yields no results

 

I created a custom indicator that outputs a binary signal on whether to open a trade (0 for do nothing, 1 for open long, -1 for open short). When I attach it to a chart it works as expected and I see the blips of 1 and -1 in the expected locations. I then coded an EA to simply open a trade if the iCustom call returns a 1 or -1. But when I run the tester, it yields no results at all. In visual mode, it adds the indicator to the window so I checked to see if it looks the same as when I added it. It doesn't! The indicator is always 0 in the visual tester. I'm wondering how this difference could have come.


Simply put, the custom indicator looks different on a live chart than it does on visual mode in strategy tester. I'm wondering how to test this other than just manual trading based on signals on live chart. Thanks for the help!

 

Why not just code the logic of your indicator into the EA.

This is a much better and robust solution, and usually easier to debug.

 
akaAni:

Simply put, the custom indicator looks different on a live chart than it does on visual mode in strategy tester. I'm wondering how to test this other than just manual trading based on signals on live chart. Thanks for the help!

You are not the first person to say this . . . and the answer is always that you have done something wrong . . . did you pass all the extern values in your iCustom call ? how many buffers do you have in the Indicator ? are you calling the correct one ?

Perhaps you should show some code and you can get more specific help if you do . . .

 
akaAni:

I created a custom indicator that outputs a binary signal on whether to open a trade (0 for do nothing, 1 for open long, -1 for open short).

You may think I am being pedantic, but this is a programming forum so we do have to be clear on our terminology. Binary is true or false, 1 or 0. The clue is in the BI- part, this prefix meaning two.

https://en.wikipedia.org/wiki/Binary_logic

https://en.wikipedia.org/wiki/Balanced_ternary

As for your problem, the indicator is at fault because it is not working in the tester. The EA may also be making a faulty call to iCustom but you will never know until the indicator displays correctly in the tester.

 

yeah my bad about the use of 'binary'

I created a second indicator which just keeps one buffer. it makes an iCustom call to the original indicator and stores the current value in its own buffer. Essentially this indicator copies the original. And that works, so the iCustom call seems to be ok...unless I'm missing something which applies to EAs in particular. I'll post the relevant snippets when I get back home, but I have a feeling I'm just missing something very elementary and I'm going to feel pretty stupid when the solution appears. Thanks

 

I just made a discovery, I don't know if it'll provide any insight.

So in the tester, the indicator *does* appear to work. But only prior to the starting date of the test. So if I'm running the test from May 10 to today, the indicator appears normal in the tester window up until May 9, and then its all zeroes from then to the end...

I'm sure it's something in the indicator that's not jiving. I've tried just calling iRSI and others in the EA and it works fine, it's like the iCustom call to my indicator returns invalid.

 

akaAni:

but I have a feeling I'm just missing something very elementary and I'm going to feel pretty stupid when the solution appears.

Yes, I think so too :-)
 

Another possibility is a zero divide in your indicator. Although this should be reported in the experts tab.

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red

double myIndicator[];

//+------------------------------------------------------------------+
int init(){

   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,myIndicator);

   return(0);
}
//+------------------------------------------------------------------+
int start(){
   int limit = Bars - IndicatorCounted() - 1;
   if( limit < 1 )
       limit = 1;
   
   double zero = 0;
       
   for( int n=limit; n>=0; n-- ){
      myIndicator[n] = n % 7;
      
      // the zero divide will crash the indicator at this point and prevent further execution for this tick
      if( n== 100 )  
         myIndicator[n] = myIndicator[n]/zero;
   }

   return(0);
}
 
akaAni:
it's like the iCustom call to my indicator returns invalid.
Detailed explanation of iCustom - MQL4 forum and/or post the code (There's no mind readers here.)
Reason: