SetScaleWeekly & GetExternalSeries?
Author: brucev
Creation Date: 5/11/2011 5:22 AM
profile picture

brucev

#1
Hi,
I have daily data for an index, named xjo.
In the code below, I am trying to get a 50 week ema of this index.

CODE:
Please log in to see this code.


However, after executing the code, WeeklyXJO and xjo both contain identical values, and the plotseries plots the two lines on top of each other. I thought that the line "WeeklyXJO = Synchronize( WeeklyXJO );" would align the weekly values with each daily value.
This seems to work if I use the same code and the closing price of the symbol selected, just not if I use an external series.
Can you tell me where I have gone wrong?
Cheers,
Bruce
profile picture

brucev

#2
Hi,
also, this version using GetExternalSymbol does exactly the same as the above, and doesn't appear to produce a difference between the daily and weekly plots either.
CODE:
Please log in to see this code.

Now I am extra confused!
Any direction welcome.
Cheers,
Bruce
profile picture

Eugene

#3
GetExternalSeries is an undocumented method, and for some reason it does not seem to work correctly. Use GetExternalSymbol:
CODE:
Please log in to see this code.
profile picture

brucev

#4
Hi Eugene,

now the weekly ema is weekly, but the xjo.close is also weekly rather than daily?

If I take the line "DataSeries xjo = GetExternalSymbol("XJO",true).Close;" to above the setscaleweekly, then both are back to daily.

I am trying to get the xjo.close in daily and the weeklyXJO in weekly, so I can check when the daily index close crosses above/below the weekly xjo.close.

I have now created a new DataSeries xjo2, and assigned it outside the setscaleweekly, and it now seems to work OK...

... is the general rule to always assign external series within the timeframe you want to use them?

Cheers,
Bruce
profile picture

Eugene

#5
Hi Bruce,

I thought both DataSeries should be Weekly.

The general rule is to make all DataSeries operations within the compressed scale before restoring the scale back.
profile picture

Eugene

#6
In other words, SetScale* applies to the Bars object obtained on the scale which contains OHLC/V.

Here, the Bars object is Daily b/c it's gathered before SetScaleWeekly():
CODE:
Please log in to see this code.


On the other hand, the Bars object here is obtained on the compressed Weekly scale:
CODE:
Please log in to see this code.
profile picture

spikemc

#7
Hello
I4m using GetExternalSymbol and SetScaleMonthly programming in weekly.
I4m buying/selling Nasdaq Composite (^IXIC) attending to weekly bars, but I need monthly SP500 (^GSPC) and Monthly Coppock Indicator.

CODE:
Please log in to see this code.


If I run the Strategy over SP500 (^GSPC), not over Nasdaq Composite (^IXIC), SetScaleMonthly compress and decompress perfectly: 1 month = 4 weeks, monthly SP500 and Coppock OK.






If I run the Strategy over Nasdaq Composite (^IXIC), SetScaleMonthly compress and decompress wrongly:
Sometimes 1 month = 4 weeks, Sometimes 1 month = 8 weeks, monthly SP500 and Coppock wrong (?).



In fact, if I put the folder name of the DataSet where "^GSPC" is included (that is the same where I4m working)

CODE:
Please log in to see this code.


If I run the Strategy over SP500 ^GSPC (or ^IXIC) I have the same problem Sometimes 1 month = 8 weeks



Any idea?? Thanks in advance.
profile picture

Eugene

#8
I'm having trouble seeing why this weekly/monthly conversion isn't working as expected. Perhaps Cone knows better.

Nonetheless, here's a workaround for you using an undocumented call to internal BarScaleConverter class. Note: uses Community.Indicators to build Coppock DataSeries:

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

spikemc

#9
Thanks Eugene
profile picture

Eugene

#10
Another workaround (thanks Cone) not involving the BarScaleConverter class:

CODE:
Please log in to see this code.
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).