Excel VBA Stock market Trading system
Budget: $15 – $25 USD
I use Excel 365 to track and back-test my trading ideas and now want the logic formalised into a single, reliable VBA module. The workbook already holds daily OHLC data in one sheet; your macro will calculate and refresh three indicators—10-day moving average of closing price, 14-day ATR, and its own 30-day moving average—then generate signals and manage an open-position log.
Core workflow
• On refresh, the code updates indicator columns and checks each new bar.
• Buy when the 14-day ATR is above its 30-day ATR MA and the close finishes above the 10-day MA; entry is at that same close.
• If the 14-day ATR drops below its 30-day MA, or the price dips back under the 10-day MA, a trailing stop is placed at the low of the first candle breaching that level and moves down candle-by-candle until hit.
• A profit target closes the trade at 2 × current ATR.
• When neither buy nor sell conditions are met (14-day ATR below its 30-day MA from the outset), the macro remains flat.
I would like detailed, line-by-line comments so I can tweak parameters later. Please build with clear, named ranges or table references rather than hard-coded cells, and surface key variables (MA lengths, ATR multiplier) at the top of the module for quick editing.
Deliverables
1. Fully commented VBA code, ready to paste into the workbook’s “TradeEngine” module.
2. A short setup note explaining required sheet names/column headers and how to trigger the routine manually or via Workbook_Open.
3. A quick demonstration run on sample data confirming entries and exits precisely match the rules above.
I’ll verify the solution by stepping through several historical periods and ensuring the trade log mirrors my manual back-test, so accuracy of the calculations and trigger points is the primary acceptance criterion.
Core workflow
• On refresh, the code updates indicator columns and checks each new bar.
• Buy when the 14-day ATR is above its 30-day ATR MA and the close finishes above the 10-day MA; entry is at that same close.
• If the 14-day ATR drops below its 30-day MA, or the price dips back under the 10-day MA, a trailing stop is placed at the low of the first candle breaching that level and moves down candle-by-candle until hit.
• A profit target closes the trade at 2 × current ATR.
• When neither buy nor sell conditions are met (14-day ATR below its 30-day MA from the outset), the macro remains flat.
I would like detailed, line-by-line comments so I can tweak parameters later. Please build with clear, named ranges or table references rather than hard-coded cells, and surface key variables (MA lengths, ATR multiplier) at the top of the module for quick editing.
Deliverables
1. Fully commented VBA code, ready to paste into the workbook’s “TradeEngine” module.
2. A short setup note explaining required sheet names/column headers and how to trigger the routine manually or via Workbook_Open.
3. A quick demonstration run on sample data confirming entries and exits precisely match the rules above.
I’ll verify the solution by stepping through several historical periods and ensuring the trade log mirrors my manual back-test, so accuracy of the calculations and trigger points is the primary acceptance criterion.