freasno, ca usa
Experience: Advanced
Platform: ninja trader
Trading: forex
Posts: 105 since Apr 2013
Thanks Given: 52
Thanks Received: 85
|
input showBands = yes;
input source = close;
input lookback = 60;
input multi = 0.2;
def na = Double.NaN;
def exitLength = RoundUp(lookback / 4, 0);
Script ma {
input src = close;
input len = 15;
def sqLen = Round(sqrt(len), 0);
def wma1 = wma(src, len);
def wma2 = wma(src, len / 2);
def ma = wma(2 * wma2 - wma1, sqLen);
plot out = ma;
}
def tr = TrueRange(high, close, low);
def BBMC = ma(source, lookback);
def rangema = ExpAverage(tr, lookback);
def upperk =BBMC + rangema * multi;
def lowerk = BBMC - rangema * multi;
def col = if source > upperk then 1 else if source < lowerk then -1 else 0;
def ExitHigh = ma(high, exitLength);
def ExitLow = ma(low, exitLength);
def Hlv3 = if source > ExitHigh then 1 else if source < ExitLow then -1 else Hlv3[1];
def sslExit = if Hlv3 < 0 then ExitHigh else ExitLow;
def base_cross_Long = (close > sslExit) and (close[1] <= sslExit[1]);
def base_cross_Short = (sslExit > close) and (sslExit[1] <= close[1]);
def codiff = if base_cross_Long then 1 else if base_cross_Short then -1 else 0;
plot ExitArrowUp = if codiff>0 then low else na;
plot ExitArrowDn = if codiff<0 then low else na;
plot maTrendLine = BBMC; # 'MA Trendline'
plot limitUp = if showBands then upperk else na;
plot limitDn = if showBands then lowerk else na;
maTrendLine.SetLineWeight(2);
maTrendLine.AssignValueColor(if col>0 then Color.CYAN else if col<0 then Color.MAGENTA else Color.GRAY);
limitUp.AssignValueColor(if col>0 then Color.CYAN else if col<0 then Color.MAGENTA else Color.GRAY);
limitDn.AssignValueColor(if col>0 then Color.CYAN else if col<0 then Color.MAGENTA else Color.GRAY);
ExitArrowUp.SetDefaultColor(Color.CYAN);
ExitArrowDn.SetDefaultColor(Color.MAGENTA);
ExitArrowUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
ExitArrowDn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
|