Support Board
Date/Time: Mon, 10 Mar 2025 10:16:47 +0000
Post From: Backtesting with sc.AllowOnlyOneTradePerBar = TRUE
[2022-03-19 03:53:02] |
User409050 - Posts: 22 |
Hi SC support team, I have a question about how the option sc.AllowOnlyOneTradePerBar works, I run a Bar Based Back Testing for a custom study with these options sc.AllowMultipleEntriesInSameDirection = TRUE; sc.AllowOnlyOneTradePerBar = TRUE; sc.MaximumPositionAllowed = 4; to place BuyEntry when some criteria are met. For example the day is "2022-02-22" and the bar is not the last bar on the chart (sc.Index < sc.ArraySize - 1). In the documentation, it mentions that if one uses "Bar Based Back Testing" then a custom study is calculated 4 times for each OHLC price. But when I run the study, it is calculated only once for the "2022-02-22 bar. If I remove the option (sc.Index < sc.ArraySize - 1) then It runs perfectly. but here is another problem. I wanted to exclude the last bar in the first place because if I didn't and the last bar happens to meet the criteria then when running "Bar Based Back Testing", the study will be calculated for the last bar first to some extent like 2-3 orders then it will be calculated for the other bars in the past which the order is not correct. Thanks |