#property copyright "IAmRetep"
#property link "https://www.forexfactory.com"
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 clrYellow
#property indicator_width1 4
#property indicator_color2 clrDodgerBlue
#property indicator_width2 4
#property indicator_color3 clrCrimson
#property indicator_width3 4
extern int WPRFast = 9;
extern int WPRSlow = 54;
extern int WPRUpper = 30;
extern int WPRLower = 70;
string LF = "\n";
int ObjCount = 0;
int current = 0;
double Buffer1[];
double Buffer2[];
double Buffer3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
    if (false) ObjectsDeleteAll();
    IndicatorShortName("IndScalpWPR");
    IndicatorDigits(0);
    IndicatorBuffers(3);
    SetIndexBuffer(0, Buffer1);
    SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID);
    SetIndexBuffer(1, Buffer2);
    SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID);
    SetIndexBuffer(2, Buffer3);
    SetIndexStyle(2, DRAW_HISTOGRAM, STYLE_SOLID);
    return(0);
}
//+------------------------------------------------------------------+
int deinit()
{
    if (false) ObjectsDeleteAll();
    return(0);
}
//+------------------------------------------------------------------+
int start()
{
    int i;
    int counted_bars = IndicatorCounted();
    if(counted_bars < 0) return(-1);
    if(counted_bars > 0) counted_bars--;
    i = Bars - counted_bars;
    while (i >= 0)
    {
        current = i;
        YellowBars();
        i--;
    }
    return(0);
}
//+------------------------------------------------------------------+
void YellowBars()
{
    Buffer1[current]= 0==0;
    BlueBars();
    RedBars();
}
//+------------------------------------------------------------------+
void BlueBars()
{
    Buffer2[current]= iWPR(NULL, PERIOD_CURRENT,WPRFast,current) > WPRUpper*(-1) && iWPR(NULL, PERIOD_CURRENT,WPRSlow,current) > WPRUpper*(-1);
}
//+------------------------------------------------------------------+
void RedBars()
{
    Buffer3[current]= iWPR(NULL, PERIOD_CURRENT,WPRFast,current) < WPRLower*(-1)  && iWPR(NULL, PERIOD_CURRENT,WPRSlow,current) < WPRLower*(-1) ;
}
