#### ulle73

##### New member
Ive seen tradingrush´s other indicators have been converted to TOS, anyone able to convert this one? Code:
``````// Created By Trading Rush

//@version=4

study(title="Trading Rush Discount - 1Day Index/Stocks", shorttitle="Trading Rush Discount - 1Day Index/Stocks", resolution="D")

emily = ema(close, 200)

hi = 0.0

if high > hi

hi := high

if high < hi

hi := hi

per1= (close*100)/hi

p90 = 0

p80 = 0

p70 = 0

p50 = 0

p30 = 0

p20 = 0

slot1=0

slot2=0

slot3=0

slot4=0

slot5=0

if (per1 <= 10 and close<emily)

p90 := 1

if (per1 <= 20 and close<emily)

p80 := 1

if (per1 <= 30 and close<emily)

p70 := 1

if (per1 <= 50 and close<emily)

p50 := 1

if (per1 <= 70 and close<emily)

p30 := 1

if (per1 <= 80 and close<emily)

p20 := 1

color00 = color.rgb(235, 235, 235, 100)

color0 = color.rgb(235, 235, 235, 70)

color1 = color.rgb(255, 226, 64)

color2 = color.rgb(255, 142, 37)

color3 = color.rgb(54, 194, 89)

color4 = color.rgb(38, 136, 63)

color5 = color.rgb(26, 94, 43)

color6 = color.rgb(1, 5, 2)

bars = if(p90 == 1)

color6

else if(p80 == 1)

color5

else if(p70 == 1)

color4

else if(p50 == 1)

color3

else if(p30 == 1)

color2

else if(p20 == 1)

color1

else

color0

fast = ema(close, 12)

slow = ema(close, 26)

macd = fast - slow

signal = ema(macd, 9)

shouldPlotColor = if(macd>signal and macd<signal and macd<0 and signal<0 and p90 == 1 and macd<signal and macd<signal and macd<signal and macd<signal)

color6

else if(macd>signal and macd<signal and macd<0 and signal<0 and p80 == 1 and macd<signal and macd<signal and macd<signal and macd<signal)

color5

else if(macd>signal and macd<signal and macd<0 and signal<0 and p70 == 1 and macd<signal and macd<signal and macd<signal and macd<signal)

color4

else if(macd>signal and macd<signal and macd<0 and signal<0 and p50 == 1 and macd<signal and macd<signal and macd<signal and macd<signal)

color3

else if(macd>signal and macd<signal and macd<0 and signal<0 and p30 == 1 and macd<signal and macd<signal and macd<signal and macd<signal)

color2

else if(macd>signal and macd<signal and macd<0 and signal<0 and p20 == 1 and macd<signal and macd<signal and macd<signal and macd<signal)

color1

else

color00

plot(per1, title="Discount", style=plot.style_area, color=bars, linewidth=2)

plotshape(per1+20, style=shape.triangleup, location=location.absolute, size=size.tiny, color=p20 ? shouldPlotColor : na)

plotshape(per1+40, style=shape.triangleup, location=location.absolute, size=size.small, color=p30 ? shouldPlotColor : na)

plotshape(per1+60, style=shape.triangleup, location=location.absolute, size=size.normal, color=p50 ? shouldPlotColor : na)

plotshape(per1+80, style=shape.triangleup, location=location.absolute, size=size.large, color=p70 ? shouldPlotColor : na)

plotshape(per1+100, style=shape.triangleup, location=location.absolute, size=size.huge, color=p80 ? shouldPlotColor : na)

plotshape(per1+120, style=shape.triangleup, location=location.absolute, size=size.huge, color=p90 ? shouldPlotColor : na)

n1 = input(title="1st Tier Discount Invest Amount", type=input.integer, defval=100, minval=1)

n2 = input(title="2nd Tier Discount Invest Amount", type=input.integer, defval=200, minval=1)

n3 = input(title="3rd Tier Discount Invest Amount", type=input.integer, defval=300, minval=1)

n4 = input(title="4th Tier Discount Invest Amount", type=input.integer, defval=400, minval=1)

n5 = input(title="5th Tier Discount Invest Amount", type=input.integer, defval=500, minval=1)

n6 = input(title="6th Tier Discount Invest Amount", type=input.integer, defval=600, minval=1)

