- ago
I tried to create a strategy that would execute a "Buy at Stop 1% Above NextSessionOpen". I have been worried that Tradier would base the Open price (NextSessionOpen) on yesterday's Open price if I ran the strategy too close to market open. So, I ran it at 9:30:30. By that time, the price had jumped more than 1% above today's open. Consequently, Tradier cancelled my order since I was putting in a Buy at Stop order below where the market had already gone.

I'm considering trying to run it at 9:30:01, but was wondering if there was another way I could tell it to just submit a Market Order if the market had increased above my Buy Stop by the time I ran the strategy (say at 9:30:30 like I had originally tried to run it). I don't see an indicator for "CurrentPrice" that I could use in a block to tell it "Buy at Market: CurrentPrice is greater than or equal to 1% above NextSessionOpen".

Also, I've never run multiple strategies at the same time before. Would there be any issues running multiple strategies 9:30:01?
2
1,244
66 Replies

Reply

Bookmark

Sort
Glitch8
 ( 10.62% )
- ago
#1
We were able to add the new NextSessionOpen because it could be backtested as well as operate in live trading. There’d be no way to backtest a CurrentPrice indicator so it’s unlikely we’ll add that.

Let me think on this and see if we can figure out a way to overcome it, maybe in a Trading Preference of some kind.

And there shouldn’t be any issue running multiple Strategies at the same time.
1
Cone8
 ( 4.98% )
- ago
#2
For Nasdaq stocks, unless they're illiquid, the opening will be available almost immediately. NYSE is a different story due to the staggered openings in the primary market, although a full-lot trade on any ECN will create an opening price even before the primary market opens.

Wealth-Data (S&P 500 and Nasdaq 100) will have opening prices in near real time. It inserts the first full lot trade as the opening price, but it will be replaced by the primary market opening price if it occurs later.

@Glitch,
fwiw, if the Quotes tool were streaming, opening prices could be available instantly for any strategy that required it.
0
- ago
#3
I ran my strategy at 9:30:02 today using NextSessionOpen with Tradier and it based my order on yesterday’s open.
0
Cone8
 ( 4.98% )
- ago
#4
Which symbol(s)?
0
- ago
#5
I guess FNGU was the only one that used yesterday’s open.

What time is a good time to run the strategy for this symbol considering it looks like it’s on the NYSE.
0
Cone8
 ( 4.98% )
- ago
#6
FNGU trades NYSE-ARCA, which is electronic. You can probably count on that trade occurring right at 09:30. Here's today's trade -



Probably it takes a few seconds for Tradier to get this in their historical server to provide the partial bar data. Maybe try at 09:30:05.

fwiw, Wealth-Data covers this symbol and its open will be available almost immediately, say, 09:30:01.
0
- ago
#7
Should I be putting Tradier above WL Data since I'm using Tradier as my broker? When this strategy based NextSessionOpen off of yesterday's open when I ran it at 9:30:02 today, WL Data was my top historical provider, then Alpaca, then Tradier, then Y!.
Which order would be most ideal?
1) WL Data, Tradier, Y!, Alpaca
or
2) Tradier, WL Data, Y!, Alpaca

Upon giving what happened a closer look, I don't think NextSessionOpen used yesterday's open. I ran similar strategies on three tickers today.

Buy at Stop 1% above NextSessionOpen (Ticker: FNGU)
Buy Stop Order that was actually submitted to the broker: $233.97 (Sent @ 9:30:04)
WL Data's Open today: $236.00
WL Data's Open yesterday: $238.94


Buy at Stop 0.3% above NextSessionOpen (Ticker: RETL)
Buy Stop Order that was actually submitted to the broker: $8.86 (Sent @ 9:30:02)
WL Data's Open today: $8.99
WL Data's Open yesterday: $9.09


Buy at Stop 0.5% above NextSessionOpen (Ticker: PILL) (Sent @ 9:30:03)
Buy Stop Order that was actually submitted to the broker: $7.01
Alpaca's Open today: $6.87
Alpaca's Open yesterday: $7.14

Those are the actual Buy Stop Order amounts. I realize the actual prices that the orders are filled at will be different since it sends a market order, but should the Buy Stop Order's be 1%, 0.3%, and 0.5% above the open for the respective strategies? Where did it come up with the Buy Stop Order amounts and what advice do you have to remedy this?
0
Cone8
 ( 4.98% )
- ago
#8
You can use any data provider with any broker.
W-Data on top is fine if you want to use that as your first choice. (It is for me.)
Here's how Wealth-Data is different from other EOD providers:
https://www.wealth-data.com/faq

As for the prices, it seems like there's a problem with the Strategy code. If you're using blocks, can you share a screen shot?
Otherwise paste the C# code in use - at least the part for the Stop order.
0
- ago
#10
This is one of the strategies..
0
Cone8
 ( 4.98% )
- ago
#11
It looks okay, and I've checked the code behind it too.
I'll give it a try today on FNGU, TQQQ, and others.
1
Glitch8
 ( 10.62% )
- ago
#12
You can just drag the NextSessionOpen into a chart to see the value it’s using.
0
- ago
#13
When you tried it, did it send in Stop Buy orders for the appropriate price?
0
Cone8
 ( 4.98% )
- ago
#14
The one symbol I checked was wrong and the price didn't make sense for the day's open or the previous day's open. But, when I checked the NextSessionOpen shortly afterward, it was correct.

Before being able to dig in further, I became distracted by the fact that our process that monitors and inserts the opening prices for Wealth-Data didn't work for about 70% of the tickers that we monitor. We noticed it the day before too, primarily for NYSE symbols.

We need to get on top of both of these.
0
- ago
#15
So the interim fix is to put Tradier data in the first historical provider position so it takes the open from Tradier data?
0
Cone8
 ( 4.98% )
- ago
#16
I don't know. The cause is undefined.
.. but it's not a bad idea to change something to move forward.
0
- ago
#17
Unfortunately, changing the Tradier historical provider to the first position didn’t yield appropriate values for the Buy Stop orders for the respective tickers.
0
Cone8
 ( 4.98% )
- ago
#18
At least we discovered that we were getting a partially delayed feed, so Wealth-Data should be able to deliver the open reliably again tomorrow. I'll troubleshoot it then.
0
Cone8
 ( 4.98% )
- ago
#19
Sadly, our feed is still delayed today :/
0
- ago
#20
Dang. I guess I don't understand why putting Tradier & Y! above Wealth-Data wouldn't have solved the issue in the interim. Shouldn't the strategies using NextSessionOpen be using whatever historical provider has priority to determine the price at market open? Or is the issue broader than that?
0
Glitch8
 ( 10.62% )
- ago
#21
Yes it should. Try dragging the indicator onto a chart and observe its value.
0
- ago
#22
When I do that for ticker PILL...here are the values I am getting with Tradier at the highest priority historical provider...

12/26 Tradier Open - $7.5
12/26 NextSessionOpen - $7.63

12/22 Tradier Open - $7.2
12/22 NextSessionOpen - $7.5

12/21 Tradier Open - $6.87
12/21 NextSessionOpen - $7.2 (a value that was beyond the High/Low of the day)

The NextSessionOpen dots don't seem to line up with the Open of the candles.
0
Glitch8
 ( 10.62% )
- ago
#23
Ok this is all correct. It’s plotting the open of the NEXT SESSION on the bar for the CURRENT SESSION.
0
Glitch8
 ( 10.62% )
- ago
#24
Furthermore, according to the sources I see PILL opened up today at 7.63 so it's correctly plotting TODAY'S open on the complete final bar for YESTERDAY 12/26.
0
- ago
#25
My strategy used a Stop Buy for that ticker that was supposed to be sent in at 0.5% above NextSessionOpen ran at 9:30:10 today. It submitted a Stop Buy order for 7.86 at that time.
0
Glitch8
 ( 10.62% )
- ago
#26
What I'm trying to do here is explain how the NextSessionOpen indicator works. You saying things like "the dots don't line up with the open" make me believe there's a misunderstanding about how the indicator works. If you see the correct value on the chart for today's market open you can be confident that this is the value that will be used in your strategy if you're using NextSessionOpen.
0
Glitch8
 ( 10.62% )
- ago
#27
Here is your strategy's entry, it's being correctly calculated at 0.5% above the session open for PILL (7.63 * 1.005 = 7.67)

If you're seeing an incorrect price at the time of running the strategy, open a chart and see what the indicator is returning. It could be that the provider doesn't have the current open price available yet via their API.

0
Cone8
 ( 4.98% )
- ago
#28
I did a test with TDA and then as IB as preferred providers. I wrote some code to put the value of the open, from NextSessionOpen(), in the SignalName.
This scheduled run with Daily data occurred at 09:30:01.

I only checked the first 5 and they are all correct.
CODE:
Symbol   Action   Quantity   Order Type   Price   Signal Name AAPL   Buy   10   Stop   193.45245   192.49 BA   Buy   10   Stop   263.94315   262.63 FNGU   Buy   10   Stop   241.0995   239.90 IBM   Buy   10   Stop   163.9557   163.14 QID   Buy   10   Stop   10.56255   10.51 QLD   Buy   10   Stop   77.0031   76.62 QQQ   Buy   10   Stop   413.00475   410.95 SQQQ   Buy   10   Stop   13.3464   13.28 TQQQ   Buy   10   Stop   51.60675   51.35 TTD   Buy   10   Stop   74.21925   73.85 WBA   Buy   10   Stop   26.8536   26.72
0
- ago
#29
That helped out a bunch. I guess it’s just the speed of the provider posting the opening value that is throwing things off. Tradier must be a little too slow. Clearly, I need to purse TDA or IB data to fully utilize a strategy that runs that quickly after market open that uses the NextSessionOpen indicator. Thanks guys

0
Glitch8
 ( 10.62% )
- ago
#30
And we’ll update here when our WealthData issue gets resolved.
1
- ago
#31
Do you happen to know if IQFeed would likely return the correct current open price if NextSessionOpen ran at 9:30:01 too? I don’t think I can get access to TDA data until they convert to Schwab and IQFeed seems a little more user-friendly than IB.
0
Glitch8
 ( 10.62% )
- ago
#32
I’d say yes as long as you subscribe to real time data and not delayed
1
Cone8
 ( 4.98% )
- ago
#33
IB is plenty good for a few symbols, but it's extremely slow to return historical data - especially intraday. I mainly use it for the future's contracts that I trade. Once you have the historical cache downloaded, then even IB is quick to update for the next day.

If you need a lot of data quickly, IQFeed is best all-around.
See All About WealthLab Intraday and Realtime Data Providers for all the options.
1
- ago
#34
That’s great advice. Thanks again!
0
- ago
#35
Do I need to run these strategies in something other than Polling? My strategies are still not basing their order values off of the appropriate open values and I’m just still trying to troubleshoot this. After signing up for the IQFeed trial version and paying for the Nasdaq and NYSE exchange data, I ran them at 9:30:01 and the order values aren’t appropriate for the open prices. I wasn’t by my computer to open a chart to see what the NextSessionOpen value WealthLab was using.
0
Glitch8
 ( 10.62% )
- ago
#36
I think you'll need to be at the computer to troubleshoot. You'll need to drag the indicator onto a chart at 9:30:01 to examine the value being returned. It might be that 9:30:01 is still too early.

If you can't be at the computer you could call WLHost.Instance.AddLogItem in the code to output the most recent value of NextSessionOpen to the WL8 log:

CODE:
//create indicators and other objects here, this is executed prior to the main trading loop public override void Initialize(BarHistory bars) {          NextSessionOpen nso = new NextSessionOpen(bars);          PlotIndicator(nso);          WLHost.Instance.AddLogItem("MyStrategy", "NextSessionOpen = " + nso.LastValue.ToString("N2"), WLColor.Green); }

1
Glitch8
 ( 10.62% )
- ago
#37
You should also verify in a streaming chart that you're actually getting non-delayed data from IQFeed. Even though you completed the agreements, some users have had to call IQFeed to get the non-delayed feed activated on their account.
1
- ago
#38
QUOTE:
verify in a streaming chart that you're actually getting non-delayed data from IQFeed.

I'm thinking the trial version might be delayed. You can call DTN and ask them to switch you to a paid version immediately. You can just pay for one month to see if it works for you. Of course, paying by quarter or year is cheaper.
0
- ago
#39
I’ve been corresponding with IQFeed. I still have the trial version but have been paying them for real-time NASDAQ & NYSE data. I asked them how quickly I can run a strategy in WL as to never miss the correct open price and they said 9:30:01. I still haven't had an opportunity to load the indicator in a chart at 9:30:01 yet.
0
Cone8
 ( 4.98% )
- ago
#40
But the question remains, are you getting real time data?

To check, just open a 1-min or 5-min intraday chart.
What's time for the last bar? Is it current or delayed by 15 minutes?
0
- ago
#41
I opened Tick, 1min, and 5min charts to see what the timestamps were (this was done well after the market closed for the day).

