- ago
Would you please tell me how programmatically to know whether I am running my strategy in 'Backtest' window or under SM/Streaming chart?

I looked everywhere but I wasn't able to locate such reference.

2
120
8 Answers

Reply

Bookmark

Sort
- ago
#1
Could you clarify why this may be required?
0
- ago
#2
Here are three example scenarios where I need to know the context in which the strategy runs:
1- Dropping a strategy to run in a streaming chart: In the charts preferences, “Data/Trading” is a global setting it affects other strategy start dates which could be meant for different time frames. To avoid this I set a date in the code to control StartIndex.
CODE:
DateTime StartDate = new DateTime(2021, 4, 1, 9, 35, 0); StartIndex = bars.IndexOf(StartDate, true);


But when I backtest the same strategy I have to comment the code each time.
If I know I was running in backtest mode I could do something like this

CODE:
   If(!backtest) { DateTime StartDate = new DateTime(2021, 4, 1, 9, 35, 0); StartIndex = bars.IndexOf(StartDate, true); } Else { StartIndex = 1; }


2- I’d like to automate trades with keyboard simulation: If I know the strategy is running in backtest then I don’t invoke the simulator.

3- To speed up backtesting I disable calculating visual indicators which are only needed when I look at the strategy while streaming.

I currently use a strategy parameter I set for different context, but since my strategy is compiled I have to reset the parameter each run. I forget to do this sometime and causes me to re-run.

0
- ago
#3
Thanks for clarifying. You're making what seems to me a solid point for exposing an IsStreaming property.
0
- ago
#4
Thank you for considering adding a new property.
0
- ago
#5
This should be flagged with #FeatureRequest so it can be voted on.
0
Cone7
- ago
#6
Voila! It is a Feature Request now. Vote if you want it!
1
- ago
#7
QUOTE:
3- To speed up backtesting I disable calculating visual indicators which are only needed when I look at the strategy while streaming.
What about a property to say if a Chart window is open whether or not it's streaming. I display many fundamentals on the Chart window, which I don't need to calculate if there isn't a Chart window.
0
- ago
#8
Linked feature request:

https://www.wealth-lab.com/Discussion/Name-of-Current-DataSet-6153
0

Reply

Bookmark

Sort