Coding help - page 110

 

Hi,

i need two indicators, one is wpr (Williams' Percent Range) and its ma (wpr with ma), the other is cmo (chande momentum osc.)

and its ma (cmo with ma),

anyone help?

Thanks

 
anonimm:
Hi,

i need two indicators, one is wpr (Williams' Percent Range) and its ma (wpr with ma), the other is cmo (chande momentum osc.)

and its ma (cmo with ma),

anyone help?

Thanks

anonimm

Here is one WPR with an average (ma)

Files:
wpr_ma.mq4  2 kb
 
mladen:
anonimm Here is one WPR with an average (ma)

Thank you Mladen,

i m trying for cmo's ma but i got error (iCMO function not defined)..can you help..? cmo is attached

//---- indicator settings

#property indicator_separate_window

#property indicator_buffers 2

#property indicator_color1 Silver

#property indicator_color2 Red

#property indicator_width1 2

#property indicator_width2 2

//---- indicator parameters

extern int CMO_Period=21;

extern int MA_Period=14;

extern string m = "--Moving Average Types--";

extern string m0 = " 0 = SMA";

extern string m1 = " 1 = EMA";

extern string m2 = " 2 = SMMA";

extern string m3 = " 3 = LWMA";

extern int MA_Type=1;

//---- indicator buffers

double CMO_Buffer[];

double MA_Buffer[];

double iCMO[];

int MA_Mode;

string strMAType;

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

//| Custom indicator initialization function |

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

int init()

{

//---- drawing settings

SetIndexStyle(0,DRAW_LINE);

SetIndexStyle(1,DRAW_LINE);

SetIndexDrawBegin(1,CMO_Period);

IndicatorDigits(Digits+1);

//---- indicator buffers mapping

SetIndexBuffer(0,CMO_Buffer);

SetIndexBuffer(1,MA_Buffer);

//---- name for DataWindow and indicator subwindow label

switch (MA_Type)

{

case 1: strMAType="EMA"; MA_Mode=MODE_EMA; break;

case 2: strMAType="SMMA"; MA_Mode=MODE_SMMA; break;

case 3: strMAType="LWMA"; MA_Mode=MODE_LWMA; break;

default: strMAType="SMA"; MA_Mode=MODE_SMA; break;

}

IndicatorShortName( "CMO" + " (" + CMO_Period + ") " + " : " + strMAType+ " (" +MA_Period + ") ");

SetIndexLabel(0,"CMO" + " (" +CMO_Period + ") ");

SetIndexLabel(1,strMAType+ " (" + MA_Period + ") ");

//---- initialization done

return(0);

}

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

//| Moving Averages Convergence/Divergence |

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

int start()

{

int limit;

int counted_bars=IndicatorCounted();

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

if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

//---- CMO counted in the 1-st buffer

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

CMO_Buffer=iCMO(NULL,0,CMO_Period,i);

//---- MA line counted in the 2-nd buffer

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

MA_Buffer=iMAOnArray(CMO_Buffer,Bars,MA_Period,0,MA_Mode,i);

//---- done

return(0);

}

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

Files:
cmo.mq4  6 kb
 

Mladen, can you help me to found the errors?

#property indicator_separate_window

#property indicator_buffers 2

#property indicator_color2 Red

//----

double UpperBuf[];

double UpperBuf1[];

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

//| |

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

void init()

{

SetIndexStyle(0, DRAW_NONE, STYLE_SOLID, 1);

//----

SetIndexDrawBegin(0, N);

//----

SetIndexBuffer(0, UpperBuf);

SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 1);

//----

SetIndexDrawBegin(1, N);

//----

SetIndexBuffer(1, UpperBuf1);

}

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

//| |

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

void deinit()

{

//----

}

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

//| |

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

void start()

{

int counted = IndicatorCounted();

//----

if(counted < 0)

return (-1);

//----

if(counted > 0)

counted--;

int limit = Bars - counted;

//----

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

{

UpperBuf= ((High/Close)-34)*Volume;

UpperBuf1= iMAOnArray(UpperBuf,0,33,0,MODE_EMA,i);

}

}

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

 
anonimm:
Thank you Mladen,

i m trying for cmo's ma but i got error (iCMO function not defined)..can you help..? cmo is attached

//---- indicator settings

#property indicator_separate_window

#property indicator_buffers 2

#property indicator_color1 Silver

#property indicator_color2 Red

#property indicator_width1 2

#property indicator_width2 2

//---- indicator parameters

extern int CMO_Period=21;

extern int MA_Period=14;

extern string m = "--Moving Average Types--";

extern string m0 = " 0 = SMA";

extern string m1 = " 1 = EMA";

extern string m2 = " 2 = SMMA";

extern string m3 = " 3 = LWMA";

extern int MA_Type=1;

//---- indicator buffers

double CMO_Buffer[];

double MA_Buffer[];

double iCMO[];

int MA_Mode;

string strMAType;

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

//| Custom indicator initialization function |

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

int init()

{

//---- drawing settings

SetIndexStyle(0,DRAW_LINE);

SetIndexStyle(1,DRAW_LINE);

SetIndexDrawBegin(1,CMO_Period);

IndicatorDigits(Digits+1);

//---- indicator buffers mapping

SetIndexBuffer(0,CMO_Buffer);

SetIndexBuffer(1,MA_Buffer);

//---- name for DataWindow and indicator subwindow label

switch (MA_Type)

{

case 1: strMAType="EMA"; MA_Mode=MODE_EMA; break;

case 2: strMAType="SMMA"; MA_Mode=MODE_SMMA; break;

case 3: strMAType="LWMA"; MA_Mode=MODE_LWMA; break;

default: strMAType="SMA"; MA_Mode=MODE_SMA; break;

}

IndicatorShortName( "CMO" + " (" + CMO_Period + ") " + " : " + strMAType+ " (" +MA_Period + ") ");

SetIndexLabel(0,"CMO" + " (" +CMO_Period + ") ");

SetIndexLabel(1,strMAType+ " (" + MA_Period + ") ");

//---- initialization done

return(0);

}

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

//| Moving Averages Convergence/Divergence |

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

int start()

{

int limit;

int counted_bars=IndicatorCounted();

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

if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

//---- CMO counted in the 1-st buffer

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

CMO_Buffer=iCMO(NULL,0,CMO_Period,i);

//---- MA line counted in the 2-nd buffer

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

MA_Buffer=iMAOnArray(CMO_Buffer,Bars,MA_Period,0,MA_Mode,i);

//---- done

return(0);

}

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

Here you go PS : it is a standalone version, no need for the cmo

Files:
cmo_ma.mq4  2 kb
 
k3rn3l:
Mladen, can you help me to found the errors?

#property indicator_separate_window

#property indicator_buffers 2

#property indicator_color2 Red

//----

double UpperBuf[];

double UpperBuf1[];

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

//| |

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

void init()

{

SetIndexStyle(0, DRAW_NONE, STYLE_SOLID, 1);

//----

SetIndexDrawBegin(0, N);

//----

SetIndexBuffer(0, UpperBuf);

SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 1);

//----

SetIndexDrawBegin(1, N);

//----

SetIndexBuffer(1, UpperBuf1);

}

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

