Modified Mama Strat...
 
Notifications
Clear all

Modified Mama Strategy Setup

1 Posts
1 Users
2 Likes
1,301 Views
divspot
(@divspot)
Posts: 1
New Member
Topic starter
 

# Complete Setup for MAMA Strategy
# Included with the following:

# 5% cutloss
# MacD crossing up 0.01
# Illiquid stocks filter, value above 5M

// ALMA-MACD Set-up
// Popularized as MAMA Set up by Trader's Den
// Works well on daily charts.
// 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 ALMA = alma(close,9,.85,6)

// Set Buy and Sell
//Value with more than Php5 Million and above for 5 days
Set Value = Close * Volume
//Minimum value for 5 days
#Set TradeValue = Min(Value,5)> 5000000
//Average value for 5 days
Set TradeValue = SMA(Value,5)> 5000000

//Set variable if close price above alma
set CloseAboveAlma = alma < close

//If you want MACD Cross and Price Above ALMA, use the buy condition below
Set BuyMACDCross =Crossover (MACD_Line, MACD_Signal) and close > ALMA

//If you want MACD Crossing Up and Price Above ALMA, use the buy condition below
set MacDCrossingUP= crossover(MACDCrossing,-0.01)

//If you want both of them, then combine your buy signal like below
Set Buy = (MacDCrossingUP Or BuyMACDCross) and CloseAboveAlma and TradeValue
Set Sellref = crossover(alma,close)

//Store the Buy Amount -> Blockref(value if condition1=True,value if condition2=True, Condition1, Condition2)
//If BuyAll is true, buyAmt will keep the close price as buy amount. When Sell is True, buyAmt will be 0
set buyAmt= blockref(close,0,Buy ,Sellref)
set gain=if(buyAmt<>0, (close - buyAmt)/buyAmt,0)
set cutloss = buyAmt<>0 And gain < -0.05
plot(gain, bar, any, gain)
Set Sell = crossover(alma,close) Or cutloss
set Cut = cutloss and Ref(Sell,1) <> true and Ref(cutloss ,1) <> true

//Plot MACD
//Plot(value,type,color,pane)
Set MACDhistup = if(hist > 0, hist ,0)
Set MACDhistdown = if(hist < 0, hist, 0)
plot(MACDhistup, stackedbar, green, MACD)
plot(MACDhistdown, stackedbar, red, MACD)
plot( MACD_line, line, any, MACD)
plot(MACD_signal, line, any, MACD)
plot(ALMA,line,cyan,main)

//Plot Buy and Sell Signals
//Plot(value,type: Buy/Sell,color,pane)
//Buy - Label displayed below
//Sell- Label displayed above
#plot(Buy , Buy, Green, Main)
#plot(Sell, Sell, Red, Main)
//To use Buy and Sell combination, use plotbuysell command
//No Buy signal if there is existing Buy not closed by Sell. No Sell signal if there is no prior Buy signal.
//plotBuySell (Buy Variable, Sell Variable, Color for Buy, Color for Sell, main - Main pane)
plotbuysell(buy,sell,green,red,main)
plot(Cut , buy, Orange, Main)

//To use Buy and Sell combination, use plotbuysell command
//No Buy signal if there is existing Buy not closed by Sell. No Sell signal if there is no prior Buy signal.
//plotBuySell (Buy Variable, Sell Variable, Color for Buy, Color for Sell, main - Main pane)
//plotbuysell (buy, sell, green, red, main)
//Signals - used to display flags in screener and backtesting.
signals(Buy ,Sell,cutloss:orange)

 

1618894170-mama_strat.png
This topic was modified 5 years ago 5 times by divspot
 
Posted : 20/04/2021 12:13 pm
snoperg and makku reacted
Share: