Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Bid/Ask During Backtest
Collapse
X
-
Hello reach4thelasers,
You should add a 1 tick ask series and 1 tick bid series. This will cause OnBarUpdate to trigger for the historical ask ticks and bid ticks.
-
I can do a playback using the playback connection. I can't do back-tests using the StrategyAnalyzer. I rely heavily on Bid/ASK market data in hundreds of different places in a 200-Class Strategy.
My strategy waits for a MarketDataType.Bid or Ask event - like would happen in live. But these events never fire during a Strategy Analyzer backtest so my strategy waits forever.
What should I do?
Leave a comment:
-
Hello reach4thelasers,
When you say "Replay" you are referring to doing a backtest with historical data with TickReplay enabled, and you are not referring to Playback with Market Replay data, is this correct?
Historical data is fundamentally different than real-time data. TickReplay is meant as an assist to avoiding adding multiple series for simple scripts to have intra-bar actions when in historical data but this does have limitations. Your script may not be able to take advantage of TickReplay when backtesting and I would recommend adding a 1 tick ask and 1 tick bid series.
See the following for more details.
Leave a comment:
-
This seems a bit silly, because I need to program my strategy differently for Replay and Live. When actually it should be agnostic of how its being run.
I get that its difficult to get actual bid and ask data in a non-live environement, But why doesn't Ninjatrader internally just provide the Last price as the Bid, and add on a pip or two to simulate the spread and provide that as the Ask Price? I don't really need the bid and ask during replay, but as it stands my strategy is waiting forever for a price that will never come.
Bid/Ask are not important during Replay, but they are important during live. Not so much for the basic MovingAverageCrossover EnterLong EnterShort type strategy. But when dealing with large trade volumes Limit orders are essential and the Bid/Ask needs to be carefully factored in.
I can add an edge case for now. How can I detemine if market data is coming via a Backtest? FYI my market data code is agnostic of strategy, so I don't have a strategy reference.
Leave a comment:
-
Hello reach4thelasers,
From the help guide:
"3. Tick Replay ONLY replays the Last market data event, and only stores the best inside bid/ask price at the time of the last trade event. You can think of this as the equivalent of the bid/ask price at the time a trade was reported. As such, historical bid/ask market data events (i..e, bid/ask volume) DO NOT work with Tick Replay. To obtain those values, you need to use a historical bid/ask series separately from TickReplay through OnBarUpdate()"
TickReplay is recorded as a single stream of last ticks and is not recorded as 3 separate streams.
Because of this, Ask and Bid will not trigger in OnMarketData. Instead, add a bid and or ask series to your script and get these values in OnBarUpdate.
Leave a comment:
-
Bid/Ask During Backtest
My strategy is blocking waiting for Bid/Ask data during a backtest. I've established that I needed to enable TickReplay for this. But its still blocking.
I notice the docs for Tick replay at:
says this...
"NinjaTrader stores the best bid price and best ask price as the last trade occurs during the MarketDataType.Last event and provides it per the table below:"
Why is bid and ask data being provided during the MarketDataType.Last event? This is not how live Bid/Ask updates happen. I've programmed my strategy to look for Bid updates during the MarketDataType.Bid event and Ask data during the MarketDataType.Ask event - seems logical, right?
However, despite working perfectly in live and in playback, backtesting causes my strategy to block waiting for bid ask data that never comes. Due to waiting for the wrong event.
Help me understand this madness, and what I can do to ensure that I get Bid/Ask updates during the appropriate event in Live/Playback - but also get the Bid/Ask in backtesting when they arrive in the wrong event.Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Change colour of Stop market and limit orders to red and green via indicator script
by Rapine Heihei
Started by Rapine Heihei, Yesterday, 07:51 PM
|
1 response
12 views
0 likes
|
Last Post Today, 06:59 AM | ||
Started by kaywai, Today, 06:26 AM
|
1 response
6 views
0 likes
|
Last Post
by kaywai
Today, 06:35 AM
|
||
Started by ct, 05-07-2023, 12:31 PM
|
6 responses
205 views
0 likes
|
Last Post
by wisconsinpat
Today, 06:29 AM
|
||
Started by kevinenergy, 02-17-2023, 12:42 PM
|
118 responses
2,780 views
1 like
|
Last Post
by kevinenergy
Today, 05:41 AM
|
||
Started by briansaul, Today, 05:31 AM
|
0 responses
10 views
0 likes
|
Last Post
by briansaul
Today, 05:31 AM
|
Leave a comment: