#### Miamidog

##### New member

Code:

```
input over_bought = 0;
input over_sold = 0;
input over_sold2 = 0;
input over_bought2 = 0;
def middle = 50;
def middle2 = 50;
input KPeriod = 5;
input DPeriod = 3;
input priceH = high;
input priceL = low;
input priceC = close;
input slowing_period = 2;
input averageType = AverageType.SIMPLE;
input showBreakoutSignals = {default "No", "On FullK", "On FullD", "On FullK & FullD"};
def lowest_k = Lowest(priceL, KPeriod);
def c1 = priceC - lowest_k;
def c2 = Highest(priceH, KPeriod) - lowest_k;
def FastK = if c2 != 0 then c1 / c2 * 100 else 0;
def FullK = MovingAverage(averageType, FastK, slowing_period);
def FullD = MovingAverage(averageType, FullK, DPeriod);
plot OverBought = over_bought;
plot OverSold = over_sold;
plot OverSold2 = over_sold2;
plot OverBought2 = over_bought2;
def upK = FullK crosses above OverSold;
def downK = FullK crosses below OverBought;
def upD = FullD crosses above OverSold;
def downD = FullD crosses below OverBought;
plot UpSignal;
plot DownSignal;
switch (showBreakoutSignals) {
case "No":
UpSignal = Double.NaN;
DownSignal = Double.NaN;
case "On FullK":
UpSignal = if upK then OverSold else Double.NaN;
DownSignal = if downK then OverBought else Double.NaN;
case "On FullD":
UpSignal = if upD then OverSold else Double.NaN;
DownSignal = if downD then OverBought else Double.NaN;
case "On FullK & FullD":
UpSignal = if upK or upD then OverSold else Double.NaN;
DownSignal = if downK or downD then OverBought else Double.NaN;
}
plot data =(if FullD crosses above middle then 2 else 0);
plot data2 =(if FullD crosses below middle then 1 else 0);
```