Notifications
Clear all

RT Pullback Setup

1 Posts
1 Users
0 Likes
1,392 Views
joeffrenz
(@joeffrenz)
Posts: 7
Active Member User
Topic starter
 

Saw this trading strategy on one of Rayner Teo's video.
Check this link to know how this strategy works. https://www.youtube.com/watch?v=W8ENIXvcGlQ&t=331s

Below is the VAI Script of this strategy. Feel free to add more parameters like value traded etc.

Copy and paste below code to your script.

 

// RT Pullback
// Public

#Simple Moving Average
Set ma200 = SMA(Close, 200)
Plot(ma200 , Line,Any,Main)

#Relative Strength Index
Set RSI = RSI(Close, 10)
PlotRange(30,40,any,rsi)
Plot(RSI, Line,Any,rsi)

#Buy And Sell
//Buy Condition
Set BuyCondition = Close > ma200 And Crossover(30,RSI )

//Buy on next day after the conditions are met
Set Buy = ref(BuyCondition,-1)

//Count days when buy started
//LASTIF returns a vector containing the number of days since the last time the specified condition evaluated to TRUE
Set DaysAfterBuy = Lastifs(Buy)
//Set initial Sell Condition- RSI Cross Or DaysAfterBuy = 10
set RS40Cross = Crossover(RSI,40) Or DaysAfterBuy =10

//Check if on 1stBuy -> Blockref(value if condition1=True,value if condition2=True, Condition1, Condition2)
//If Buy = Close > ma200 And Crossover(30,RSI )is true, InBuy will be true. When RS40Cross is True, InBuy will be false
Set InBuy = BlockRef(true,false,Buy ,RS40Cross )

//Commented - old codes 
//Set Sell = Ref(InBuy,-1) And RS40Cross

//Sell on the next day after the conditions are met
Set Sell = Ref(RS40Cross,-1)

#Plot(Buy , buy, green, main)
#Plot(Sell, sell, red, main)

#Uncomment below if you want to check values on variables
#plot(DaysAfterBuy, bar, any, days)
#plot(InBuy , bar, any, days2)

#Activate this to plot to show all buy and sell signals
#To activate, remove the # sign before both plot scripts below.
#plot(buy,buy,green,main)
#plot(sell,sell,red,main)

#Activate this to plot to show only per set of buy and sell signals, this removes all buy and sell signals in between
#If you activate this plot, remember to disable the previous plot function above.
plotbuysell(buy,sell,green,red,main)

//This function tells the screener and backtester which function is your buy and sell
signals(buy,sell)

 
Posted : 19/04/2021 8:43 pm
Share: