Pullback to Moving Average Indicator For ThinkOrSwim
This code created by Pete Hahn.
It plots the Up Arrow when these two conditions are met:
You may change the Moving Average by changing the value of ma1.
Hope this is useful.
This code created by Pete Hahn.
It plots the Up Arrow when these two conditions are met:
- Price pulls back to 20MA
- CCI is below 100.
You may change the Moving Average by changing the value of ma1.
Code:
# Pullback to Moving Average Indicator For ThinkOrSwim by Pete Hahn.
input length = 14;
def price = close + low + high;
def linDev = lindev(price, length);
def CCI = if linDev == 0 then 0 else (price - Average(price, length)) / linDev / 0.015;
def ma1 = Average(close, 20);
def priceAboveMa1 = close > ma1;
def atLeastFiveBarsAboveMa1 = Lowest(priceAboveMa1, 5) > 0;
def firstTouchInFiveBars = atLeastFiveBarsAboveMa1[1] and close < ma1;
plot signal = if firstTouchInFiveBars and CCI < 100 then low else Double.NaN;
signal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
signal.SetDefaultColor(Color.GREEN);
Hope this is useful.
Last edited by a moderator: