NexusFi: Find Your Edge


Home Menu

 





thinkorswim pinescript to thinkscript


Discussion in Platforms and Indicators

Updated
    1. trending_up 2,456 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 0 posts
    2. attach_file 0 attachments




 
Search this Thread

thinkorswim pinescript to thinkscript

  #1 (permalink)
jaimeyr
Chelmsford MA
 
Posts: 1 since Apr 2020
Thanks Given: 0
Thanks Received: 0

Can some one convert this to thinkscript (from pinescript). Very useful indicator.

study(title="Trend Trading", shorttitle="Trend 35", overlay=true)


MAlength = input(35, title="Length of Moving Averages")

petd = ema(close, MAlength)
petx = wma(close, MAlength)
pety = sma(close, MAlength)

iGreen=(close > petd) and (close > petx) and (close > pety)
iBlue = ((close > petd) or (close > petx) or (close > pety)) and not ((close > petd) and (close > petx) and (close > pety)) and not ((close < petd) and (close < petx) and (close < pety))
iRed = (close < petd) and (close < petx) and (close < pety)

up = (close > petd) and (close > petx) and (close > pety) ? green : (close > petd) or (close > petx) or (close > pety) ? blue : red
test = (petd + petx + pety) /3
//plot(out2 and smaplot ? out2 :na , title="SMA", color=mycolor2, linewidth=1)
plot(test, title="Buy Sell", color= white )

barcolor(up)

alertcondition(iRed,"Going Red","Going Red")
alertcondition(iGreen,"Going Green ","Going Green" )
alertcondition(iBlue,"Going Blue","Going Blue")

conditioncrossover=crossover(test, close)
conditioncrossunder=crossunder(test, close)
alertcondition(conditioncrossover,"Crossing Up","Crossing Up")
alertcondition(conditioncrossunder,"Crossing Down","Crossing Down")

plot(petd, color= blue , title="Blue Plot")
plot(petx, color= yellow , title="Yellow Plot")
plot(pety, color= red , title="Red Plot")

petyMulti = pety + test- ((pety + test /100) * 12)
petyMulti2 = (open + close) / 2 // pety + test
//Decrease = Original Number - New Number
//% Decrease = Decrease ÷ Original Number × 100


//Increase = New Number - Original Number
//% increase = Increase ÷ Original Number × 100.



buy = (petx > petd) and (petd> pety)
sell = (pety > petd) and (petd> petx)
//v(petd> pety)

tbuy=test - pety
t2buy= (tbuy / test)*100

CurrentMA= sma(close, 50)
LastMA = CurrentMA[1]

Last5Avg= (CurrentMA[3]+CurrentMA[4]+CurrentMA[5]+CurrentMA[6]+CurrentMA[7]) /5

samIncrese=CurrentMA-LastMA
samPercIncrese=(samIncrese/CurrentMA )* 100


samDecrease=LastMA - CurrentMA
samPercDecrease=(samDecrease/LastMA )* 100

LastAvgDec= Last5Avg-CurrentMA
LastAvgPercDecrease=(LastAvgDec/Last5Avg )* 100

LastAvgInc= CurrentMA-Last5Avg
LastAvgPercIncrease=(CurrentMA/Last5Avg )* 100



//Simple Buysell
//plotshape(buy, title= "Buy", location=location.belowbar, color=lime, style=shape.arrowup, text="")
//plotshape(sell, title= "Sell", location=location.abovebar, color=red, style=shape.arrowdown, text="")



//SMA Buy Sell
///plotshape(samPercIncrese>.005 and true, title= "Buy", location=location.belowbar, color=lime, style=shape.arrowup, text="")
//plotshape(samPercDecrease>.005 and true , title= "Sell", location=location.abovebar, color=red, style=shape.arrowdown, text="")
//Ttest

plotshape(samPercIncrese>.006 and buy, title= "Buy Arrow", location=location.belowbar, color=lime, style=shape.arrowup, text="")
plotshape(samPercDecrease>.006 and sell , title= "Sell Arrow", location=location.abovebar, color=red, style=shape.arrowdown, text="")



//plotshape(t2 < .3, title= "Sell", location=location.abovebar, color=red, style=shape.arrowdown, text="")

//plotshape(ReversalShort, title= "ReversalShort", location=location.abovebar, color=red, style=shape.arrowdown, text="SELL")

//plot(petyMulti2, color= green , title="Gary Trader Strategy petyMulti")

timeinrange(res, sess) => time(res, sess) != 0

showTimes = input(false, title="Show Closing")


c= iff(showTimes, gray, black)
bgcolor(timeinrange(period, "1530-1900") ? c : na, transp=70)

Reply With Quote




Last Updated on April 10, 2020


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts