Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- oscillator = rsi(20);
- lowBound = 40;
- highBound = 60;
- oscilMax = 80;
- oscilMin = 20;
- /*
- -------------------------------------------------------------------
- HIGH BOUNDARY of PLOT
- PLOT `oscillator`, fill to zero with color/hatch, then plot
- `highBound` line and fill to zero with Green
- -------------------------------------------------------------------
- */
- // first plot the oscillator
- // if you want color filled zone, use :
- plot(oscillator, "Choppiness Index", colorRed|50, ChartLine, StyleDotted|StyleNoScale|StyleWidth0);
- // if you dont want a color filled zone, use :
- //plot(oscillator, "Choppiness Index", colorLightGray);
- // hatch underneath it
- SetHatchBrush("BackwardDiagonal", colorRed); // hatch zone under index curve
- Plot(highBound, "", colorWhite|255, ChartLine, StyleDotted|StyleNoScale|StyleWidth0); // erase all under `highBound` horiz line
- /*
- -------------------------------------------------------------------
- LOW BOUNDARY of PLOT
- PLOT segments of `lowBound` line where `choppiness` < `lowBound`
- and fill to zero with Green
- (we have to segment so as not to erase the previous plot of
- highbound color fill/hatch)
- -------------------------------------------------------------------
- */
- // determine segments
- a = iff(oscillator <= lowBound, lowBound, 0);
- // if you wish to fill the zone with a single color instead of hatching it,
- // replace following line with : Plot(a, "", colorGreen|55, ChartLine, StyleDotted|StyleNoScale|StyleWidth0);
- // otherwise, use Plot(a, "", colorGreen, ChartLine, StyleDotted|StyleNoScale|StyleWidth0);
- Plot(a, "", colorGreen|50, ChartLine, StyleDotted|StyleNoScale|StyleWidth0);
- // hatch the zone (comment out if you do not want to hatch)
- SetHatchBrush("BackwardDiagonal", colorGreen); // hatch zone under index curve
- // erase all under `oscillator` in the zone where `oscillator` < `lowBound`
- b = iff(oscillator <= lowBound, oscillator, 0);
- Plot(b, "", colorWhite|255, ChartLine, StyleDotted|StyleNoScale|StyleWidth0);
- /*
- -------------------------------------------------------------------
- MAIN CURVE
- Finally, plot the whole curve again, and adapt colors of its
- sections.
- -------------------------------------------------------------------
- */
- // refresh the oscillator line
- plot(oscillator, "Choppiness Index", colorDarkGray);
- // optionally : overwrite lowBound portion with custom color
- testLow = oscillator < lowBound and oscillator[-1] < lowBound; // in order to have fastcross segments colored
- updatecolor(testLow, colorDarkGreen);
- testHigh = oscillator > highBound and oscillator[-1] > highBound; // in order to have fastcross segments colored
- updatecolor(testHigh, colorDarkRed);
- // finally plot the `highBound` and `lowBound` lines
- Plot(highBound, 'high', colorLightGray, ChartLine,StyleDashed); // `highBound` horiz line
- Plot(lowBound, 'low', colorLightGray, ChartLine,StyleDashed);
- // and the oscilMax & oscilMin so as to frame the region
- Plot(oscilMax, "", colorTransparent);
- Plot(oscilMin, "", colorTransparent);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement