I wrote this script after reading about the algorithm from a public website but added my own twist. It can be used for scalping.
Dots above and below the signal is the support and resistance levels.
Let me know what you think and how I can improve it.
Dots above and below the signal is the support and resistance levels.
Let me know what you think and how I can improve it.
Code:
# TD Perfection Indicator
# barbaros
# 04.25.2020
# v1.0 - 04.25.2020 - barbaros - Initial release of TD Perfection Indicator
input price = close;
input showbuy = yes;
input showsell = no;
input k = 0; # 0 to 8
input i = 0; # 0 to 13
# Buy Perfection
def BearishPriceTwist = price[9] > price[13] and price[8] < price[12];
def BuySystem = price[k] < price[4+k];
def BuyPerfection = Lowest(price) <= Lowest(price[3]) and Lowest(price) <= Lowest(price[2]);
def BuySupport = Lowest(low[i]);
def BuyResistance = Highest(high[i]);
def BuyProbability = ((price - BuySupport) / (BuyResistance - price)) > 0.60 and ((BuyResistance - price) / (price - BuySupport)) > 0.40;
plot buySignal = if showbuy and BearishPriceTwist and BuySystem and BuyPerfection and BuyProbability and low > BuySupport and price > BuySupport and price < BuyResistance then close else Double.NaN;
buySignal.SetDefaultColor(Color.WHITE);
buySignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
plot buySupportLine = if buySignal then BuySupport else Double.NaN;
buySupportLine.SetDefaultColor(Color.WHITE);
buySupportLine.SetPaintingStrategy(PaintingStrategy.POINTS);
plot buyResistanceLine = if buySignal then BuyResistance else Double.NaN;
buyResistanceLine.SetPaintingStrategy(PaintingStrategy.POINTS);
buyResistanceLine.SetDefaultColor(Color.WHITE);
Alert(buySignal, "Buy Perfection", Alert.BAR, Sound.Bell);
# Sell Perfection
def BullishPriceTwist = price[9] < price[13] and price[8] > price[12];
def SellSystem = price[k] > price[4+k];
def SellPerfection = Highest(price) >= Highest(price[3]) and Highest(price) >= Highest(price[2]);
def SellSupport = Highest(price[i]);
def SellResistance = Lowest(price[i]);
def SellProbability = ((SellSupport - price) / (price - SellResistance)) > 0.60 and ((price - SellResistance) / (SellSupport - price)) > 0.40;
plot sellSignal = if showsell and BullishPriceTwist and SellSystem and SellPerfection and SellProbability and high < SellSupport and price > sellResistance then close else Double.NaN;
sellSignal.SetDefaultColor(Color.WHITE);
sellSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
plot sellSupportLine = if sellSignal then SellSupport else Double.NaN;
sellSupportLine.SetDefaultColor(Color.WHITE);
sellSupportLine.SetPaintingStrategy(PaintingStrategy.POINTS);
plot sellResistanceLine = if sellSignal then SellResistance else Double.NaN;
sellResistanceLine.SetDefaultColor(Color.WHITE);
sellResistanceLine.SetPaintingStrategy(PaintingStrategy.POINTS);
Alert(sellSignal, "Sell Perfection", Alert.BAR, Sound.Bell);
Last edited: