#// This source code is subject to the terms of the Mozilla Public License 2.0
#/ LNL Scalper Arrows
#// Created by L&L Capital
#indicator("LNL Scalper Arrows",shorttitle = "LNL Scalper Arrows", overlay = true)
# Converted by Sam4Cok@Samer800 - 11/2023 - request from UseThinkScript.com memebr
input showLabel = yes;
input TailSignalType = {"Signal", "SignalBrake", default "None"}; # "Tail Signal Type"
input ScalpSignalType = {default "Signal", "SignalBrake", "None"}; # "Scalp Signal Type"
input HoagieSignalType = {default "Signal", "SignalBrake", "None"}; # "Hoagie Signal Type"
input UmbrellaSignalType = {default "Signal", "SignalBrake", "None"}; # "Umbrella Signal Type"
input showInsideOutsideBars = no;
input TrendStrength = 20; # "Trend Strength"
input PinbarBTWRatio = 2.5; # "PinBar BTW Ratio" (ideal pin bar is 2.0 - 3.0)")
input ATRLength = 7; # "ATR Length"
input RoundNumbersTo = 2; # "Round Numbers To"
input TargetATR = 2.0; # "Target = ATR /"
input StopATR = 1.0; # "Stop = ATR *"
def na = Double.NaN;
#// Functions & Definitons
def iTelo = AbsValue(close - open);
def bPinUp = (((high - low) / (iTelo)) > PinBarBTWRatio) and Max(open, close) < high - ((high - low) / 2);
def bPinDown = (((high - low) / (iTelo)) > PinBarBTWRatio) and Min(open, close) > low + ((high - low) / 2);
def bSignalUp = bPinUp;
def bSignalDown = bPinDown;
def up = if bSignalUp then high else na;
def down = if bSignalDown then high else na;
def greenbar = close > open;
def redbar = close < open;
def ema8 = ExpAverage(close, 8);
def trendd = ExpAverage(close, TrendStrength);
def Kup1 = KeltnerChannels(Length = 21, factor = 1.0).Upper_Band;
def Kdn1 = KeltnerChannels(Length = 21, factor = 1.0).Lower_Band;
def KUP2 = KeltnerChannels(Length = 21, factor = 1.5).Upper_Band;
def KDN2 = KeltnerChannels(Length = 21, factor = 1.5).Lower_Band;
#/ Tail Arrows [Eat The Tail]
def TailUp = if TailSignalType == TailSignalType."Signal" then
bPinUp and hl2[1] > ema8 and high[2] < high[1] and hl2 > ema8 and hl2 > Kup1
else if TailSignalType == TailSignalType."SignalBrake" then
high > up[1] and hl2 > hl2[1] and high[2] < high[1] and hl2[1] > ema8 and hl2 > ema8 and hl2 > Kup1 else na;
def TailDown = if TailSignalType == TailSignalType."Signal" then
bPinDown and hl2[1] < ema8 and low[2] > low[1] and hl2 < ema8 and hl2 < KDN2
else if TailSignalType == TailSignalType."SignalBrake" then
high < down[1] and hl2 < hl2[1] and low[2] > low[1] and hl2[1] < ema8 and hl2 < ema8 and hl2 < KDN2 else na;
plot Tail_Up = if TailUp then low else na; # 'Tail Up'
plot Tail_Dn = if TailDown then high else na; # 'Tail Down'
Tail_Up.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
Tail_Dn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
Tail_Up.SetDefaultColor(Color.DARK_GREEN);
Tail_Dn.SetDefaultColor(Color.DARK_RED);
#// Scalp Arrows [Scallops]
def ScalpUp = if ScalpSignalType == ScalpSignalType."Signal" then
close > open and low < low[1] and high < high[1] and hl2 > trendd
else if ScalpSignalType == ScalpSignalType."SignalBrake" then
close[1] > open[1] and low[1] < low[2] and high[1] < high[2] and hl2[1] > trendd and high > high[1] else na;
def ScalpDown = if ScalpSignalType == ScalpSignalType."Signal" then
close < open and low > low[1] and high > high[1] and hl2 < trendd
else if ScalpSignalType == ScalpSignalType."SignalBrake" then
close[1] < open[1] and low[1] > low[2] and high[1] > high[2] and hl2[1] < trendd and low < low[1] else na;
plot scalp_Up = if ScalpUp then low else na;#,title='Scalp Up'
plot scalp_Dn = if ScalpDown then high else na;#,title='Scalp Down'
scalp_Up.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
scalp_Dn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
scalp_Up.SetDefaultColor(Color.GREEN);
scalp_Dn.SetDefaultColor(Color.RED);
#// Hoagie Arrows [Hoagies]
def HoagieUp = if HoagieSignalType == HoagieSignalType."Signal" then
high < high[1] and low > low[1] and high[1] < high[2] and low[1] > low[2] and hl2 > trendd
else if HoagieSignalType == HoagieSignalType."SignalBrake" then
high[1] < high[2] and low[1] > low[2] and high[2] < high[3] and low[2] > low[3] and high > high[3] and hl2 > trendd else na;
def HoagieDown = if HoagieSignalType == HoagieSignalType."Signal" then
low > low[1] and high < high[1] and low[1] > low[2] and high[1] < high[2] and hl2 < trendd
else if HoagieSignalType == HoagieSignalType."SignalBrake" then
low[1] > low[2] and high[1] < high[2] and low[2] > low[3] and high[2] < high[3] and low < low[3] and hl2 < trendd else na;
plot Hoagie_Up = if HoagieUp then low else na;#,title='Hoagie Up'
plot Hoagie_Dn = if HoagieDown then high else na;#,title='Hoagie Down'
Hoagie_Up.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
Hoagie_Dn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
Hoagie_Up.SetDefaultColor(Color.MAGENTA);
Hoagie_Dn.SetDefaultColor(Color.MAGENTA);
#// Umbrella Arrows [Umbrellas]
def UmbrellaUp = if UmbrellaSignalType == UmbrellaSignalType."Signal" then
(open >= close[1]) and (close >= close[1]) and (high <= high[1]) and (low >= low[1]) and (close[1] > open[1]) and (close - open + close[1]) - (open[1] / high - low + high[1] - low[1]) > 0.5 and (low > trendd)
else if UmbrellaSignalType == UmbrellaSignalType."SignalBrake" then
(open[1] >= close[2]) and (close[1] >= close[2]) and (high[1] <= high[2]) and (low[1] >= low[2]) and (close[2] > open[2]) and (close[1] - open[1] + close[2]) - (open[1] / high[1] - low[1] + high[2] - low[2]) > 0.5 and (low > trendd) else na;
def UmbrellaDown = if UmbrellaSignalType == UmbrellaSignalType."Signal" then
(open <= close[1]) and (close <= close[1]) and (high >= high[1]) and (low <= low[1]) and (close[1] < open[1]) and (close - open + close[1]) - (open[1] / high - low + high[1] - low[1]) > 0.5 and (high < trendd)
else if UmbrellaSignalType == UmbrellaSignalType."SignalBrake" then
(open[1] <= close[2]) and (close[1] <= close[2]) and (high[1] >= high[2]) and (low[1] <= low[2]) and (close[2] < open[2]) and (close[1] - open[1] + close[2]) - (open[1] / high[1] - low[1] + high[2] - low[2]) > 0.5 and (high < trendd) else na;
plot Umbrella_Up = if UmbrellaUp then low else na;#,title='Umbrella Up'
plot Umbrella_Dn = if UmbrellaDown then high else na;#,title='Umbrella Down'
Umbrella_Up.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
Umbrella_Dn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
Umbrella_Up.SetDefaultColor(Color.CYAN);
Umbrella_Dn.SetDefaultColor(Color.CYAN);
#// Inside Outside Bars
def OutUp = greenbar and (high > high[1]) and (low < low[1]) and (close > high[1]) and (open < open[1]) and KUP2;
def OutDn = redbar and (low < low[1]) and (high > high[1]) and (close < low[1]) and (open > open[1]) and KDN2;
AddChartBubble(showInsideOutsideBars and OutUp, low, "OutUp", Color.LiGHT_GREEN, no);
AddChartBubble(showInsideOutsideBars and OutDn,high, "OutDn", Color.LIGHT_RED);
#// Trend Gauge [Enhanced EMA]
def avg = ExpAverage(close,TrendStrength);
def rsi = rsi(Price = close, Length = 30);
def TrendColor = if avg < open and avg < close and rsi > 50 then 1 else
if avg > open and avg > close and rsi < 50 then -1 else 0;
plot avgLine = avg; # "Trend"
avgLine.SetLineWeight(2);
avgLine.AssignValueColor(if TrendColor > 0 then Color.GREEN else
if TrendColor < 0 then Color.RED else Color.GRAY);
#// ATR & Target & Stop Label Calculations
def atr = atr(Length = ATRLength);
def target = atr / TargetATR;
def stop = atr * StopATR;
def rATR = Round(atr, RoundNumbersTo);
def rTarget = Round(target, RoundNumbersTo);
def rStop = Round(stop, RoundNumbersTo);
AddLabel(showLabel, "ATR(" + rATR + ")", Color.YELLOW);
AddLabel(showLabel, "Target(" + rTarget + ")", Color.GREEN);
AddLabel(showLabel, "Stop(" + rStop + ")", Color.RED);
#-- END of CODE