Need help with a new indicator

 

Hi everyone,

I need some help putting together an indicator please. I am not a developer and have the worlds respect for the gurus on this site. Normally I can manipulate existing code, but MT code I struggle to understand :-)

I want a buy and sell signal to fire on the chart (with alert) if all of the following is true:

BUY/CALL:

Bollinger Bands: Price => the top band

AND

RSI <=30

AND

Intraday Momentum Index <=30

AND

Money Flow Index <=20

AND

Stochastics: Both fast and slow needs to be <=20

SELL/PUT:

Bollinger Bands: Price =< the bottom band

AND

RSI <=70

AND

Intraday Momentum Index >=70

AND

Money Flow Index >=80

AND

Stochastics: Both fast and slow needs to be >=80

Any help will be greatly appreciated.

Sincerely,

J

 

That is a whole trading system

jluyt:
Hi everyone,

I need some help putting together an indicator please. I am not a developer and have the worlds respect for the gurus on this site. Normally I can manipulate existing code, but MT code I struggle to understand :-)

I want a buy and sell signal to fire on the chart (with alert) if all of the following is true:

BUY/CALL:

Bollinger Bands: Price => the top band

AND

RSI <=30

AND

Intraday Momentum Index <=30

AND

Money Flow Index <=20

AND

Stochastics: Both fast and slow needs to be <=20

SELL/PUT:

Bollinger Bands: Price =< the bottom band

AND

RSI <=70

AND

Intraday Momentum Index >=70

AND

Money Flow Index >=80

AND

Stochastics: Both fast and slow needs to be >=80

Any help will be greatly appreciated.

Sincerely,

J
 

Please Try it,

I can't attach file so copy and paste the code below.

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 LawnGreen

#property indicator_color2 Red

extern int BB_Period =20;

extern int BB_Price = PRICE_CLOSE;

extern int BB_Dev = 2;

extern int BB_Type = MODE_SMA;

extern int RSI_Period =20;

extern int RSI_Price = PRICE_CLOSE;

extern int MOM_Period =20;

extern int MOM_Price = PRICE_CLOSE;

extern int MON_Period =20;

extern int STOK_Period= 8;

extern int STOD_Period=3;

extern int STO_Slow=3;

extern int STO_Method=MODE_SMA;

extern int STO_Price=PRICE_CLOSE;

double MA_,BBUp,BBDw,RSI,MOM,MON,STOUp,STODw;

double CrossUp[];

double CrossDown[];

//plot state can be 1 of: UP,DOWN

#define PLOTUP 1

#define PLOTDOWN -1

int iWaitFor = PLOTUP; //initial value

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

//---- indicators

SetIndexStyle(0, DRAW_ARROW, EMPTY);

SetIndexArrow(0, 225);

SetIndexBuffer(0, CrossUp);

SetIndexStyle(1, DRAW_ARROW, EMPTY);

SetIndexArrow(1, 226);

SetIndexBuffer(1, CrossDown);

return(0);

}

//+------------------------------------------------------------------+

//| script program start function |

//+------------------------------------------------------------------+

int start()

{

BBUp= 0;

BBDw= 0;

RSI=0;

MOM=0;

MON=0;

STOUp=0;

STODw=0;

int counted_bars = IndicatorCounted();

int i;

int limit;

if(counted_bars < 0)

return(-1);

if(counted_bars > 0)

counted_bars--;

limit = Bars - counted_bars;

for(i=0; i<=limit; i++)

{

BBUp= iBands(Symbol(),0,BB_Period,BB_Dev,0,BB_Price,1,i);

BBDw= iBands(Symbol(),0,BB_Period,BB_Dev,0,BB_Price,2,i);

RSI=iRSI(Symbol(),0,RSI_Period,RSI_Price,i);

MOM=iMomentum(Symbol(),0,MOM_Period,MOM_Price,i);

MON=iMFI(Symbol(),0,MON_Period,i);

STOUp=iStochastic(Symbol(),0,STOK_Period,STOD_Period,STO_Slow,STO_Method,STO_Price,1,i);

STODw=iStochastic(Symbol(),0,STOK_Period,STOD_Period,STO_Slow,STO_Method,STO_Price,2,i);

if (Open >= BBUp && RSI <= 30 && MOM <= 30 && MON <= 20 && STOUp <= 20 && STODw <= 20 && iWaitFor==PLOTUP)

{

iWaitFor = PLOTDOWN;

CrossUp=Low - 0.0010;

}

if (Open <= BBUp && RSI = 70 && MON >= 80 && STOUp >= 80 && STODw >= 80 && iWaitFor==PLOTUP)

{

iWaitFor = PLOTUP;

CrossDown=High + 0.0010;

}

}

return(0);

}

 

jluyt,

Something is wrong with those conditions - they almost never happen simultaneously.

dasio,

changed a bit you code to check what is going on. Attaching it here

Files:
_dasio.mq4  3 kb
 
mladen:
jluyt,

Something is wrong with those conditions - they almost never happen simultaneously.

dasio,

changed a bit you code to check what is going on. Attaching it here

Thank you. i will study it.^^

i think that the error is in this sell condition

RSI <=70

 

Thanks everyone for helping me out on this - I really appreciate it.

I will check the conditions tonight and post an update.

Sincerely,

J

 

Thanks everyone for helping on this system. Indeed the RSI needs to be >=70 for a selling condition, thanks for the catch dasio.

I loaded the indicator, fine tuned its parameters and it is still not firing, even though it should. Below I am adding some additional information, I forgot to add last night.

BUY/CALL:

Bollinger Bands: Price => the top band

AND

RSI <=30

AND

Intraday Momentum Index <=30

AND

Money Flow Index <=20

AND

Stochastics: Both fast and slow needs to be <=20

SELL/PUT:

Bollinger Bands: Price =< the bottom band

AND

RSI >=70

AND

Intraday Momentum Index >=70

AND

Money Flow Index >=80

AND

Stochastics: Both fast and slow needs to be >=80

The default parameters for each needs to be:

Bollinger Bands (12,2,2)

RSI (length 12)

IMI (length 12)

MFI (length 12)

Stochastics needs to be FULL Stochastics (full sto) with (%K=10 ; Slowing Period = 6 and %D = 6)

I attach my indicator as I have it now, but as I mentioned, it is not firing under conditions that it should. I will add a screenshot to indicate what I mean.

Sincerely,

J

PS: I renamed the file to OptionsSystem, just so that it is meaningful long term.

Files:
mtshot.jpg  321 kb
 
Files:
 

Thanks dasio. I loaded it but I can still not get it to fire any signals on the chart al all. I have several instances where all the conditions hold true, but no signal. Does it show up on your chart?

Sincerely,

J

 
jluyt:
Thanks dasio. I loaded it but I can still not get it to fire any signals on the chart al all. I have several instances where all the conditions hold true, but no signal. Does it show up on your chart?

Sincerely,

J

In the image all the indicators respect the sell rules. But the BB not respect it.

Please check your rules.

SELL/PUT:

Bollinger Bands: Price =< the bottom band

AND

RSI >=70

AND

Intraday Momentum Index >=70

AND

Money Flow Index >=80

AND

Stochastics: Both fast and slow needs to be >=80

 

Dasio,

Yes, I slipped on that - sorry

BB's:

At or above the TOP band, we SELL

At or below the bottom band, we buy

J

Reason: