Implementation of MACD Trend Reversal Trading System - Specification 2023
Implementation of MACD Trend Reversal Trading System - Specification 2023
assignment - MACD
trading system
specificaton
500
400
300
200
100
The Rear represents the point where the items are inserted
inside the queue. The Front represents the point where the
items from the queue will be removed. This forms a FIFO queue
FILO/LIFO queue - last in the first out queue, the element that
is entered last will be the first to come out. - STACK
MACD line = S-MA – L-MA (MA can be SMA or EMA of the time series)
9-MACD-MA is the signal line (MA can be SMA or EMA of the MACD)
MACD Histogram = MACD – 9-MACD-MA (+ve = bullish and –ve =
bearish)
1) When the signal line crosses over the MACD line (That is the
histogram changes from +ve to –ve) it represents a trend reversal
turning bearish
2) When the signal line crosses under the MACD line (that is the
histogram changes from –ve to +ve) it represents a trend reversal
turning bullish
Introduction to Computational Thinking 14
MACD and MACDH
In a BUY and HOLD investment, the Long position is held over the
duration of investment and no opportunistic BUY and SELL are
considered during this investment holding period. Hence only 2
commission loss are incurred in standard BUY and HOLD strategy.
600
Close
500
400
300
200
100
Compute the BUY and SELL pair through the trading cycle with a
commission at each trade done during each of the trend reversal
BUY/SELL position. Assume all the holdings are bought or sold with all
the accumulated fund. The stock series is stored in a text or excel file.
600
Close
500
400
300
200
Hold
100
Buy Sell
Include a script of the run of your code which allows one to select which
financial excel data file to be used – generality of code.
Optional:
If we intend to reduce unnecessary trade due to weak trend reversal
what must be added to your design? Explain this with your result
with this additional filter for unnecessary trades
https://www.pythontutorial.net/python-basics/python-read-text-file/
https://www.pythontutorial.net/python-basics/python-write-text-file/
https://www.pythontutorial.net/python-basics/python-read-csv-file/
https://www.pythontutorial.net/python-basics/python-write-csv-file/
https://pythonbasics.org/read-excel/
https://pythonbasics.org/write-excel/