Max Open Positions



Please let me know how “max open positions” is calculated. My AFL works on hourly charts and I put 2 max positions for backtesting purpose. Yesterday, I saw 4 signals generated at 10 AM but backtesting obviously gave me 2 signals.

Now my questions is, how does Amibroker take 2 signals out of 4?

Note: All my signals are of (BUY ABOVE/SELL BELOW) type. So, out of 4 signals, Stock A triggered at 10:10AM, Stock B at 10:20, Stock C at 10:30 and Stock D at 10:40 AM.

So, ideally, Stock A and B should be captured by Amibroker as they triggered first but Amibroker showed Stock A and Stock C.

Please let us know the logic behind that? Some people say it is based on Stock name alphabets and some say, it is based on prices (Lower prices will be shown).



If you are backtesting using EOD data, then obviously there is no way for AmiBroker to know when the individual stocks triggered an intraday limit order. When there are multiple entry signals on the same bar, AmiBroker will use the PositionScore variable to determine which signals to take. If you have not defined PositionScore, then AB will default to alphabetic order based on the ticker symbol, although I’m not sure that behavior is guaranteed.



No, the order is as follows if no PositionScore is used (or if it has same value for multiple symbols):

  1. Greater (Dollar) position sizes are preferred
  2. Alphabetical order of symbols
  3. Long trades over short trades if both occur at the same bar for the same stock.


Thanks @fxshrat. In the few cases where I have not used PositionScore, I have always used equal position sizes (as a percentage of equity), so had never observed the preference for larger position sizes.


what about realtime trading , I have set max open position to 30 on the afl,i use the scan function to realtime trading ,will the max open position work in such a case or is it only for backtesting purpose,please advise