totalinvestedamount = 0.0

totalnumshares = 0.0

if (totalinvestedamount != 0.0)

totalinvestedamount:= totalinvestedamount

totalnumshares := totalnumshares

startDate = input(title="Start Date", type=input.integer,

defval=1, minval=1, maxval=31, group = "Extra")

startMonth = input(title="Start Month", type=input.integer,

defval=1, minval=1, maxval=12, group = "Extra")

startYear = input(title="Start Year", type=input.integer,

defval=1500, minval=1500, maxval=9900, group = "Extra")

endDate = input(title="End Date", type=input.integer,

defval=1, minval=1, maxval=31, group = "Extra")

endMonth = input(title="End Month", type=input.integer,

defval=1, minval=1, maxval=12, group = "Extra")

endYear = input(title="End Year", type=input.integer,

defval=9900, minval=1500, maxval=9900, group = "Extra")

inDateRange = (time >= timestamp(syminfo.timezone, startYear,

startMonth, startDate, 0, 0)) and

(time < timestamp(syminfo.timezone, endYear, endMonth, endDate, 0, 0))

totalinvestedamount := if(macd>signal and macd<signal and macd<0 and signal<0 and p90 == 1 and macd<signal and macd<signal and macd<signal and macd<signal and inDateRange)

totalinvestedamount+n6

else if(macd>signal and macd<signal and macd<0 and signal<0 and p80 == 1 and macd<signal and macd<signal and macd<signal and macd<signal and inDateRange)

totalinvestedamount+n5

else if(macd>signal and macd<signal and macd<0 and signal<0 and p70 == 1 and macd<signal and macd<signal and macd<signal and macd<signal and inDateRange)

totalinvestedamount+n4

else if(macd>signal and macd<signal and macd<0 and signal<0 and p50 == 1 and macd<signal and macd<signal and macd<signal and macd<signal and inDateRange)

totalinvestedamount+n3

else if(macd>signal and macd<signal and macd<0 and signal<0 and p30 == 1 and macd<signal and macd<signal and macd<signal and macd<signal and inDateRange)

totalinvestedamount+n2

else if(macd>signal and macd<signal and macd<0 and signal<0 and p20 == 1 and macd<signal and macd<signal and macd<signal and macd<signal and inDateRange)

totalinvestedamount+n1

else

totalinvestedamount

totalnumshares := if(macd>signal and macd<signal and macd<0 and signal<0 and p90 == 1 and macd<signal and macd<signal and macd<signal and macd<signal and inDateRange)

totalnumshares+(n6/close)

else if(macd>signal and macd<signal and macd<0 and signal<0 and p80 == 1 and macd<signal and macd<signal and macd<signal and macd<signal and inDateRange)

totalnumshares+(n5/close)

else if(macd>signal and macd<signal and macd<0 and signal<0 and p70 == 1 and macd<signal and macd<signal and macd<signal and macd<signal and inDateRange)

totalnumshares+(n4/close)

else if(macd>signal and macd<signal and macd<0 and signal<0 and p50 == 1 and macd<signal and macd<signal and macd<signal and macd<signal and inDateRange)

totalnumshares+(n3/close)

else if(macd>signal and macd<signal and macd<0 and signal<0 and p30 == 1 and macd<signal and macd<signal and macd<signal and macd<signal and inDateRange)

totalnumshares+(n2/close)

else if(macd>signal and macd<signal and macd<0 and signal<0 and p20 == 1 and macd<signal and macd<signal and macd<signal and macd<signal and inDateRange)

totalnumshares+(n1/close)

else

totalnumshares

averageprice = totalinvestedamount/totalnumshares

enableavg = input(false, "Average Price", type = input.bool, group = "Extra")

enabletotalnumshares = input(false, "Total Num Of Shares", type = input.bool, group = "Extra")

enabletotalinvestedamount = input(false, "Total Invested Amount", type = input.bool, group = "Extra")

plot(enabletotalnumshares ? totalnumshares : na, title="Total Num Of Shares", color=color.orange)

plot(enabletotalinvestedamount ? totalinvestedamount : na, title="Total Invested Amount", color=color.red)

plot(enableavg ? averageprice : na, title="Average Price", color=color.green)`````` ## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?