OPEN-SOURCE SCRIPT
ScalpGawd Risk Reward

//version=5
indicator("ScalpGawd Risk Reward", overlay=true)
i_fromDate = input.time(timestamp("2024-02-01T00:00:00"), title="Entry Time")
i_entryPrice = input.float(4000, "Entry Price")
i_slPrice = input.float(3900, "Stop Loss Price")
i_distance = input.int(100, "Horizontal Distance (in Time Units)", group="Styling")
i_entryColor = input.color(color.white, "Entry Line", inline="Entry", group="Styling")
i_entryStyle = input.string("solid", title="", options=["solid", "dotted", "dashed"], inline="Entry", group="Styling")
i_entryWidth = input.int(1, "", inline="Entry", group="Styling")
i_slColor = input.color(color.red, "SL Line", inline="SL", group="Styling")
i_slStyle = input.string("solid", title="", options=["solid", "dotted", "dashed"], inline="SL", group="Styling")
i_slWidth = input.int(2, "", inline="SL", group="Styling")
i_tpColor = input.color(color.green, "TP Line", inline="TP", group="Styling")
i_tpStyle = input.string("solid", title="", options=["solid", "dotted", "dashed"], inline="TP", group="Styling")
i_tpWidth = input.int(2, "", inline="TP", group="Styling")
i_labelSize = input.string("tiny", "Label Size", options=["tiny", "small", "normal"], group="Label")
i_labelOffset = input.int(2, "Label Offset", group="Label")
i_useTP1 = input.bool(true, "1", inline="1", group="Show Take Profit")
i_useTP2 = input.bool(true, "2", inline="1", group="Show Take Profit")
i_useTP3 = input.bool(true, "3", inline="1", group="Show Take Profit")
i_useTP4 = input.bool(true, "4", inline="1", group="Show Take Profit")
i_useTP5 = input.bool(true, "5", inline="1", group="Show Take Profit")
i_useTP6 = input.bool(true, "6", inline="1", group="Show Take Profit")
i_useTP7 = input.bool(true, "7", inline="1", group="Show Take Profit")
i_useTP8 = input.bool(true, "8", inline="1", group="Show Take Profit")
i_useTP9 = input.bool(true, "9", inline="1", group="Show Take Profit")
i_useTP10 = input.bool(true, "10", inline="1", group="Show Take Profit")
var int barDistance = na
if bar_index < 2
barDistance := time - time[1]
else
barDistance := math.min(barDistance, time - time[1])
int distanceInTime = barDistance * i_distance
var line entryLine = na, line.delete(entryLine)
var line stopLossLine = na, line.delete(stopLossLine)
var line tpLine1 = na, line.delete(tpLine1)
var line tpLine2 = na, line.delete(tpLine2)
var line tpLine3 = na, line.delete(tpLine3)
var line tpLine4 = na, line.delete(tpLine4)
var line tpLine5 = na, line.delete(tpLine5)
var line tpLine6 = na, line.delete(tpLine6)
var line tpLine7 = na, line.delete(tpLine7)
var line tpLine8 = na, line.delete(tpLine8)
var line tpLine9 = na, line.delete(tpLine9)
var line tpLine10 = na, line.delete(tpLine10)
var label entryLabel = na, label.delete(entryLabel)
var label slLabel = na, label.delete(slLabel)
var label tpLabel1 = na, label.delete(tpLabel1)
var label tpLabel2 = na, label.delete(tpLabel2)
var label tpLabel3 = na, label.delete(tpLabel3)
var label tpLabel4 = na, label.delete(tpLabel4)
var label tpLabel5 = na, label.delete(tpLabel5)
var label tpLabel6 = na, label.delete(tpLabel6)
var label tpLabel7 = na, label.delete(tpLabel7)
var label tpLabel8 = na, label.delete(tpLabel8)
var label tpLabel9 = na, label.delete(tpLabel9)
var label tpLabel10 = na, label.delete(tpLabel10)
float i_tp1Price = i_entryPrice + (i_entryPrice - i_slPrice)
float i_tp2Price = i_entryPrice + (i_entryPrice - i_slPrice) * 2
float i_tp3Price = i_entryPrice + (i_entryPrice - i_slPrice) * 3
float i_tp4Price = i_entryPrice + (i_entryPrice - i_slPrice) * 4
float i_tp5Price = i_entryPrice + (i_entryPrice - i_slPrice) * 5
float i_tp6Price = i_entryPrice + (i_entryPrice - i_slPrice) * 6
float i_tp7Price = i_entryPrice + (i_entryPrice - i_slPrice) * 7
float i_tp8Price = i_entryPrice + (i_entryPrice - i_slPrice) * 8
float i_tp9Price = i_entryPrice + (i_entryPrice - i_slPrice) * 9
float i_tp10Price = i_entryPrice + (i_entryPrice - i_slPrice) * 10
f_getStyle(_style) =>
ret = line.style_solid
if _style == "dotted"
ret := line.style_dotted
else if _style == "dashed"
ret := line.style_dashed
ret
f_getLabelSize() =>
ret = size.normal
if i_labelSize == "small"
ret := size.small
else if i_labelSize == "tiny"
ret := size.tiny
ret
entryLine := line.new(i_fromDate, i_entryPrice, i_fromDate + distanceInTime, i_entryPrice, xloc=xloc.bar_time, color=i_entryColor, width=i_entryWidth, style=f_getStyle(i_entryStyle))
stopLossLine := line.new(i_fromDate, i_slPrice, i_fromDate + distanceInTime, i_slPrice, xloc=xloc.bar_time, color=i_slColor, width=i_slWidth, style=f_getStyle(i_slStyle))
tpLine1 := i_useTP1 ? line.new(i_fromDate, i_tp1Price, i_fromDate + distanceInTime, i_tp1Price, xloc=xloc.bar_time, color=i_tpColor, width=i_tpWidth, style=f_getStyle(i_tpStyle)) : na
tpLine2 := i_useTP2 ? line.new(i_fromDate, i_tp2Price, i_fromDate + distanceInTime, i_tp2Price, xloc=xloc.bar_time, color=i_tpColor, width=i_tpWidth, style=f_getStyle(i_tpStyle)) : na
tpLine3 := i_useTP3 ? line.new(i_fromDate, i_tp3Price, i_fromDate + distanceInTime, i_tp3Price, xloc=xloc.bar_time, color=i_tpColor, width=i_tpWidth, style=f_getStyle(i_tpStyle)) : na
tpLine4 := i_useTP4 ? line.new(i_fromDate, i_tp4Price, i_fromDate + distanceInTime, i_tp4Price, xloc=xloc.bar_time, color=i_tpColor, width=i_tpWidth, style=f_getStyle(i_tpStyle)) : na
tpLine5 := i_useTP5 ? line.new(i_fromDate, i_tp5Price, i_fromDate + distanceInTime, i_tp5Price, xloc=xloc.bar_time, color=i_tpColor, width=i_tpWidth, style=f_getStyle(i_tpStyle)) : na
tpLine6 := i_useTP6 ? line.new(i_fromDate, i_tp6Price, i_fromDate + distanceInTime, i_tp6Price, xloc=xloc.bar_time, color=i_tpColor, width=i_tpWidth, style=f_getStyle(i_tpStyle)) : na
tpLine7 := i_useTP7 ? line.new(i_fromDate, i_tp7Price, i_fromDate + distanceInTime, i_tp7Price, xloc=xloc.bar_time, color=i_tpColor, width=i_tpWidth, style=f_getStyle(i_tpStyle)) : na
tpLine8 := i_useTP8 ? line.new(i_fromDate, i_tp8Price, i_fromDate + distanceInTime, i_tp8Price, xloc=xloc.bar_time, color=i_tpColor, width=i_tpWidth, style=f_getStyle(i_tpStyle)) : na
tpLine9 := i_useTP9 ? line.new(i_fromDate, i_tp9Price, i_fromDate + distanceInTime, i_tp9Price, xloc=xloc.bar_time, color=i_tpColor, width=i_tpWidth, style=f_getStyle(i_tpStyle)) : na
tpLine10 := i_useTP10 ? line.new(i_fromDate, i_tp10Price, i_fromDate + distanceInTime, i_tp10Price, xloc=xloc.bar_time, color=i_tpColor, width=i_tpWidth, style=f_getStyle(i_tpStyle)) : na
entryLabel := label.new(i_fromDate + barDistance * i_labelOffset, i_entryPrice, text="Entry @ " + str.tostring(i_entryPrice, '#.##'), xloc=xloc.bar_time, yloc=yloc.price, textcolor=i_entryColor, style=label.style_none,textalign = text.align_center, size=f_getLabelSize())
slLabel := label.new(i_fromDate + barDistance * i_labelOffset, i_slPrice, text="Stop Loss " + str.tostring((i_slPrice - i_entryPrice) / syminfo.mintick, "#")+ " Ticks @ " + str.tostring(i_slPrice, '#.##'), xloc=xloc.bar_time, yloc=yloc.price, textcolor=i_slColor, style=label.style_none,textalign = text.align_center, size=f_getLabelSize())
tpLabel1 := i_useTP1 ? label.new(i_fromDate + barDistance * i_labelOffset, i_tp1Price, text="Target 1 " + str.tostring((i_tp1Price - i_entryPrice) / syminfo.mintick, "#")+ " Ticks @ " + str.tostring(i_tp1Price, '#.##'), xloc=xloc.bar_time, yloc=yloc.price, textcolor=i_tpColor, style=label.style_none,textalign = text.align_center, size=f_getLabelSize()) : na
tpLabel2 := i_useTP2 ? label.new(i_fromDate + barDistance * i_labelOffset, i_tp2Price, text="Target 2 " + str.tostring((i_tp2Price - i_entryPrice) / syminfo.mintick, "#")+ " Ticks @ " + str.tostring(i_tp2Price, '#.##'), xloc=xloc.bar_time, yloc=yloc.price, textcolor=i_tpColor, style=label.style_none,textalign = text.align_center, size=f_getLabelSize()) : na
tpLabel3 := i_useTP3 ? label.new(i_fromDate + barDistance * i_labelOffset, i_tp3Price, text="Target 3 " + str.tostring((i_tp3Price - i_entryPrice) / syminfo.mintick, "#")+ " Ticks @ " + str.tostring(i_tp3Price, '#.##'), xloc=xloc.bar_time, yloc=yloc.price, textcolor=i_tpColor, style=label.style_none,textalign = text.align_center, size=f_getLabelSize()) : na
tpLabel4 := i_useTP4 ? label.new(i_fromDate + barDistance * i_labelOffset, i_tp4Price, text="Target 4 " + str.tostring((i_tp4Price - i_entryPrice) / syminfo.mintick, "#")+ " Ticks @ " + str.tostring(i_tp4Price, '#.##'), xloc=xloc.bar_time, yloc=yloc.price, textcolor=i_tpColor, style=label.style_none,textalign = text.align_center, size=f_getLabelSize()) : na
tpLabel5 := i_useTP5 ? label.new(i_fromDate + barDistance * i_labelOffset, i_tp5Price, text="Target 5 " + str.tostring((i_tp5Price - i_entryPrice) / syminfo.mintick, "#")+ " Ticks @ " + str.tostring(i_tp5Price, '#.##'), xloc=xloc.bar_time, yloc=yloc.price, textcolor=i_tpColor, style=label.style_none,textalign = text.align_center, size=f_getLabelSize()) : na
tpLabel6 := i_useTP6 ? label.new(i_fromDate + barDistance * i_labelOffset, i_tp6Price, text="Target 6 " + str.tostring((i_tp6Price - i_entryPrice) / syminfo.mintick, "#")+ " Ticks @ " + str.tostring(i_tp6Price, '#.##'), xloc=xloc.bar_time, yloc=yloc.price, textcolor=i_tpColor, style=label.style_none,textalign = text.align_center, size=f_getLabelSize()) : na
tpLabel7 := i_useTP7 ? label.new(i_fromDate + barDistance * i_labelOffset, i_tp7Price, text="Target 7 " + str.tostring((i_tp7Price - i_entryPrice) / syminfo.mintick, "#")+ " Ticks @ " + str.tostring(i_tp7Price, '#.##'), xloc=xloc.bar_time, yloc=yloc.price, textcolor=i_tpColor, style=label.style_none,textalign = text.align_center, size=f_getLabelSize()) : na
tpLabel8 := i_useTP8 ? label.new(i_fromDate + barDistance * i_labelOffset, i_tp8Price, text="Target 8 " + str.tostring((i_tp8Price - i_entryPrice) / syminfo.mintick, "#")+ " Ticks @ " + str.tostring(i_tp8Price, '#.##'), xloc=xloc.bar_time, yloc=yloc.price, textcolor=i_tpColor, style=label.style_none,textalign = text.align_center, size=f_getLabelSize()) : na
tpLabel9 := i_useTP9 ? label.new(i_fromDate + barDistance * i_labelOffset, i_tp9Price, text="Target 9 " + str.tostring((i_tp9Price - i_entryPrice) / syminfo.mintick, "#")+ " Ticks @ " + str.tostring(i_tp9Price, '#.##'), xloc=xloc.bar_time, yloc=yloc.price, textcolor=i_tpColor, style=label.style_none,textalign = text.align_center, size=f_getLabelSize()) : na
tpLabel10 := i_useTP10 ? label.new(i_fromDate + barDistance * i_labelOffset, i_tp10Price, text="Target 10 " + str.tostring((i_tp10Price - i_entryPrice) / syminfo.mintick, "#")+ " Ticks @ " + str.tostring(i_tp10Price, '#.##'), xloc=xloc.bar_time, yloc=yloc.price, textcolor=i_tpColor, style=label.style_none,textalign = text.align_center, size=f_getLabelSize()) : na
i_showBox = input.bool(true, "Show Background", group="Show Background")
var box greenBox = na, box.delete(greenBox)
var box redBox = na, box.delete(redBox)
f_findHighestTP() =>
ret = i_tp1Price
if i_useTP10
ret := i_tp10Price
else if i_useTP9
ret := i_tp9Price
else if i_useTP8
ret := i_tp8Price
else if i_useTP7
ret := i_tp7Price
else if i_useTP6
ret := i_tp6Price
else if i_useTP5
ret := i_tp5Price
else if i_useTP4
ret := i_tp4Price
else if i_useTP3
ret := i_tp3Price
else if i_useTP2
ret := i_tp2Price
ret
greenBox := i_showBox ? box.new(i_fromDate, i_entryPrice, i_fromDate + distanceInTime, f_findHighestTP(), xloc=xloc.bar_time, bgcolor=color.new(i_tpColor, 70), border_width = 0) : na
redBox := i_showBox ? box.new(i_fromDate, i_entryPrice, i_fromDate + distanceInTime, i_slPrice, xloc=xloc.bar_time, bgcolor=color.new(i_slColor, 70), border_width = 0) : na
indicator("ScalpGawd Risk Reward", overlay=true)
i_fromDate = input.time(timestamp("2024-02-01T00:00:00"), title="Entry Time")
i_entryPrice = input.float(4000, "Entry Price")
i_slPrice = input.float(3900, "Stop Loss Price")
i_distance = input.int(100, "Horizontal Distance (in Time Units)", group="Styling")
i_entryColor = input.color(color.white, "Entry Line", inline="Entry", group="Styling")
i_entryStyle = input.string("solid", title="", options=["solid", "dotted", "dashed"], inline="Entry", group="Styling")
i_entryWidth = input.int(1, "", inline="Entry", group="Styling")
i_slColor = input.color(color.red, "SL Line", inline="SL", group="Styling")
i_slStyle = input.string("solid", title="", options=["solid", "dotted", "dashed"], inline="SL", group="Styling")
i_slWidth = input.int(2, "", inline="SL", group="Styling")
i_tpColor = input.color(color.green, "TP Line", inline="TP", group="Styling")
i_tpStyle = input.string("solid", title="", options=["solid", "dotted", "dashed"], inline="TP", group="Styling")
i_tpWidth = input.int(2, "", inline="TP", group="Styling")
i_labelSize = input.string("tiny", "Label Size", options=["tiny", "small", "normal"], group="Label")
i_labelOffset = input.int(2, "Label Offset", group="Label")
i_useTP1 = input.bool(true, "1", inline="1", group="Show Take Profit")
i_useTP2 = input.bool(true, "2", inline="1", group="Show Take Profit")
i_useTP3 = input.bool(true, "3", inline="1", group="Show Take Profit")
i_useTP4 = input.bool(true, "4", inline="1", group="Show Take Profit")
i_useTP5 = input.bool(true, "5", inline="1", group="Show Take Profit")
i_useTP6 = input.bool(true, "6", inline="1", group="Show Take Profit")
i_useTP7 = input.bool(true, "7", inline="1", group="Show Take Profit")
i_useTP8 = input.bool(true, "8", inline="1", group="Show Take Profit")
i_useTP9 = input.bool(true, "9", inline="1", group="Show Take Profit")
i_useTP10 = input.bool(true, "10", inline="1", group="Show Take Profit")
var int barDistance = na
if bar_index < 2
barDistance := time - time[1]
else
barDistance := math.min(barDistance, time - time[1])
int distanceInTime = barDistance * i_distance
var line entryLine = na, line.delete(entryLine)
var line stopLossLine = na, line.delete(stopLossLine)
var line tpLine1 = na, line.delete(tpLine1)
var line tpLine2 = na, line.delete(tpLine2)
var line tpLine3 = na, line.delete(tpLine3)
var line tpLine4 = na, line.delete(tpLine4)
var line tpLine5 = na, line.delete(tpLine5)
var line tpLine6 = na, line.delete(tpLine6)
var line tpLine7 = na, line.delete(tpLine7)
var line tpLine8 = na, line.delete(tpLine8)
var line tpLine9 = na, line.delete(tpLine9)
var line tpLine10 = na, line.delete(tpLine10)
var label entryLabel = na, label.delete(entryLabel)
var label slLabel = na, label.delete(slLabel)
var label tpLabel1 = na, label.delete(tpLabel1)
var label tpLabel2 = na, label.delete(tpLabel2)
var label tpLabel3 = na, label.delete(tpLabel3)
var label tpLabel4 = na, label.delete(tpLabel4)
var label tpLabel5 = na, label.delete(tpLabel5)
var label tpLabel6 = na, label.delete(tpLabel6)
var label tpLabel7 = na, label.delete(tpLabel7)
var label tpLabel8 = na, label.delete(tpLabel8)
var label tpLabel9 = na, label.delete(tpLabel9)
var label tpLabel10 = na, label.delete(tpLabel10)
float i_tp1Price = i_entryPrice + (i_entryPrice - i_slPrice)
float i_tp2Price = i_entryPrice + (i_entryPrice - i_slPrice) * 2
float i_tp3Price = i_entryPrice + (i_entryPrice - i_slPrice) * 3
float i_tp4Price = i_entryPrice + (i_entryPrice - i_slPrice) * 4
float i_tp5Price = i_entryPrice + (i_entryPrice - i_slPrice) * 5
float i_tp6Price = i_entryPrice + (i_entryPrice - i_slPrice) * 6
float i_tp7Price = i_entryPrice + (i_entryPrice - i_slPrice) * 7
float i_tp8Price = i_entryPrice + (i_entryPrice - i_slPrice) * 8
float i_tp9Price = i_entryPrice + (i_entryPrice - i_slPrice) * 9
float i_tp10Price = i_entryPrice + (i_entryPrice - i_slPrice) * 10
f_getStyle(_style) =>
ret = line.style_solid
if _style == "dotted"
ret := line.style_dotted
else if _style == "dashed"
ret := line.style_dashed
ret
f_getLabelSize() =>
ret = size.normal
if i_labelSize == "small"
ret := size.small
else if i_labelSize == "tiny"
ret := size.tiny
ret
entryLine := line.new(i_fromDate, i_entryPrice, i_fromDate + distanceInTime, i_entryPrice, xloc=xloc.bar_time, color=i_entryColor, width=i_entryWidth, style=f_getStyle(i_entryStyle))
stopLossLine := line.new(i_fromDate, i_slPrice, i_fromDate + distanceInTime, i_slPrice, xloc=xloc.bar_time, color=i_slColor, width=i_slWidth, style=f_getStyle(i_slStyle))
tpLine1 := i_useTP1 ? line.new(i_fromDate, i_tp1Price, i_fromDate + distanceInTime, i_tp1Price, xloc=xloc.bar_time, color=i_tpColor, width=i_tpWidth, style=f_getStyle(i_tpStyle)) : na
tpLine2 := i_useTP2 ? line.new(i_fromDate, i_tp2Price, i_fromDate + distanceInTime, i_tp2Price, xloc=xloc.bar_time, color=i_tpColor, width=i_tpWidth, style=f_getStyle(i_tpStyle)) : na
tpLine3 := i_useTP3 ? line.new(i_fromDate, i_tp3Price, i_fromDate + distanceInTime, i_tp3Price, xloc=xloc.bar_time, color=i_tpColor, width=i_tpWidth, style=f_getStyle(i_tpStyle)) : na
tpLine4 := i_useTP4 ? line.new(i_fromDate, i_tp4Price, i_fromDate + distanceInTime, i_tp4Price, xloc=xloc.bar_time, color=i_tpColor, width=i_tpWidth, style=f_getStyle(i_tpStyle)) : na
tpLine5 := i_useTP5 ? line.new(i_fromDate, i_tp5Price, i_fromDate + distanceInTime, i_tp5Price, xloc=xloc.bar_time, color=i_tpColor, width=i_tpWidth, style=f_getStyle(i_tpStyle)) : na
tpLine6 := i_useTP6 ? line.new(i_fromDate, i_tp6Price, i_fromDate + distanceInTime, i_tp6Price, xloc=xloc.bar_time, color=i_tpColor, width=i_tpWidth, style=f_getStyle(i_tpStyle)) : na
tpLine7 := i_useTP7 ? line.new(i_fromDate, i_tp7Price, i_fromDate + distanceInTime, i_tp7Price, xloc=xloc.bar_time, color=i_tpColor, width=i_tpWidth, style=f_getStyle(i_tpStyle)) : na
tpLine8 := i_useTP8 ? line.new(i_fromDate, i_tp8Price, i_fromDate + distanceInTime, i_tp8Price, xloc=xloc.bar_time, color=i_tpColor, width=i_tpWidth, style=f_getStyle(i_tpStyle)) : na
tpLine9 := i_useTP9 ? line.new(i_fromDate, i_tp9Price, i_fromDate + distanceInTime, i_tp9Price, xloc=xloc.bar_time, color=i_tpColor, width=i_tpWidth, style=f_getStyle(i_tpStyle)) : na
tpLine10 := i_useTP10 ? line.new(i_fromDate, i_tp10Price, i_fromDate + distanceInTime, i_tp10Price, xloc=xloc.bar_time, color=i_tpColor, width=i_tpWidth, style=f_getStyle(i_tpStyle)) : na
entryLabel := label.new(i_fromDate + barDistance * i_labelOffset, i_entryPrice, text="Entry @ " + str.tostring(i_entryPrice, '#.##'), xloc=xloc.bar_time, yloc=yloc.price, textcolor=i_entryColor, style=label.style_none,textalign = text.align_center, size=f_getLabelSize())
slLabel := label.new(i_fromDate + barDistance * i_labelOffset, i_slPrice, text="Stop Loss " + str.tostring((i_slPrice - i_entryPrice) / syminfo.mintick, "#")+ " Ticks @ " + str.tostring(i_slPrice, '#.##'), xloc=xloc.bar_time, yloc=yloc.price, textcolor=i_slColor, style=label.style_none,textalign = text.align_center, size=f_getLabelSize())
tpLabel1 := i_useTP1 ? label.new(i_fromDate + barDistance * i_labelOffset, i_tp1Price, text="Target 1 " + str.tostring((i_tp1Price - i_entryPrice) / syminfo.mintick, "#")+ " Ticks @ " + str.tostring(i_tp1Price, '#.##'), xloc=xloc.bar_time, yloc=yloc.price, textcolor=i_tpColor, style=label.style_none,textalign = text.align_center, size=f_getLabelSize()) : na
tpLabel2 := i_useTP2 ? label.new(i_fromDate + barDistance * i_labelOffset, i_tp2Price, text="Target 2 " + str.tostring((i_tp2Price - i_entryPrice) / syminfo.mintick, "#")+ " Ticks @ " + str.tostring(i_tp2Price, '#.##'), xloc=xloc.bar_time, yloc=yloc.price, textcolor=i_tpColor, style=label.style_none,textalign = text.align_center, size=f_getLabelSize()) : na
tpLabel3 := i_useTP3 ? label.new(i_fromDate + barDistance * i_labelOffset, i_tp3Price, text="Target 3 " + str.tostring((i_tp3Price - i_entryPrice) / syminfo.mintick, "#")+ " Ticks @ " + str.tostring(i_tp3Price, '#.##'), xloc=xloc.bar_time, yloc=yloc.price, textcolor=i_tpColor, style=label.style_none,textalign = text.align_center, size=f_getLabelSize()) : na
tpLabel4 := i_useTP4 ? label.new(i_fromDate + barDistance * i_labelOffset, i_tp4Price, text="Target 4 " + str.tostring((i_tp4Price - i_entryPrice) / syminfo.mintick, "#")+ " Ticks @ " + str.tostring(i_tp4Price, '#.##'), xloc=xloc.bar_time, yloc=yloc.price, textcolor=i_tpColor, style=label.style_none,textalign = text.align_center, size=f_getLabelSize()) : na
tpLabel5 := i_useTP5 ? label.new(i_fromDate + barDistance * i_labelOffset, i_tp5Price, text="Target 5 " + str.tostring((i_tp5Price - i_entryPrice) / syminfo.mintick, "#")+ " Ticks @ " + str.tostring(i_tp5Price, '#.##'), xloc=xloc.bar_time, yloc=yloc.price, textcolor=i_tpColor, style=label.style_none,textalign = text.align_center, size=f_getLabelSize()) : na
tpLabel6 := i_useTP6 ? label.new(i_fromDate + barDistance * i_labelOffset, i_tp6Price, text="Target 6 " + str.tostring((i_tp6Price - i_entryPrice) / syminfo.mintick, "#")+ " Ticks @ " + str.tostring(i_tp6Price, '#.##'), xloc=xloc.bar_time, yloc=yloc.price, textcolor=i_tpColor, style=label.style_none,textalign = text.align_center, size=f_getLabelSize()) : na
tpLabel7 := i_useTP7 ? label.new(i_fromDate + barDistance * i_labelOffset, i_tp7Price, text="Target 7 " + str.tostring((i_tp7Price - i_entryPrice) / syminfo.mintick, "#")+ " Ticks @ " + str.tostring(i_tp7Price, '#.##'), xloc=xloc.bar_time, yloc=yloc.price, textcolor=i_tpColor, style=label.style_none,textalign = text.align_center, size=f_getLabelSize()) : na
tpLabel8 := i_useTP8 ? label.new(i_fromDate + barDistance * i_labelOffset, i_tp8Price, text="Target 8 " + str.tostring((i_tp8Price - i_entryPrice) / syminfo.mintick, "#")+ " Ticks @ " + str.tostring(i_tp8Price, '#.##'), xloc=xloc.bar_time, yloc=yloc.price, textcolor=i_tpColor, style=label.style_none,textalign = text.align_center, size=f_getLabelSize()) : na
tpLabel9 := i_useTP9 ? label.new(i_fromDate + barDistance * i_labelOffset, i_tp9Price, text="Target 9 " + str.tostring((i_tp9Price - i_entryPrice) / syminfo.mintick, "#")+ " Ticks @ " + str.tostring(i_tp9Price, '#.##'), xloc=xloc.bar_time, yloc=yloc.price, textcolor=i_tpColor, style=label.style_none,textalign = text.align_center, size=f_getLabelSize()) : na
tpLabel10 := i_useTP10 ? label.new(i_fromDate + barDistance * i_labelOffset, i_tp10Price, text="Target 10 " + str.tostring((i_tp10Price - i_entryPrice) / syminfo.mintick, "#")+ " Ticks @ " + str.tostring(i_tp10Price, '#.##'), xloc=xloc.bar_time, yloc=yloc.price, textcolor=i_tpColor, style=label.style_none,textalign = text.align_center, size=f_getLabelSize()) : na
i_showBox = input.bool(true, "Show Background", group="Show Background")
var box greenBox = na, box.delete(greenBox)
var box redBox = na, box.delete(redBox)
f_findHighestTP() =>
ret = i_tp1Price
if i_useTP10
ret := i_tp10Price
else if i_useTP9
ret := i_tp9Price
else if i_useTP8
ret := i_tp8Price
else if i_useTP7
ret := i_tp7Price
else if i_useTP6
ret := i_tp6Price
else if i_useTP5
ret := i_tp5Price
else if i_useTP4
ret := i_tp4Price
else if i_useTP3
ret := i_tp3Price
else if i_useTP2
ret := i_tp2Price
ret
greenBox := i_showBox ? box.new(i_fromDate, i_entryPrice, i_fromDate + distanceInTime, f_findHighestTP(), xloc=xloc.bar_time, bgcolor=color.new(i_tpColor, 70), border_width = 0) : na
redBox := i_showBox ? box.new(i_fromDate, i_entryPrice, i_fromDate + distanceInTime, i_slPrice, xloc=xloc.bar_time, bgcolor=color.new(i_slColor, 70), border_width = 0) : na
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, penulis skrip ini telah menjadikannya sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Hormat untuk penulisnya! Meskipun anda dapat menggunakannya secara gratis, ingatlah bahwa penerbitan ulang kode tersebut tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi tidak dimaksudkan untuk menjadi, dan bukan merupakan saran keuangan, investasi, perdagangan, atau rekomendasi lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Persyaratan Penggunaan.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, penulis skrip ini telah menjadikannya sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Hormat untuk penulisnya! Meskipun anda dapat menggunakannya secara gratis, ingatlah bahwa penerbitan ulang kode tersebut tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi tidak dimaksudkan untuk menjadi, dan bukan merupakan saran keuangan, investasi, perdagangan, atau rekomendasi lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Persyaratan Penggunaan.