Indicator updating and using SetContext
Author: Ray60
Creation Date: 5/8/2009 11:03 AM
profile picture

Ray60

#1
I am calculating an indicator based on a symbol using SetContext.() The indicator is not updating on streaming data when new candle is drawn. My strategy is using SSO but calculating the RSI on the VIX. My code is:

******
CODE:
Please log in to see this code.

******

I set up another strategy window to use VIX and calculate the RSI. I have used 5 minute and 15-minute candles and the same thing happens. When the new candle is drawn on the above code the RSI of the VIX is unchanged from the last period.

This is the code above:
Date Time RSI(Close(.VIX),21)
5/8/2009 11:10 AM 40.94083155
5/8/2009 11:15 AM 41.14825665
5/8/2009 11:20 AM 38.58686889
5/8/2009 11:25 AM 38.58686889 <-No change

This is from the separate strategy window using VIX:
Date Time RSI(Close,21)
5/8/2009 11:10 AM 40.94083155
5/8/2009 11:15 AM 41.14825665
5/8/2009 11:20 AM 38.58686889
5/8/2009 11:25 AM 44.0702373 <- Correct value

Is there some code that will solve this or is this a problem that should be passed on to the developers?
profile picture

Cone

#2
It appears to be a problem with external symbols, not just .VIX. Please create a Support Ticket. tia.
profile picture

luce50

#3
I am having a similar problem when trying to trade the ETF pair QLD/QID. I want my strategy to Buy the QLD when the QLD's first intraday bar's Close > Open. If the reverse is true (QLD's 1st intraday bar's Close < Open), I use the SetContext to attempt to purchase the QID.

It runs flawlessly in backtest mode. However, the streming data combined with the SetContext appears to cause the strategy to fail with a runtime error and stop working.

Ray60, did you get an answer to your Support Ticket?

Cone, is there a workaround?

Many thanks,

Robert
profile picture

Cone

#4
It's impossible to determine if this has anything to do with what Ray60 reported, which was the fact that updates for external symbols may not be in synch with the primary symbol. I do not believe that that any work was done to resolve that issue.

If you're getting an error, I urge to post its precise text as well as the Strategy used to re-create it. Use Support if you want to keep it private.
profile picture

luce50

#5
I am going to try to get my problem/point across again after eliminating multiple "peeking" issues. I have a "simple" strategy that WLP executes 30 seconds to 1 minute after the completion of the first intraday bar. I have a streaming chart of the QQQQ using intraday data (30 minute bars). At the end of the 1st bar (first 30 minutes of trading), I want to purchase the QLD if the the Close > Open of the QQQQ's 1st bar. If the Close < Open, then I want to purchase the QID.

Below is a portion of my code:

CODE:
Please log in to see this code.


The backtests work without error, however, in live trading I am getting a significant delay (30 seconds+) before the orders are staged.

How can I improve the response time?

Thanks,

Robert
profile picture

Cone

#6
Use a streaming chart.
profile picture

luce50

#7
I stated that I am using a streaming chart of the QQQQ. Do you mean that I should use a streaming chart of the other symbols as well? I'm not clear concerning your answer.

Thx,

Robert
profile picture

luce50

#8
Another point--Strategy Monitor is where I am experiencing the 30+ second delay. Does that help clarify my issue?

Robert
profile picture

Cone

#9
Not at all. Why would you tell me that you're using a streaming chart and then tell me that the problem is in the S. Monitor (like I suspected)?
profile picture

luce50

#10
You're right, i mixed two unrelated issues. Since we now know that your suspicion was correct, how can I improve the Strategy Monitor's response time for a multi-symbol program (i.e. QQQQ, QLD, QID)?

Many Thx,

Robert
profile picture

Cone

#11
If you're using fewer than 10 or 12 symbols in your DataSets, personally, I'd just set up a Workspace (or 2) with Streaming charts. Streaming charts will execute the script immediately when the end of interval is detected, which [with Fidelity streaming] should never be more than 2 seconds past the actual end of interval.

For the Strategy Monitor, make sure that your system clock is in synch with Fidelity's clock (use premarket time of sales, for example). The Monitor logic, I think, adds a 5-second buffer to the scheduled request time, so you might be able to cut a few seconds out by advancing your clock 3 or 4 (max) seconds. Also, you can save round-trip delays by breaking up your DataSets to 10 or fewer symbols and creating a new line in the Monitor for each 10-symbol set.

A gotcha in the Monitor with Strategies running with intervals greater than 10 minutes is alluded to in the User Guide: Strategy Monitor > Behavior as a function of Scale. If you have a thinly-traded symbol in your DataSet, it may not return data for the past interval, which can delay the processing for the entire DataSet.
profile picture

luce50

#12
That information is exactly what I was seeking! Thank you for the information.

Robert
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).