Notifications
Clear all

MACD Histogram and RSI Strat

punk
 punk
(@punk)
New Member User

#--------------------------------------------------------------------------------------------------------#
//MACDHISTOGRAM-RSI Strategy
//Buy when MACDHISTOGRAM IS UP AND RSI14 >= 60 AND Value >5M
//Sell when Close < EMA9  or when stoploss is hit (-4% from entry price)
#--------------------------------------------------------------------------------------------------------#

//Set Variables
Set MACD_line = MACD(12,26,9, exponential)
Set MACD_signal = MACDSIGNAL(12,26,9, exponential)
Set Hist = MACD_line - MACD_signal
Set RSI = RSI(close,14)
Set EMA = EMA(close,9)
Set SMA = SMA(close,20)
Set MACDhistup = if(hist > 0, hist ,0)
Set MACDhistdown = if(hist < 0, hist, 0)

//Plot(value,type,color,pane)
plot(RSI,line,blue,RSI)
plot(60,line,Green,RSI)
plot(EMA,line,green,main)
plot(SMA,line,red,main)
plot(MACDhistup, stackedbar, green, MACD)
plot(MACDhistdown, stackedbar, red, MACD)
plot(Vol50,splinearea,any,volume)

//Volume at 80 of Average 50 bars
set Vol50 =Sma(Volume,50)
set VolAvg =Volume > vol50 *0.8

//Value with more than Php5 Million
Set Value = Close * Volume
Set TradeValue = value > 5000000

//Buy Signal
SET buy = MACDhistup and RSI >= 60 and TradeValue

//trail Stop
SET trailStop = CLOSE < EMA

//entry price
SET entryPrice = BLOCKREF(CLOSE, 0, buySignal, trailStop)

//day change
SET change = IF(entryPrice <> 0, (CLOSE - entryPrice) / entryPrice, 0)

//cutloss
SET cutloss = entryPrice <> 0 AND -0.04 > change

//Sell Signal
SET sell= trailStop Or cutloss

//Plotting of buy and sell signals
PLOTBUYSELL(buy, sell, green, red, main)
plot(Cutloss , buy, Orange, Main)

//Signals(BuyCondition,SelCondition)
signals(Buy ,Sell,cutloss:orange)

//END

 

 

 

 

 

This topic was modified 3 months ago by punk
Quote
Topic starter Posted : 29/04/2021 10:31 pm
Mike
 Mike
(@vanguardai)
Co-Founder Admin

Adding a photo here to benefit our other users. Nice script @punk!

1619852878-punk-sese-chart.png
ReplyQuote
Posted : 01/05/2021 3:07 pm
Share: