MIH8
- ago
Is there a way to access the opening price of the streaming (trading) bar or is it (easily) possible to provide it?

I can easily run backtesting scenarios with the opening price (of the trading bar) and would like to include the market opening in limit price calculations (for the trading session). Therefore, I would like to access this information.

In the intraday context, one can of course query the first bar of the day on a low scale, but this is also not optimal in terms of any time scale. In EOD trading, I don't know any way to do this at all.

Thanks for a feedback.
0
452
Solved
5 Replies

Reply

Bookmark

Sort
MIH8
- ago
#1
An example can be the Knife Juggler strategy. When you change the limit price calculation.

CODE:
limit_price = bars.Close[idx] * 0.98; // Knife Juggler


CODE:
limit_price = bars.Open[idx+1] * 0.98; // Limit with opening price of trading session.


So bars.Open[idx+1] can be used for backtesting. For Trading the real opening price would be required.
As soon the streaming begins, the price is basically known (available).
0
- ago
#2
Yes, please see ExecuteSessionOpen. There's also a Youtube video link:

https://www.wealth-lab.com/Support/ApiReference/UserStrategyBase
0
Best Answer
MIH8
- ago
#3
Great! Thank you.

Can you tell me if i need some kind of exception handling if the sessionOpenPrice is not available (can this happen if i already stream data)? Do i need to have some kind of fallback price, like for example the closing price of the previous session?
0
MIH8
- ago
#4
I ask my last question because of the documentation snippet.

QUOTE:
For live trading, WealthLab will attempt to load the price from the Historical Data Providers that are enabled in the Data Manager and will keep trying to get the session open price for up to 20 seconds,


Now, if i am connected with IB, i guess you retrieve the price from IB. Or do you really check the different providers (which are enabled) in the Datamanager when streaming?

And does these limit orders work with the Quotes-Tool?
I guess i first need to run the strategy monitor (on market opening) and send the limit orders to the quotes tool then?
With the closing price of the previous day i would do it before the market opens.

Please excuse the uncertainties and many questions.
0
- ago
#5
QUOTE:
Can you tell me if i need some kind of exception handling if the sessionOpenPrice is not available (can this happen if i already stream data)? Do i need to have some kind of fallback price, like for example the closing price of the previous session?

Having a fallback is up to you but WL will return NaN if the partial bar's opening price is not available.
0

Reply

Bookmark

Sort