Please fix this indicator or EA - page 142

 

Hi mladen,

Thanks for your answer!

Yes, they are Moving Averages (9 EMA & 12 SMA). I prefer to work with them.

Do you have any clue what i did wrong in my case?

 
Liza:
Hi mladen,

Thanks for your answer!

Yes, they are Moving Averages (9 EMA & 12 SMA). I prefer to work with them.

Do you have any clue what i did wrong in my case?

Liza

The (ma(9) > ma(12) || ma(9) < ma(12)) expression is always true (cases when ma(9) and ma(12) are exactly the same are very, very rare and almost never will happen)

 

Hi mladen,

Yes, i know. But i refer to my post #1411 that i'm trying to code an indicator wich filters the pinbars by MACD(12,26,9) or 2 MA's(9EMA & 12SMA). I try to generate an arrow when there is a bullish pinbar detected while 9EMA > 12SMA. And when there is a bearish pinbar detected while 9EMA < 12SMA. But somehow i did'nt manage to code it properly as the results are a bit odd. Please see my post for the screenshot.

I really appreciate all your help guys. Normally i would try everything my own until i can't figure it out myself anymore. I even started coding trying to get what i want.

Thanks again!

 
Liza:
Hi mladen,

Yes, i know. But i refer to my post #1411 that i'm trying to code an indicator wich filters the pinbars by MACD(12,26,9) or 2 MA's(9EMA & 12SMA). I try to generate an arrow when there is a bullish pinbar detected while 9EMA > 12SMA. And when there is a bearish pinbar detected while 9EMA < 12SMA. But somehow i did'nt manage to code it properly as the results are a bit odd. Please see my post for the screenshot.

I really appreciate all your help guys. Normally i would try everything my own until i can't figure it out myself anymore. I even started coding trying to get what i want.

Thanks again!

If you want to check to ma crosses than this code :

if ((pinbup!=EMPTY_VALUE&&pinup>0)&&(signal>main)) Temp = 1;

if ((pinbdown!=EMPTY_VALUE&&pindown>0)&&(signal<main)) Temp =-1;[/PHP]

should be like this :

[PHP]

if ((pinbup!=EMPTY_VALUE&&pinup>0)&&( iMA(NULL,0,9,0,MODE_EMA,PRICE_CLOSE,i)>iMA(NULL,0,12,0,MODE_DMA,PRICE_CLOSE,i))) Temp = 1; if ((pinbdown!=EMPTY_VALUE&&pindown>0)&&(iMA(NULL,0,9,0,MODE_EMA,PRICE_CLOSE,i)<iMA(NULL,0,12,0,MODE_SMA,PRICE_CLOSE,i))) Temp =-1;

but be aware that iMA(NULL,0,9,0,MODE_EMA,PRICE_CLOSE,i) < iMA(NULL,0,12,0,MODE_SMA,PRICE_CLOSE,i) is not the place where macd and signal line are crossing

 

Thanks, i knew that. My first attempt was with the iMA instead of iMACD. But that didn't work so that's why i tried the iMACD's MODE_MAIN & MODE_SIGNAL to check if my coding was off.

I tried your suggestion but still doesn't work. Please see the screenshot. On the red vertical line, there should be an arrow. I changed every suggestion. Normally i'm doing very well using logic in my life, but this time i really, really can't see what i'm doing wrong here. Do you have any hints, tips?

Thanks!!

pinbarma.mq4

Files:
 
Liza:
Thanks, i knew that. My first attempt was with the iMA instead of iMACD. But that didn't work so that's why i tried the iMACD's MODE_MAIN & MODE_SIGNAL to check if my coding was off.

I tried your suggestion but still doesn't work. Please see the screenshot. On the red vertical line, there should be an arrow. I changed every suggestion. Normally i'm doing very well using logic in my life, but this time i really, really can't see what i'm doing wrong here. Do you have any hints, tips?

Thanks!!

pinbarma.mq4

Liza

According to your set of conditions, it should not be there (it is a pinbar up but the fast ema is bellow the slow sma)

 

Thanks for your view but on the red vertical stripe there is a bearish (red smiley) pinbar detected while the fast ema is below the slow sma. The bearish buffer (0) is marked as you can see in the screenshot posted yesterday (see datawindow, that is the actual data for the signalcandle on the red vertical stripe). Here's another screenshot whereby the arrow is correctly shown (green line is the fast ema). So somewhere i made a mistake i think. Some arrows are drawn correctly, some wrong and some not at all.

Files:
gbpusdm5.png  57 kb
 
Liza:
Thanks for your view but on the red vertical stripe there is a bearish (red smiley) pinbar detected while the fast ema is below the slow sma. The bearish buffer (0) is marked as you can see in the screenshot posted yesterday (see datawindow, that is the actual data for the signalcandle on the red vertical stripe). Here's another screenshot whereby the arrow is correctly shown (green line is the fast ema). So somewhere i made a mistake i think. Some arrows are drawn correctly, some wrong and some not at all.

Liza

Try it out now : pinbarma_1.mq4

Files:
 

mladen,

THANKS!!

I noticed the changes and now i know why it didn't worked before! This will help my future coding very well (now i'm convinced to do so). Once again thanks for your great help. There's no need to explain the changes because i figured it out. But i think you thought the same.

 

Mr M

I ran his EA with the old MT4 ( 4 digits ) I had some good results .

I kept playing with the magic number , some times it worked and sometime it didn't

I not sure which pair or timeframe this EA is optimized for

If you could fix this

Thanks very much

Files:
pc.ex4  7 kb
Reason: