Am I inserting the "FuturesMode" function into the script correctly? It does not switch to futures mode.
Although if I choose futures mode in Preferences, it works correctly. Can I switch to futures mode in the script?
CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using System.Drawing; using System.Collections.Generic; namespace WealthScript3 { public class MyStrategy : UserStrategyBase { //create indicators and other objects here, this is executed prior to the main trading loop public override void Initialize(BarHistory bars) { BacktestSettings.FuturesMode = true; } //execute the strategy rules here, this is executed once for each bar in the backtest history public override void Execute(BarHistory bars, int idx) { if (!HasOpenPosition(bars, PositionType.Long)) { //code your buy conditions here } else { //code your sell conditions here } } //declare private variables below } }
Although if I choose futures mode in Preferences, it works correctly. Can I switch to futures mode in the script?
Rename
So this - "BacktestSettings.FuturesMode = true;" - doesn't switch to futures mode?
I would not ask if there was an example in the instruction, but it is not there, so it is not clear :)
I would not ask if there was an example in the instruction, but it is not there, so it is not clear :)
You're correct, it's not honoring the change of Futures Mode in the code. It's fixed for Build 8.
For some reason, it still does not work for me. In principle, this is not so important, since it is possible to simply choose the futures mode in preferences.
It is absolutely working for me. I created some symbols using the Random Provider, then assigned them to the CME using the Markets and Symbols tool. I ran a Knife Juggler on this DataSet, then cloned it and added the line to set FuturesMode to true in the code. Look at the difference in the result.
In my limited testing, enabling the option in Preferences first and then setting it to false in the strategy code produces unexpected result (no trades):
If I set it back to true I get my trades back.
However, if Futures Mode is disabled in Preferences, enabling it back and forth via strategy code is working just fine for me.
CODE:
BacktestSettings.FuturesMode = false;
If I set it back to true I get my trades back.
However, if Futures Mode is disabled in Preferences, enabling it back and forth via strategy code is working just fine for me.
Good catch there, I fixed this case for B39!
For example, I take the same Knife Juggler system, insert the code there:

Testing Australian Dollar Futures:

I get a result that is clearly not futures mode:

But when I choose in preferences Futures Mode, the result is true:

Although, I'm not sure that the percentage profit is correctly calculated from the margin. Probably, from equity would be more correct.
Testing Australian Dollar Futures:
I get a result that is clearly not futures mode:
But when I choose in preferences Futures Mode, the result is true:
Although, I'm not sure that the percentage profit is correctly calculated from the margin. Probably, from equity would be more correct.
Your Response
Post
Edit Post
Login is required