- ago
Am I inserting the "FuturesMode" function into the script correctly? It does not switch to futures mode.

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?
0
826
Solved
7 Replies

Reply

Bookmark

Sort
- ago
#1
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 :)

0
Glitch8
 ( 12.10% )
- ago
#2
You're correct, it's not honoring the change of Futures Mode in the code. It's fixed for Build 8.
1
- ago
#3
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.
0
Glitch8
 ( 12.10% )
- ago
#4
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.

0
- ago
#5
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):
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.
0
Glitch8
 ( 12.10% )
- ago
#6
Good catch there, I fixed this case for B39!
0
Best Answer
- ago
#7
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.
0

Reply

Bookmark

Sort