—-PILL—-
Tick *First Tick: 9:30:00(Last Tick 3:59:57)
1min *First Bar: 9:31am(Last Bar 3:58PM)
5min *First Bar: 9:35am(Last Bar 4:00PM)

—-FNGU—-
Tick *First Tick: 9:30:00(Last Tick 3:59:59)
1min *First Bar: 9:31am(Last Bar 4:00PM)
5min *First Bar: 9:35am(Last Bar 4:00PM)

—-RETL—-
Tick *First Tick: 9:30:00(Last Tick 3:59:58)
1min *First Bar: 9:31am(Last Bar 4:00PM)
5min *First Bar: 9:35am(Last Bar 4:00PM)
0
Glitch8
 ( 10.62% )
- ago
#42
You can’t tell if the data is delayed or not unless you do this during a time that the market is open. For example say it is 10:23am EST. If you open a 5 minute chart, you’ll see 10:20 as the last bar if you have real time data. If it’s delayed, the last bar will show 10:05.
0
- ago
#43
I finally had the chance to put NextSessionOpen in a chart this morning at 9:30:01. These are the results. The data doesn't seem delayed, but NextSessionOpen is still returning NaN for RETL and FNGU, but not PILL.



0
Cone8
 ( 4.98% )
- ago
#44
I don't even see how it's possible to get an intraday chart of NaNs for that indicator. The data is there, so there's no question about the "NextSessionOpen". Nonetheless, I see it's possible, so we need to figure out why.

That said, it's a mistake to uncheck Filter Pre/Post. If the strategy depends on NextSessionOpen, you should not backtest with premarket data. If you do that, the history for the GetSessionOpen indicator - excluding "today after the market opens" - will be from the first opening tick in the premarket data.

Update -
Sorry, since the charts don't have the times along the bottom, I assumed I was looking at pre/post data due to the illiquid trading of those instruments.
0
Glitch8
 ( 10.62% )
- ago
#45
It looks like the provider was not able to return the data in time for FNGU and RETN. We have WealthData’s real time open issue resolved so you can compare with that.
0
Cone8
 ( 4.98% )
- ago
#46
Okay, I see the problem. You're not loading enough intraday data.

Because of its construction, NextSessionOpen() needs the data to begin at "some time" in the session before the previous session - or precisely on the 0931 bar of the session before the "next session".

With a 1-minute chart, you can probably guarantee that if you use 780 bars (less if you start at the beginning of the session).
Actually - use 3 Days (N Days) of data. That'll guarantee it.

We can probably make an adjustment to NextSessionOpen() later so that that's not required.
0
- ago
#47
@Glitch I guess I'll try using Wealth-Data tomorrow.

@Cone I'm trying to wrap my mind around what you said and how to fix the issue of not loading enough data into the chart. I thought I selected it to load "All Data" in the chart in preferences. IQFeed trial only supplies 4 calendar days of intraday data. When I looked at how I was loading the strategies in strategy monitor, I was using the default "100 bars" and "Daily". Should I be changing those to "1200" and "1minute"?
0
Cone8
 ( 4.98% )
- ago
#48
Do not use "All Data" for intraday trading.
Using millions of bars will cause terrible delays while trading.

QUOTE:
Should I be changing those to "1200" and "1minute"?

I don't know anything about your strategy or how you want to trade it. I'm commenting on the 1-minute charts that you showed above.

For live trading you only need to load enough data to make your indicators valid, and to create the hypothetical "active" trades. In other words, if your strategy holds positions for more than a week, you should probably load 2 weeks of data.

Note - extra data to create a hypothetical position for an active trade isn't required with the "Use Live Positions" Trading Preference.

The N Days (3 minimum) or N weeks options are convenient data loading options for live intraday trading.


0
- ago
#49
I was trying to get the strategy in Post #10 to work. I used "100 bars" and "Daily" when I loaded the strategy in S.Monitor. I gather that this isn’t the culprit to why it’s putting in order values that don’t reconcile with the market open price?

I've had "Use Live Positions" checked throughout trying to get this to run properly.
0
Cone8
 ( 4.98% )
- ago
#50
Right, I lost track of that strategy 30 posts ago :D
There shouldn't be a problem making that work with 100 Daily bars.

Wealth-Data (for the symbols it covers - S&P 500, Nasdaq 100) will work fine, but it doesn't cover the symbols like PILL.

The only thing I can suggest it to make sure your clock is synchronized to internet time. If your clock is fast, it will run too early, before the open. Since you're basing an order on movement after the open, I'd wait a few seconds to be sure the open has had time to occur.. .schedule 09:30:05 for example.
0
- ago
#51
I've had my clock synced to internet time since initially having issues with sending orders to binance months ago. Fwiw the time server that it is syncing to is time.windows.com

I would have thought that even if my clock were fast and it executed prior to market open, it would have just erroneously used the prior day's market open price. That has not been the case. I ran it at 9:30:05 today and it still didn’t send the appropriate order.

Would you anticipate setting the strategy to Streaming instead of Polling to have any impact? I wouldn't think so since this is more of a daily strategy than an intraday strategy, but I'm just trying to think of anything to make this work correctly.
0
Cone8
 ( 4.98% )
- ago
#52
I would anticipate a problem scheduling a run with Daily Streaming because I've never even thought to test that scenario.

Use Polling for Daily+.
It works. I've tested it every day for months.
0
Cone8
 ( 4.98% )
- ago
#53
I just scheduled a Daily Streaming run for 3:19 PM, during market hours, similar to what would be done at 09:30:01.

It sticks in "Processing" and doesn't complete a run.

Update - 5 minutes later at 3:24PM -
No Updates for 4 Symbols: IBM,NFLX,TTD,ZS (the 4 symbols I used to test)

The only time I can imagine Daily Streaming to be advantageous (and only ever so slightly so) is to quickly get the closing price for a Daily bar precisely at 4pm to immediately Auto-Place a post-market trade. It's hard to imagine a scenario that would be required, so I think we should actually disable Streaming for Daily+ strategies.
0
- ago
#54
Thanks. I was just grasping at straws because I couldn’t think of anything else to try in order to get it to work properly.
0
Cone8
 ( 4.98% )
- ago
#55
And I cannot get it to break.
0
- ago
#56
Do I need to submit a feature request for the solution @Glitch was thinking about in Post #1? WL submitted a Stop Buy today at 8:30:01 at 0.3% above the RETL open and (I assume) the price had already moved beyond that because Tradier rejected the order.
0
Glitch8
 ( 10.62% )
- ago
#57
Yes that would be a new piece of development so a #FeatureRequest would be in order.
0
Cone8
 ( 4.98% )
- ago
#58
Although it might be a good idea to have a feature that converts a stop order to market when the market is already moved past your stop, you need to be realistic about how you trade too.

In another thread we were talking about a 0.3% stop on a $8.21 stock at the open. You're looking to buy on a stop at 2 cents over the market open. Well, that occurred in the same second that the opening tick occurred - actually the very next trade - and 1 second after that the price was already at 8.28.



As you can see, there was no opportunity to get a 2-cent stop order in the market before the market had already gone past it. The market is volatile at the open and setting a 0.3% stop trigger on the opening price for a $10 stock is just too close. Just buy the damn thing.
0
- ago
#59
The idea was to avoid days when the market opens and immediately drops despite it not being able to avoid today's drop. Nevermind about the FeatureRequest.
0
- ago
#60
This burnt me again today. Do I need to start a new thread to put in a feature request to have WL submit a market buy order if market price is above the price of a Stop But order when the Stop But order was submitted, as well as an option for it to submit a market sell order if market price is below the price of the Stop Sell order when the Stop Sell order was submitted?
0
Glitch8
 ( 10.62% )
- ago
#61
I turned this into a #FeatureRequest for you.
2
- ago
#62
Thanks! Can I make this a concierge request so I don't have to wait for it to rise to the top of the wish list?
0
Glitch8
 ( 10.62% )
- ago
#63
Email concierge@wealth-lab.com and we can go over some ideas.
0
- ago
#64
Done, thanks!
0
- ago
#65
Thanks for implementing this feature! Can’t wait to try it!

1) Does the new “Convert Limit/Stop to Market if current quote exceeds price” checkbox also make Sell at Limit/Stop orders execute as Market orders if current quote goes below order price?

2) Does this work for Short Limit/Stop orders?

3) Does it also work for Cover Stop/Limit orders?
0
Glitch8
 ( 10.62% )
- ago
#66
Yes it works for all Limit/Stop orders.
1

Reply

Bookmark

Sort