How to plot external weekly or monthly data on daily chart
Author: rmandel00
Creation Date: 3/23/2019 1:00 PM
profile picture

rmandel00

#1
I am using weekly data from FRED, to generate crossovers from fast and slow moving averages as entry or exit signals on daily SPY data. The program works and generates weekly signals.

1. I would like to plot the daily data from SPY with another pane for the FRED data also on daily chart. How do you do it? If I specify Daily data on the data pane I get a run time error. If I specify Weekly data the program runs correctly with weekly charts.

2. If I have an entry based on the weekly FRED data and an exit based on an indicator from the daily SPY can I exit on daily bars?
Thanks,
RichMan
profile picture

Eugene

#2
Generally you'll find guidance in the WealthScript Programming > Multi-Time Frame Analysis chapters, Daily/Weekly in particular. A simple forum search also gives pointers to the many examples like SetScaleWeekly & GetExternalSeries? or Adding a Weekly-bar overlay to a Daily-bar Strategy.

If you have a specific problem with your code, we don't charge an extra fee for posting it here (along with data loading range etc.) ;)
profile picture

rmandel00

#3
I thought I attached the file but here is the code. I would like to enter basedon the weekly and exit based on the daily. The exit from my code is at the end of the month not on a daily bar. You could run for any length (10 years is fine). I read over the SetScaleWeekly and Get ExternalSeries but couldn't adapt it to my need.
Thanks,
RichMan

CODE:
Please log in to see this code.
profile picture

Eugene

#4
1. You shouldn't use "bar+1" as this badly peeks into the future (and causes that runtime error):

CODE:
Please log in to see this code.


2. Have you see the Daily/Weekly chapter as I suggested? Note that when you employ this in your code, plotting a compressed series requires an extra call to Synchronize for this maDelta series:

CODE:
Please log in to see this code.


You'll find it in the WS Programming Guide.
profile picture

rmandel00

#5
With regard to the peaking, I had two thoughts, first if I use the open then I have a month to close the trade on the same bar as the entry is based on the monthly bar. Also, the indicator is based on the open while trade is based on the close? Is this not true?
However, I haven't been able to convert the data from the monthly indicator so that I can plot it on a daily chart? I have read the information and have tried several things but I always get a run time error stating "Can not convert monthly bars to daily bars". Please help.
RichMan
profile picture

Eugene

#6
QUOTE:
Also, the indicator is based on the open while trade is based on the close? Is this not true?

You're accessing the value of the HullMA indicator one bar before it becomes available in real life. This is peeking.

QUOTE:
I have read the information and have tried several things but I always get a run time error stating "Can not convert monthly bars to daily bars"

I have no idea what things you tried but sounds like it wasn't done correctly.

Also the problem is that your task is not being set clear. It started as weekly/daily. Then you show some code that doesn't even have any compressed scale logic. Now you tell about some monthly bars, having a month to close the trade etc (??)

If further assistance is required please rephrase your task as clearly as possible. Start from scratch if necessary.
profile picture

rmandel00

#7
Thanks, I figured it out from the link Adding a Weekly-bar overlay to a Daily-bar Strategy.
profile picture

Eugene

#8
Glad you got it sorted out.
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).