//| |

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

void deinit()

{

//----

}

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

//| |

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

void start()

{

int counted = IndicatorCounted();

//----

if(counted < 0)

return (-1);

//----

if(counted > 0)

counted--;

int limit = Bars - counted;

//----

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

{

UpperBuf= ((High/Close)-34)*Volume;

UpperBuf1= iMAOnArray(UpperBuf,0,33,0,MODE_EMA,i);

}

}

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

k3rn3l

Try it like this :

#property indicator_separate_window

#property indicator_buffers 1

#property indicator_color1 Red

double UpperBuf[];

double UpperBuf1[];

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

//| |

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

void init()

{

IndicatorBuffers(2);

SetIndexBuffer(0, UpperBuf1);

SetIndexBuffer(1, UpperBuf);

}

void deinit() {}

void start()

{

int counted = IndicatorCounted();

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

if(counted > 0) counted--;

int limit = Bars - counted;

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

if (Close!=0)

UpperBuf= ((High/Close)-34)*Volume;

else UpperBuf= 0;

for( i = 0; i < limit; i++) UpperBuf1= iMAOnArray(UpperBuf,0,33,0,MODE_EMA,i);

}
 

Dear Mladen;

Thank you again for wpr ma and cmo ma indics. Lets assume that for first indic i set the wpr per to a, ma per to b, and for second indic cmo range to c and ma per to d. i would like to buy when wpr crosses its ma (while wpr>level x) and cmo crosses its ma (while cmo>level y) at THE SAME MINUTE/BAR. (here is important , two conditions have to occur at the same time), and sell reverse conditions.

is it possible?

 
anonimm:
Dear Mladen;

Thank you again for wpr ma and cmo ma indics. Lets assume that for first indic i set the wpr per to a, ma per to b, and for second indic cmo range to c and ma per to d. i would like to buy when wpr crosses its ma (while wpr>level x) and cmo crosses its ma (while cmo>level y) at THE SAME MINUTE/BAR. (here is important , two conditions have to occur at the same time), and sell reverse conditions.

is it possible?

Yes

it is possible

Use iCustom() to check the conditions you are looking for and the you can combine conditions from whatever number of custom indicators you use into one signal.

 

Can anyone help me fix this indicator for over 950 countbars?

Files:
 
YSCWL:
Can anyone help me fix this indicator for over 950 countbars?

Try it out

Files:
Reason: