Anybody know how to deal this indicator?

 

Hi All,


Is anybody know how to deal with the attached indicator? I'm trying to build an EA base on this indicator, but somehow the indicator's color and the indicator's buffer is inconsistent. I can't see it repaint though.

For better understanding, please look at the simple file written as an EA (without buy and sell code), and 2 screenshots below.


Here is the "EA" code:

//+------------------------------------------------------------------+
//|                                              BrainTrend test.mq4 |
//|                      Copyright © 2009, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
    
    double BrainTrend0=iCustom(Symbol(),0,"BrainTrend2",500,0,1); 
    double BrainTrend1=iCustom(Symbol(),0,"BrainTrend2",500,1,1);    

    string com="\n";
    if(BrainTrend0>BrainTrend1) com=com+"BrainTrend UP "+DoubleToStr(BrainTrend0,Digits)+" "+DoubleToStr(BrainTrend1,Digits)+"\n";
    if(BrainTrend0<BrainTrend1) com=com+"BrainTrend DN "+DoubleToStr(BrainTrend0,Digits)+" "+DoubleToStr(BrainTrend1,Digits)+"\n";
    
    Comment(com);
    
 //----
   return(0);
  }

Below are screenshots from visual backtesting.

At the first screenshot, everything looks fine.



Then at a bar later, the indicator buffer looks reversed without reversing the color.



And this happen so many times, this almost frustating me (it's already actually LOL). Is anybody know how to deal with this kind of indicator?

I'm appreciating any help.


Thank you!

Files:
 
Guys?
 
So is this impossible? or is there anything obvious and not challenging at all but I missed it?
Reason: