Help on MACD Strategy
Forums › ProRealTime English forum › ProOrder support › Help on MACD Strategy
- This topic has 5 replies, 4 voices, and was last updated 3 years ago by
Andrea.
-
-
06/20/2019 at 7:48 PM #101114
Hello,trying out an simple macd strategy. If someone coud help , much appreciated.
for Long:
- once macd crosses over 0 and the next 3 bars on macd line is green
- then place and buy order “x”pips below the close price of the 3rd bar
For short:
- once macd crosses under 0 and the next 3 bars are red
- then place a short order “x”pips over the close price of the 3rd bar
see also attached screen
123456789101112131415161718192021// Definition of code parametersDEFPARAM Preloadbars = 10000DEFPARAM CumulateOrders = False // Cumulating positions deactivated// indicatorsmac = MACDline[12,26,9](close)Positions = 10IF not onmarket and mac crosses over 0 THENbuy Positions SHARES AT MARKETENDIFIF not onmarket and mac crosses under 0 THENsellshort Positions SHARES AT MARKETENDIFSet target pprofit 50set stop ploss 5006/21/2019 at 7:04 AM #1011243 red / green candles:
1234567891011redcandle1 = close < openredcandle2 = close[1] < open[1]redcandle3 = close[2] < open[2]threeredcandle = redcandle1 and redcandle2 and redcandle3greencandle1 = close > opengreencandle2 = close[1] > open[1]greencandle3 = close[2] > open[2]threegreencandle = greencandle1 and greeencandle2 and greencandle3And heres the “place an order below/above closed candle:
1234567891011y2 = close - (10*pointsize)if buytime thenbuy 1 contract at y limitendify1 = close + (10*pointsize)if shorttime thensellshort 1 contract at y2 limitendifSo your entire code would look like this:
1234567891011121314151617181920212223242526272829303132333435363738394041// Definition of code parametersDEFPARAM Preloadbars = 10000DEFPARAM CumulateOrders = False // Cumulating positions deactivated// indicatorsmac = MACDline[12,26,9](close)redcandle1 = close < openredcandle2 = close[1] < open[1]redcandle3 = close[2] < open[2]threeredcandle = redcandle1 and redcandle2 and redcandle3greencandle1 = close > opengreencandle2 = close[1] > open[1]greencandle3 = close[2] > open[2]threegreencandle = greencandle1 and greeencandle2 and greencandle3Positions = 10macbuy = mac crosses over 0macshort = mac crosses under 0buytime = macbuy[2] and threegreencandleshorttime = macshort[2] and threeredcandley1 = close + (10*pointsize)y2 = close - (10*pointsize)IF not onmarket and buytime THENbuy Positions SHARES AT y2 limitENDIFIF not onmarket and shorttime THENsellshort Positions SHARES AT y1 limitENDIFSet target pprofit 50set stop ploss 503 users thanked author for this post.
06/21/2019 at 7:45 AM #101128Just noticed you might have asked for 3 red macd bars and not 3 red candles in photo. Do you want the 3 bars to be lower/higher then the last one? or does it only matter that they are red/green?
This is for 3 red macd histogram bars that goes lower and lower: (just do the “>” for higher and higher for long trades)
12345678910indicator1 = MACD[12,26,9](close)c1 = (indicator1 < 0)indicator2 = MACD[12,26,9](close)c2 = (indicator2[1] < 0)indicator3 = MACD[12,26,9](close)c3 = (indicator3[2] < 0)indicator4 = MACD[12,26,9](close)c4 = (indicator4 < indicator4[1])indicator5 = MACD[12,26,9](close)c5 = (indicator5[1] < indicator5[2])If you only want 3 red bars and it dosnt matter which is bar is lower then the other then just remove c4 and c5
1 user thanked author for this post.
06/21/2019 at 8:18 AM #10113506/21/2019 at 5:22 PM #10118012/29/2020 at 10:41 AM #155524 -
AuthorPosts
Find exclusive trading pro-tools on