Coding help - page 154

 

Re

I want to try to have result for 3 lines averages i have coded this but don't work can anyone help me ?? Thanks for your reply !

#property copyright ""

#property link ""

#property indicator_chart_window

#property indicator_buffers 1

#property indicator_color1 Yellow

//---- input parameters

extern int length = 14;

extern int length2 = 21;

extern int lenght3 =38;

double ExtMapBuffer1[];

int ExtCountedBars=0;

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

//| Custom indicator initialization function |

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

int init()

{

//---- indicators

SetIndexStyle(0,DRAW_LINE);

SetIndexBuffer(0,ExtMapBuffer1);

//----

return(0);

}

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

//| Custom indicator deinitialization function |

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

int deinit()

{

//----

//----

return(0);

}

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

//| Custom indicator iteration function |

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

int start()

{

if(Bars<=1) return(0);

ExtCountedBars=IndicatorCounted();

//---- check for possible errors

if (ExtCountedBars<0) return(-1);

//---- last counted bar will be recounted

if (ExtCountedBars>0) ExtCountedBars--;

int pos=Bars-1;

if(ExtCountedBars>1) pos=Bars-ExtCountedBars-1;

//---- main calculation loop

while(pos>=0)

{

double median = (iCustom(NULL,0,"indicator1",length,0,pos)+

iCustom(NULL,0,"indicator2",length2,0,pos)+

iCustom(NULL,0,"indicator3",length3,0,pos))/3.0;

}

return(median);

}

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

 
bixwin:
I want to try to have result for 3 lines averages i have coded this but don't work can anyone help me

#property copyright ""

#property link ""

#property indicator_chart_window

#property indicator_buffers 1

#property indicator_color1 Yellow

//---- input parameters

extern int length = 14;

extern int length2 = 21;

extern int lenght3 =38;

double ExtMapBuffer1[];

int ExtCountedBars=0;

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

//| Custom indicator initialization function |

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

int init()

{

//---- indicators

SetIndexStyle(0,DRAW_LINE);

SetIndexBuffer(0,ExtMapBuffer1);

//----

return(0);

}

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

//| Custom indicator deinitialization function |

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

int deinit()

{

//----

//----

return(0);

}

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

//| Custom indicator iteration function |

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

int start()

{

if(Bars<=1) return(0);

ExtCountedBars=IndicatorCounted();

//---- check for possible errors

if (ExtCountedBars<0) return(-1);

//---- last counted bar will be recounted

if (ExtCountedBars>0) ExtCountedBars--;

int pos=Bars-1;

if(ExtCountedBars>1) pos=Bars-ExtCountedBars-1;

//---- main calculation loop

while(pos>=0)

{

double median = (iCustom(NULL,0,"indicator1",length,0,pos)+

iCustom(NULL,0,"indicator2",length,,0,pos)+

iCustom(NULL,0,"indicator3",length,0,pos))/3.0;

}

return(median);

}

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

bixwin

I already posted a question : what are the exact names of the custom indicators you wish to use in calculation (I mean, they are not called "indicator1", "indicator2" and "indicator3", aren't they)?

You have to replace that names with the exact names of the indicators you wish to use in a iCustom() call, or else it will do nothing. Also, your start function should look like this (again, you have to replace the names with real names) :

int start()

{

if(Bars<=1) return(0);

int ExtCountedBars=IndicatorCounted();

if (ExtCountedBars<0) return(-1);

if (ExtCountedBars>0) ExtCountedBars--;

int pos=Bars-1;

if(ExtCountedBars>1) pos=Bars-ExtCountedBars-1;

while(pos>=0)

{

ExtMapBuffer1[pos] = (iCustom(NULL,0,"indicator1",length,0,pos)+

iCustom(NULL,0,"indicator2",length,0,pos)+

iCustom(NULL,0,"indicator3",length,0,pos))/3.0;

}

return(0);

}
 

Thank's Mladen, The exact name is "indicator1" for the first indicator ,"indicator2"for the second and finally " indicator3" for the final. This what you want ?

 
bixwin:
Thank's Mladen, The exact name is "indicator1" for the first indicator ,"indicator2"for the second and finally " indicator3" for the final. This what you want ?

bixwin

Please see the code for start function in the previous post of mine

 

Thanks Mladen for your quick reply,

it don't work,

i thinks the start fonction is not good

Can you post an exemple of 3 custom indicator ?

 
bixwin:
Thanks Mladen for your quick reply,

it don't work,

i thinks the start fonction is not good

Can you post an exemple of 3 custom indicator ?

bixwind,

I do not know what do the "indicator1", "indicator2" and "indicator3" do. Made these that actually only calculate a moving average and used them in the _test indicator (that does that median calculation you started from) and it works OK (see how it looks on the terminal). So if the parameters for your custom indicators are OK, it should work OK, since the test indicator works OK too

Files:
_test.mq4  1 kb
test.gif  41 kb
 

Thanks a lot Mladen it work !!!

 

Hi, kinda new to mt4 coding and need some help.

How to display currency and timeframe label like these at bottom left corner:-

The timeframe label will also change if i move from other timeframe.

Files:
eu1.png  64 kb
eu2.png  43 kb
 
cawat:
Hi, kinda new to mt4 coding and need some help.

How to display currency and timeframe label like these at bottom left corner:-

The timeframe label will also change if i move from other timeframe.

cawat

This one will do that. You can specify various properties of the time-symbol label using parameters

Files:
 
mladen:
Marco regarding EA building - see these threads :
https://www.mql5.com/en/forum/173136

https://www.mql5.com/en/forum/173171

Dear MLaden,

Thx so far for the help, keep in contact.

Regards Marco