Starting a new trading system design in AmiBroker

Hi everyone,

I’m new to coding and trading, and I’m struggling with AmiBroker while trying to implement my ideas.

As I understand it, a trading system consists of several components—buy/sell logic, position sizing, no-trade criteria, etc.

I started coding all of these parts in a single formula, but I’m wondering if that’s the best approach or if I should create separate formulas for each component. I’d appreciate any advice on the ideal workflow for designing a trading system in AmiBroker.

Thank you in advance!

Create one formula. Divide it into visually separate segments (using blank lines and/or comments) that serve different tasks.

1 Like

And finally, where should I place each component? Should position sizing come before or after calculations like the Donchian Channel or RSI? Should pyramiding occur after each buy or cover signal, or only once all signals have been generated? And should I define the conditions that liquidate all units before or after the long/short logic? I’m a bit confused about the proper order of these parts when writing the code.

It doesn't matter if you place position sizing statements here or there as long as formula parses without errors. All these things in your formula are just "instructions" for backtester that takes all the settings, collects all signals and variables and only AFTER it has all information collected it performs actual backtesting (trading simulation). Actual sequence of events is
Formula execution -> storing and ranking of signals (according to pos. score ) -> actual portfolio backtest

1 Like

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.