mt4 how to access custom indicator from expert?

 

I need a bit of help understanding how to access below custom indicator signals from an EA so I can produce buy and sell orders. It appears the b1 and b2 is where I need to look, but I cannot work out what to do. Forgive me for the lack of insight, I'm new to this. For what it's worth, this indicator is the one typically named super signal, it's been discussed widely on the forum over the years.


#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Aqua
//----
extern int SignalGap=10;
//----
int dist=24;
double b1[];
double b2[];
//----
int init()
{
    SetIndexStyle(0,DRAW_ARROW,STYLE_SOLID,1);
    SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID,1);
    SetIndexArrow(1,233);
    SetIndexArrow(0,234);
    SetIndexBuffer(0,b1);
    SetIndexBuffer(1,b2);
    return(0);
}
//----
int start()
{
    int counted_bars=IndicatorCounted();
    int k,i,j,limit,hhb,llb;
//----
    if (counted_bars<0) return(-1);
    if (counted_bars>0) counted_bars--;
    limit=Bars-1;
    if(counted_bars>=1) limit=Bars-counted_bars-1;
    if (limit<0) limit=0;
        for(i=limit;i>=0;i--)   
        {
            hhb=Highest(NULL,0,MODE_HIGH,dist,i-dist/2);
            llb=Lowest(NULL,0,MODE_LOW,dist,i-dist/2);
//----
            if (i==hhb)
                b1[i]=High[hhb]+SignalGap*Point;
            if (i==llb)
                b2[i]=Low[llb]-SignalGap*Point;
        }
    return(0);
}
 
jepper:

I need a bit of help understanding how to access below custom indicator signals from an EA so I can produce buy and sell orders. It appears the b1 and b2 is where I need to look, but I cannot work out what to do. Forgive me for the lack of insight, I'm new to this. For what it's worth, this indicator is the one typically named super signal, it's been discussed widely on the forum over the years.


You can use 'iCustom' function for this to read signal in buffers.

Check the below link in mql4 documentation

https://docs.mql4.com/indicators/icustom

iCustom - Technical Indicators - MQL4 Reference
iCustom - Technical Indicators - MQL4 Reference
  • docs.mql4.com
iCustom - Technical Indicators - MQL4 Reference
 
Afsal Meerankutty #:

You can use 'iCustom' function for this to read signal in buffers.

Check the below link in mql4 documentation

https://docs.mql4.com/indicators/icustom

I've read as much, I am none the wiser. How do I get from here

double superSignal=iCustom(NULL,0,"super-signal",10,0);

this always just returns 0 - another questino: Does the indicator itself lend itself to this? All I really need is a true false per bar.

 
jepper #: double superSignal=iCustom(NULL,0,"super-signal",10,0);

this always just returns 0

Of course, it does.
extern int SignalGap=10;
    SetIndexBuffer(0,b1);
    SetIndexBuffer(1,b2);

Your indicator only has two buffers [0 … 1] and one input (10). Your call does not pass buffer index and bar index.
          Detailed explanation of iCustom - MQL4 programming forum (2017)

 
jepper:

I need a bit of help understanding how to access below custom indicator signals from an EA so I can produce buy and sell orders. It appears the b1 and b2 is where I need to look, but I cannot work out what to do. Forgive me for the lack of insight, I'm new to this. For what it's worth, this indicator is the one typically named super signal, it's been discussed widely on the forum over the years.



Please rename super-signal.mq4 -> supersignal.mq4. and recompiler.


---
   double T1=iCustom(Symbol(),0,"supersignal",0,1);
   double T2=iCustom(Symbol(),0,"supersignal",1,1);
   if(T1!=2147483647 && T1>0) Print("BUY ");
   if(T2!=2147483647 && T2>0) Print("SELL ");

dd