Metatrader 5 coding questions / issues - page 19

 

Please,

In an alert EA, when I write :

if (GetIndicator(handle1,0,0) >GetIndicator(handle2,0,0)) , I get Alerts, and with

if ((GetIndicator(handle1,0,0) >GetIndicator(handle2,0,0)) && (GetIndicator(handle1,0,1) <GetIndicator(handle2,0,1)) ), not any Alert.

Of course , I have :

handle1 = iMA(NULL, NULL,10,0,MODE_SMA,PRICE_CLOSE);

handle2 = iMA(NULL, NULL,20,0,MODE_SMA,PRICE_CLOSE);

What is the reason ?

Thanks in advance.

Jo

 
Jovager:
Please,

In an alert EA, when I write :

if (GetIndicator(handle1,0,0) >GetIndicator(handle2,0,0)) , I get Alerts, and with

if ((GetIndicator(handle1,0,0) >GetIndicator(handle2,0,0)) && (GetIndicator(handle1,0,1) <GetIndicator(handle2,0,1)) ), not any Alert.

Of course , I have :

handle1 = iMA(NULL, NULL,10,0,MODE_SMA,PRICE_CLOSE);

handle2 = iMA(NULL, NULL,20,0,MODE_SMA,PRICE_CLOSE);

What is the reason ?

Thanks in advance.

Jo

It should alert only in case when sma(10) crosses sma(20) up in the seconds case while in the first case it will alert whenever sma(10) is greater than sma(20) (assuming that the GetIndicator() function is OK)

 

loop array

Halo everyone!

It`s lovely to be here, a forum really well done, with experts able to help most of the time.

I tried to make something new in this new mq5 worl, but i got some problem.

i`m not good at all with cycles but here there is something abnormal from my weak point of view, i tried to store 2 datas current e previous touch of my array called touchedline, without success using this code:

for(int i=0;i<10;i++) {

if(touchedline>temp)

{

highest=i;

temp=touchedline;

}

}

temp=0;

for(int i=0;i<10;i++)

{

if(touchedline>temp && i!=highest)

{

previoushighest=i;

temp=touchedline;

}

}

Print("act_highest :",highest);

Print("prv_highest :",previoushighest);

THANKS IN ADVANCE

mecca_ea.mq5

Files:
mecca_ea.png  47 kb
mecca_ea.mq5  13 kb
 

Halo traders! i'm so sad no one is able to help me...

I know it's a bit too difficult to understand this code, especialy becauze this is mq5 (terrible to code with), but if someone could give me any idea is realy appreciate.

the main problem remain this:

The first check (touchedline > temp) because touchedline> 0, assign the first value "i" is equal to 0, to the highest variable. The other does not check because temp = touchedline and touchedline is equal for all.

Ani support is realy appreciate, thanks.

p.s.

sorry for bad english

KISSES

 

thanks

p.s.

sorry for bad english

 

There is a simple answer to the second question, and I already know it

As a way for you to treat in conventional buffers and Needs () if you want to use, a buffer before the init (and of course the number of buffers) should be notified. Then get hold of a particular indicator and then it copybuff () function should use. No longer (MetaTrader 5 "on-the-fly" to change the parameters, for example, try to) specific indicators to look for the easy way and I MetaTrader 4 MetaTrader indicator compared to the usual 5 s step back functions are now being kept repeating and why only a simple () call is needed, MetaTrader 4, and I practice indicators rather than "administration" so you have to write your own functions using the procedure 10 times the amount of code written for the need to make

 
sohagm700:
...so you have to write your own functions using the procedure 10 times the amount of code written for the need to make

thnx mr. Sohagm,

i need to write 10 times more which part of the code? it's not really clear.

Thank you

 

I changed the code like this:

int highest,touchx,previoustouchx;

if(ema1[1] > ema2[1] && ema1[0]< ema2[0])

{

if(TouchTime1 != emacross1_TouchTime)

{

drawArrow1(TouchTime1,ema1[0],"Wingdings 3",ArrowSize,"p",ArrowColor);

emacross1_TouchTime= TouchTime1;

highest=emacross1_TouchTime;

previoustouchx=touchx;

touchx=1;

}

}

but the problem is that each tick the previous touch is update...how could i bypass that?

only if touchx is different from before should be stored on "previoustouchx", how to do that?

is there any good coder here arounnd ?

thanx for any support mecca.mq5

Files:
mecca.mq5  14 kb
 

Mr. Mladen, could you please tell us somthing to help in coding?

Thanx alot

 
claudiaforex:
I changed the code like this:
int highest,touchx,previoustouchx;

if(ema1[1] > ema2[1] && ema1[0]< ema2[0])

{

if(TouchTime1 != emacross1_TouchTime)

{

drawArrow1(TouchTime1,ema1[0],"Wingdings 3",ArrowSize,"p",ArrowColor);

emacross1_TouchTime= TouchTime1;

highest=emacross1_TouchTime;

previoustouchx=touchx;

touchx=1;

}

}

but the problem is that each tick the previous touch is update...how could i bypass that?

only if touchx is different from before should be stored on "previoustouchx", how to do that?

is there any good coder here arounnd ?

thanx for any support mecca.mq5

claudiaforex

In metatrader 5 index 0 is the oldest bar (not the current bar like in metatrader 4) unless not specified differently (by using ArraySetAsSeries()).

all the best

Reason: