Metatrader 5 coding questions / issues - page 18

 

gioooooo

Error is in SimpleMAOnBuffer() function. Forget about it - even if you correct it, on next update it will be overwritten and you will loose your changes. If you use SimpleMA() instead, it works OK

Attached the correct version

Files:
gio_trand.mq5  3 kb
 

Not worth using their mqh files. Buggy and when you correct them they get overwritten with new update. Better to make your own

 
techmac:
Not worth using their mqh files. Buggy and when you correct them they get overwritten with new update. Better to make your own

That was like that from the very beginning (I remember when I lost a day or two when I trusted to the functions they wrote in metatrader 5 and it turned out that those are not to be trusted at all). Ever since I never user their functions written in mql5 : not worth of time you are going to loose in some situations. Better make your own

 

Is there a chance that anyone programmed e version with alerts and arrows of the SMI Indicator?

sgvg23:
Hi mladen, i have this two file

blau_sm_stochastic.mq5

williamblau.mqh
 

Mladen,

I understand that default fractal indicator in mt5 gives signal on current bar after the close of the next bar (Correct me If I'm wrong; see image attached). I have been trying to call fractal buy and sell function but I do not know how. I downloaded a fractal indicator (attached) and tried to use it but I discovered two problems;

1. It does not behave like the default fractal i.e. it waits more than one bar before forming a fractal unlike the default one which wait only one bar.

2. Even if problem 1 is corrected, I do not know what specific number represents buy or sell fractal that I can call from this indicator. Although I plan solving this by simply multiplying one of the buffers by zero.

For Example {where buffer1 is High} (buffer1 * 0)+1. if(buffer1[2]==1) sell;

{and buffer2 is Low} (buffer2*0)+2. if(buffer2[2]==2) buy;

Please find the attached files below.

Thanks.

Files:
 
funayot:
Mladen,

I understand that default fractal indicator in mt5 gives signal on current bar after the close of the next bar (Correct me If I'm wrong; see image attached). I have been trying to call fractal buy and sell function but I do not know how. I downloaded a fractal indicator (attached) and tried to use it but I discovered two problems;

1. It does not behave like the default fractal i.e. it waits more than one bar before forming a fractal unlike the default one which wait only one bar.

2. Even if problem 1 is corrected, I do not know what specific number represents buy or sell fractal that I can call from this indicator. Although I plan solving this by simply multiplying one of the buffers by zero.

For Example {where buffer1 is High} (buffer1 * 0)+1. if(buffer1[2]==1) sell;

{and buffer2 is Low} (buffer2*0)+2. if(buffer2[2]==2) buy;

Please find the attached files below.

Thanks.

funayot

It sets the fractal 2 bars away from the current (not on the first closed)

The easiest way is to test if a buffer value is == to EMPTY_VALUE. If it is not, then there is a signals

 

I have a problem in calling from a custom indicator both value printed in the chart.

Here is my code:

Inicator 1:

//indicator 1 plot 2 different line in the chart with 2 different color

SetIndexBuffer(0,buffer1);

SetIndexBuffer(1,buffer2);

for( int i=start; i<rates_total; i++) {

buffer1=......

buffer2=.....

}

........

Indicator 2:

double Value1[];

double Value2[];

......

h_X= iCustom(NULL,0,"INDICATOR 1",parm1,param2,param3,param4);

int copy2=CopyBuffer(h_X,0,0,rates_total,Value1); //here 1 get the first plotted line of indicator1 inside indicator2

.......

for( int i=start; i<rates_total ; i++) {

Value2= ObjectGetValueByTime(0,"INDICATOR 1",time,OBJ_TREND); //get the second plotted line of indicator1 inside indicator2

Print("Val1=",value1); //for debug it prints 0

Print("Val2=",value2); //for debug it prints 0

}

 
gioooooo:
I have a problem in calling from a custom indicator both value printed in the chart.

Here is my code:

Inicator 1:

//indicator 1 plot 2 different line in the chart with 2 different color

SetIndexBuffer(0,buffer1);

SetIndexBuffer(1,buffer2);

for( int i=start; i<rates_total; i++) {

buffer1=......

buffer2=.....

}

........

Indicator 2:

double Value1[];

double Value2[];

......

h_X= iCustom(NULL,0,"INDICATOR 1",parm1,param2,param3,param4);

int copy2=CopyBuffer(h_X,0,0,rates_total,Value1); //here 1 get the first plotted line of indicator1 inside indicator2

.......

for( int i=start; i<rates_total ; i++) {

Value2= ObjectGetValueByTime(0,"INDICATOR 1",time,OBJ_TREND); //get the second plotted line of indicator1 inside indicator2

Print("Val1=",value1); //for debug it prints 0

Print("Val2=",value2); //for debug it prints 0

}

Without the whole code impossible to tell what is going on

Metatrader 5 logic that something is inverted compared to metatrader 4 and something is not make the whole thing messed up sometimes

 
mladen:
Without the whole code impossible to tell what is going on Metatrader 5 logic that something is inverted compared to metatrader 4 and something is not make the whole thing messed up sometimes

I have found the solution, here the two example files

1.mq5

2.mq5

Files:
1.mq5  4 kb
2.mq5  4 kb
 
gioooooo:
I have found the solution, here the two example files

1.mq5

2.mq5

gioooooo

You do not need this part :

IndicatorRelease(h_var2);

IndicatorRelease(h_var3);

IndicatorRelease(h_var4);

h_var2, h_var3 and h_var4 were never initialized

Reason: