Pine editor tradingview indicator to PRT
Forums › ProRealTime English forum › ProBuilder support › Pine editor tradingview indicator to PRT
- This topic has 1 reply, 2 voices, and was last updated 7 months ago by Iván.
Viewing 2 posts - 1 through 2 (of 2 total)
-
-
01/28/2024 at 10:15 PM #2269871234567891011121314151617181920212223242526272829303132333435363738394041//@version=4study("TN Alerts v13", overlay=true)// This indicator is designed to run with period setting "week"// Settings Inputs SectiontsPercent= input(defval = 20, title = "Trailing Stop")/100wma4_sw = input(true, title="Display wma4")wma62_sw = input(true, title="Display wma62")TSswitch = input(true, title="Display Stoploss")BGswitch = input(true, title="Display BG Color")REswitch = input(true, title="Display Re-entry?")// Calculation Sectionenterlong = (wma(close,62)>wma(close,62)[1]) and (close>wma(close,4)) and (close[1]>wma(close,4)[1]) and (close>close[1])entershort = (wma(close,62)<wma(close,62)[1]) and (close<wma(close,4)) and (close[1]<wma(close,4)[1]) and (close<close[1])trail_top = float(na)trail_top := (close>trail_top[1]) or (close<trail_top[1]*(1-tsPercent)) or (entershort)?close:na(trail_top[1])?close:trail_top[1]plot(trail_top)trail_bot = float(na)trail_bot := (close<trail_bot[1]) or (close>trail_bot[1]*(1+tsPercent)) or (enterlong)?close:na(trail_bot[1])?close:trail_bot[1]exitlong = trail_top<trail_top[1]exitshort = trail_bot>trail_bot[1]inlong = bool(na)inlong := enterlong?true:(entershort or exitlong)?false:inlong[1]inshort = bool(na)inshort := entershort?true:(enterlong or exitshort)?false:inshort[1]// Output sectionplot(wma4_sw ? wma(close,4) : na, title="WMA 4", color=color.blue, linewidth=2)plot(wma62_sw ? wma(close,62) : na, title="WMA 62", color=color.purple, linewidth=2)plot(inlong and TSswitch?trail_top * (1-tsPercent):na, title="Trading Stop Long", linewidth=4, style=plot.style_circles,color=color.red)plot(inshort and TSswitch?trail_bot * (1+tsPercent):na, title="Trading Stop Short", linewidth=4, style=plot.style_circles,color=color.green)bgcolor(BGswitch and inlong ? color.new(color.green, 85) : na, title="Background Long Period")bgcolor(BGswitch and inshort ? color.new(color.red, 85) : na, title="Background Short Period")plotshape(enterlong and not inlong[1], title="Buy Signal", color=color.green, style=shape.arrowup, text="Buy", location=location.belowbar, offset=0, size=size.small)plotshape(entershort and not inshort[1], title="Sell Signal", color=color.red, style=shape.arrowdown, text="Sell", location=location.abovebar, offset=0, size=size.small)plotshape(exitlong and inlong[1] and not entershort, title="Stoploss Long Signal", color=color.black, style=shape.triangledown, text="Buy Exit", location=location.abovebar, offset=0, size=size.small)plotshape(exitshort and inshort[1] and not enterlong, title="Stoploss Short Signal", color=color.black, style=shape.triangleup, text="Sell Exit", location=location.belowbar, offset=0, size=size.small)plotshape(REswitch and enterlong and inlong and inlong[1], title="Re-entry Long signal" ,color=color.aqua, style=shape.arrowup, text="RE", location=location.belowbar, offset=0, size=size.small)plotshape(REswitch and entershort and inshort and inshort[1], title="Re-entry Short signal" ,color=color.silver, style=shape.arrowdown, text="RES", location=location.abovebar, offset=0, size=size.small)// Alert section Create 'Alert' see also https://uk.tradingview.com/pine-script-reference/v4/#fun_alertconditionalertcondition(enterlong and not inlong[1] or exitshort and inshort[1] , title="There is a Buy- or STOPLOSS SHORT Signal", message="Buy/STOPLOSS SHORT signal! \n{{exchange}}:{{ticker}}, price= {{'Source'}}\n{{time}}, volume= {{volume}}")alertcondition(entershort and not inshort[1] or exitlong and inlong[1] , title="There is a Sell- or STOPLOSS LONG Signal", message="Sell/STOPLOSS LONG signal! \n{{exchange}}:{{ticker}}, price={{'Source'}}\n{{time}}, volume= {{volume}}")plot(close)03/11/2024 at 10:00 AM #229582
Good morning
//PRC_TN alerts123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081//PRC_TN alerts//version = 0//11.03.24//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//inputsTS = 20 //% Trailing stopTSswitch = 1 // Display StoplossBGswitch = 1 // Display BG colorREswtich = 1 // Display Re-entry////wma62 = average[62,2](close)wma4 = average[4,2](close)tsPercent = TS/100 //Trailing stopenterlong = wma62>wma62[1] and close>wma4 and close[1]>wma4[1] and close>close[1]entershort = wma62<wma62[1] and close<wma4 and close[1]<wma4[1] and close<close[1]//(close>trail_top[1]) or (close<trail_top[1]*(1-tsPercent)) or (entershortonce trailTop = closeif close>trailtop[1] or close<trailtop[1]*(1-tspercent) or entershort thentrailTop = closeelsetrailTop = trailTop[1]endif//trail_bot := (close<trail_bot[1]) or (close>trail_bot[1]*(1+tsPercent)) or (enterlong)?close:na(trail_bot[1])?close:trail_bot[1]once trailBot = closeif close<trailBot[1] or close>trailBot[1]*(1+tspercent) or enterlong thentrailBot = closeelsetrailBot = trailBot[1]endifexitlong = trailTop < trailTop[1]exitsh = trailBot > trailBot[1]if enterlong theninlong = 1elsif entershort or exitlong theninlong = 0elseinlong = inlong[1]endifif entershort theninshort = 1elsif enterlong or exitsh theninshort = 0elseinshort = inshortendif////Drawing trailsif inlong and Tsswitch thendrawpoint(barindex,TrailTop*(1-tspercent),3)coloured("red")elsif inshort and Tsswitch thendrawpoint(barindex,TrailBot*(1+tspercent),3)coloured("green")endif////Background colorsif inlong and BGswitch thenbackgroundcolor("green",15)elsif inshort and BGswitch thenbackgroundcolor("red",15)endif////Plot signalsif enterlong and not inlong[1] thendrawarrowup(barindex,low-0.25*tr)coloured("green")elsif entershort and not inshort[1] thendrawarrowdown(barindex,high+0.25*tr)coloured("red")elsif REswtich and enterlong and inlong and inlong[1] thendrawarrowup(barindex,low-0.25*tr)coloured("blue",85)elsif REswtich and entershort and inshort and inshort[1] thendrawarrowdown(barindex,high+0.25*tr)coloured("gray",85)elsif exitlong and inlong[1] and not entershort thendrawtext("▼",barindex,high+0.25*tr)coloured("black")elsif exitsh and inshort[1] and not enterlong thendrawtext("▲",barindex,low-0.25*tr)coloured("black")endifreturn wma4 as "WMA4"coloured("blue"), wma62 as "WMA62"coloured("purple") -
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
Find exclusive trading pro-tools on
Similar topics: