Jump to content

Can someone fix this indicator? [wpr slow]


Recommended Posts

Hello, I really like the attached indicator, problem is that it behaves differently for bullish blue bars / bearish red bars

 

I think the formulas for blue bars are different than for red bars.

 

I would really like the red bars to behave like blue bars...

 

http://www.4shared.com/file/d9MYfhmR/WPRslow.html

 

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

//| WPRslow.mq4 |

//| |

//| Ramdass - Conversion only |

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

#property copyright "Author - OlegVS"

 

#property indicator_separate_window

#property indicator_minimum -1.000000

#property indicator_maximum 1.000000

#property indicator_buffers 2

#property indicator_color1 Blue

#property indicator_color2 Red

//---- input parameters

extern int P=54;

extern int n1=9;

extern int n2=49;

extern int CountBars=300;

//---- buffers

double Up[];

double Down[];

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

//| Custom indicator initialization function |

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

int init()

{

string short_name;

//---- indicator line

IndicatorBuffers(2);

SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,5,Blue);

SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,5,Red);

SetIndexBuffer(0,Up);

SetIndexBuffer(1,Down);

//----

//----

return(0);

}

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

//| WPRslow |

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

int start()

{

if (CountBars>Bars) CountBars=Bars;

SetIndexDrawBegin(0,Bars-CountBars+P);

SetIndexDrawBegin(1,Bars-CountBars+P);

int i,counted_bars=IndicatorCounted();

double V1,V2;

//----

if(CountBars<=P) return(0);

//---- initial zero

if(counted_bars<1)

{

for(i=1;i<=P;i++) Up[CountBars-i]=0.0;

for(i=1;i<=P;i++) Down[CountBars-i]=0.0;

}

//----

i=CountBars-P-1;

while(i>=0)

{

Down=0.0; Up=0.0;

V1=iWPR(NULL,0,P,i)*iWPR(NULL,0,P,i)/100;

V2=MathCeil(V1);

if (V2<n1) {Up=V2;}

if (V2>n2) {Down=-(V2);}

 

i--;

}

return(0);

}

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

Edited by camisa
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...