Login Page - Create Account

Support Board


Date/Time: Sun, 28 Apr 2024 05:56:49 +0000



[User Discussion] - Offering To The Community: Forex: Currency Decorrelation (and Currency Strength)

View Count: 10062

[2018-11-26 17:22:11]
Halco - Posts: 92
Thanks Brett but this is some kind of glitch. Recalculate doesn't work because the study is always disabled. For instance if I input the AUD I have these charts in the symbol list:

AUDCAD (AUD CAD), AUDCHF (AUD CHF), AUDJPY (AUD JPY), AUDNZD (AUD NZD), AUDUSD (AUD USD), EURAUD (EUR AUD), GBPAUD (GBP AUD)

These are daily charts with only 501 days loading. Theses 7 charts open almost instantly, then after these charts open any additional charts are just these same 7 symbols over and over again.

It doesn't matter if I set it to limit 7 charts or leave it at 200, it disables the study after all the charts open and gives me that same error msg.

What I don't understand is why I'm having this looping/disable problem only with daily charts, and why you are not having the same problem if we are both using the latest version of SC.

I suppose I should ask SC support about it since you are not experiencing the same issue. Thanks again.
Date Time Of Last Edit: 2018-11-26 17:53:55
[2018-11-26 18:43:30]
bjohnson777 (Brett Johnson) - Posts: 284
I doubt SC support would even look at it. I'm on v1842 as of this post. Make sure you're not on a pre-release version. It sounds like old settings got stuck somehow. Also make sure you recompile any add on's for every new SC version.
[2018-11-26 19:49:22]
Halco - Posts: 92
He shoots, he scores! That was the problem, I was using the pre-release. I downgraded to 1842, deleted the dll, recompiled the cpp, all is well and good. Thanks!
[2018-12-08 11:42:49]
Halco - Posts: 92
USDCHF 4 HR chart with Relative Strength vs the USD index in the bottom pane. Note following A the downtrend in price continues but the RS starts going sideways. At B price makes a substantive low vs A but RS makes a higher low vs A. At C price makes a substantive low against B while RS makes a higher low vs B.

I haven't attached the chart but between C and D the USD index and CHF index are trending opposite each other and the DFP shows the majority of currencies weak against the USD and strong against the CHF.

And of course during this time the USDCHF RS is showing strength against the USD index as per this chart.

What follows is a nice uptrend.

Note also how RS gives early warnings of the ends both of the trends on this chart.

BTW, just to be clear, the label in the RS pane says "USD-X" but the RS is against the decorrelated USD index.

http://www.sierrachart.com/image.php?Image=1544269051982.png
Date Time Of Last Edit: 2018-12-08 13:16:05
[2018-12-15 21:40:19]
Halco - Posts: 92
Hey Brett, I'm back to bug you again. David Letterman used to do a bit called "Is This Anything?". So I'm wondering, is this anything:

It's kind of a breadth indicator, based on the closing slope of each of the 7 currency lines in the DFP study. In a spreadsheet study I sum the number of the down-sloping currencies and then I plot that as 7 and 21 period moving avgs on the chart. So if the ma is going up the primary currency is gaining strength because more of the other 7 currencies are weak against it and if it's going down the currency is getting weaker as more currencies are strong against it. Of course some may be flat, I haven't adjusted for that yet. This is crude at this point, experimental. And bear with me, I'm learning how to create spreadsheets studies while I'm doing this. I can do simple stuff in Excel so I know just enough to squeak by here. I think I've setup everything correctly.

This is a 20-min chart of the USD decorrelated index with the "breadth indicator" below it. A-B is a small trading range (within a larger range), at B the highs are equal to A in the currency while the indicator makes a lower high. At D the index springs C with a lower low but the indicator makes a higher low. At D to E there is a breakout and uptrend, confirmed by the indicator.

This is just one bit of one chart, but I'm intrigued. There are all kinds of refinements you could experiment with such as different ma periods or you could make the formula for the last 2 closes down, or 3, or the last 3 out of the last 5. Or maybe also make an up-sloping version, then plot them both as a ratio. Maybe apply some kind of standard deviation of the ma's.

It would certainly be better with more currencies, 10 would be nice, but this is still interesting.

Anyone have any thoughts? Thanks!

http://www.sierrachart.com/image.php?Image=1544909594427.png
Date Time Of Last Edit: 2018-12-16 09:10:50
[2018-12-17 10:02:15]
bjohnson777 (Brett Johnson) - Posts: 284
My health problems have given me a really bad weekend, but I think I've got a general idea about what you're talking about. Since I'm a C++ programmer, I've never bothered to learn the spreadsheet side of SC, so my responses will be more from the programming side.

This kinda sounds like an indirect measurement of the primary line from all the secondaries creating a forward looking indicator.

Instead of summing all the down slopes, a percentage would probably be better. A percentage won't care about about flat and up because it handles everything at once. Math:
Percent = Down / (Up + Down + Flat)
Simplified a little more, Percent = DownCount / TotalCount
This will give a range between 0.0 to 1.0, where 0.0 is 0% (all secondary lines are going up, very weak primary) and 1.0 is 100% (all secondary lines are going down, very strong primary).

The weakness in this is not accounting for distance each secondary line has travelled in the up or down direction. That accounts for some of the noise and strong smoothing requied to clean it up. If all the secondary lines blip up for a single bar, that would send the primary indicator to 0%.

Your comment about counting the last few closes would kinda add the missing distance calculation. Maybe each secondary line gets a percentage calculation like the one above and for the final primary indicator, all those secondary percentages get averaged together. The weakness in this is the bar back count. Count enough back and most of the lines would be wiggling around 50% instead of making larger moves. Maybe 10 bars back would be the max.

There's also a possiblity of skipping percents and going for pip movements since all my price lines are proportionally scaled to each other. In that case it would be counting pips up and down for all the secondary lines. Weakness: technically a percentage would be cleaner from the math purist perspective. That way scaling is always relative to some kind of percentage point count.

Something to look out for: Getting too much math in this might just recreate the primary line, which doesn't work so well for a forward looking indicator. This is a kind of over engineering gotcha.

Another thing to experiment with would be putting RSI's on each of the secondary currencies and averaging those together for the primary indicator line. In testing, compare that to an RSI against the primary indicator line to see if something stands out and really makes a difference.

Adding more currencies into the calculation really won't do too much more beyond the standard 7 since that's what everyone else uses. If you're trading some of the lesser currencies, then yes, it would be needed. For the time being, keep things simple with the major 7.

Keep playing with all this. When I was experimenting with the new indicators in my tool kit, I would watch them for weeks to see how they responded. There were many failures that I would just dump... and sometimes I would do a total gut and rewrite into something new before I found something I was happy with. The process starts out with something that looks good for historical data. Next it's taken into some kind of live trading (paper or actual money) to see how well it responds and indicates for real time. If real time starts giving good trading signals, then it's close to done.

Doing active trading right now for the next few weeks is a really good opportunity for seeing normal volume and low volume for the end of year holidays.

Open up a new text file and start taking notes about the possibilities I've mentioned, volumes, and the problems you haven't mentioned in the post. Also write down dates for interesting chart patterns and things that go right and pitfalls that go wrong. This text file will become your build journal. If you look at my various indicators, I'll mention the good and the bad. The journal is where this comes from and is very important. In the scattered notes in my journal, some of the separate variations of indicators were born out of this.
[2018-12-18 09:11:07]
Halco - Posts: 92
Thanks for the input, Brett. Very helpful. I changed it to percentage, looks better. Will keep working on it.
[2019-01-11 21:31:54]
Halco - Posts: 92
Hi Brett. I'm a bit confused. I compared the AUD-X and USD-X to your corresponding indexes on the weekly and 20-min charts and they appear to be exactly the same. I've attached the 20-min AUD. Shouldn't there be some differences? Am I misunderstanding something?

http://www.sierrachart.com/image.php?Image=1547241847908.png
[2019-01-12 12:58:02]
bjohnson777 (Brett Johnson) - Posts: 284
Bump up your screen brightness a little. Top left says AUD-X and middle left says AUD Index.
[2019-02-12 05:51:53]
bjohnson777 (Brett Johnson) - Posts: 284
Minor update to compile with the new SC version.
[2019-02-13 09:30:43]
Trint - Posts: 112
Thank you Brett, your indicators are great and I'm using them quite frequently. Did you find the last minor update critical as it seems I can still the older versions with the latest SC.
[2019-02-13 21:19:01]
bjohnson777 (Brett Johnson) - Posts: 284
I had to rename a couple pointer fetch functions to the new names. Any time you update SC you should also recompile any custom studies you have. Usually you can get away with it for awhile, but eventually something will break. Considering there is money involved, that could be costly at a very bad moment.
[2019-02-14 10:42:32]
Trint - Posts: 112
Yeah I found the persistence variables in one of my custom studies had broke on an update and the naming had changed. Unless the 'Whats New' feature shows something I can make great use of I generally leave updating for a while if nothing has broken.

I hope things are going as well as they can at your end Brett.
[2019-03-05 10:29:31]
ARDAN - Posts: 66
Hi Brett,
I'm trying to open daily charts with your wonderful study.
As I can see that It opens exactly the same chart for each pair 14 times. Is there a specific reason for that? Or is it a loop?
I look at 8 major currencies including USD so this makes 28 pairs in total. Can I make it work with 28 charts for each time frame? 28charts for daily, 28charts for 4hourly, 28charts for hourly, 28charts for 15M, 28charts for 5M, 28charts for 1M.

I'm always stuck while running the study in daily/weekly/monthly charts. Please advise.
How many charts should I set for "limit number of open charts" setting? I tried 200/300 but I could not view anything yet with daily/weekly/monthly charts.
Thank you again for the great contribution.
Date Time Of Last Edit: 2019-03-05 10:35:55
[2019-03-05 11:54:42]
ILIM KIRGIZ - Posts: 187
Brett,
I made a mistake in the previous version of this post so I'm now updating it. Sorry.

I set these currencies to Symbol List input of Currency Decorrelation Study. Basically 28 pairs of 8 major currencies.
AUDUSD (AUD USD) 1.0, EURUSD (EUR USD) 1.0, GBPUSD (GBP USD) 1.0, NZDUSD (NZD USD) 1.0, USDCAD (USD CAD) 1.0, USDCHF (USD CHF) 1.0, USDJPY (USD JPY) 1.0, AUDCAD (AUD CAD) 1.0, AUDCHF (AUD CHF) 1.0, AUDJPY (AUD JPY) 1.0, AUDNZD (AUD NZD) 1.0, CADCHF (CAD CHF) 1.0, CADJPY (CAD JPY) 1.0, CHFJPY (CHF JPY) 1.0, EURAUD (EUR AUD) 1.0, EURCAD (EUR CAD) 1.0, EURCHF (EUR CHF) 1.0, EURGBP (EUR GBP) 1.0, EURJPY (EUR JPY) 1.0, EURNZD (EUR NZD) 1.0, GBPAUD (GBP AUD) 1.0, GBPCAD (GBP CAD) 1.0, GBPCHF (GBP CHF) 1.0, GBPJPY (GBP JPY) 1.0, GBPNZD (GBP NZD) 1.0, NZDCAD (NZD CAD) 1.0, NZDCHF (NZD CHF) 1.0, NZDJPY (NZD JPY) 1.0
chart time frame: 1 hour
chart days to load setting is 120 days.
other currencies bar back setting is 300
limit number of open charts 200

I've made two 2 tests.
1. I set "currency to decorrelate" input as USD and "decorrelate other currencies" input to yes.
2. with all the same settings above, I duplicated the chart and I set "currency to decorrelate" input as EUR and "decorrelate other currencies" input to "NO".
I could only view " in FLAG: Active Symbols Used field It is 7 again.
Then I moved the EUR Index from chart #1 to the second chart via Study/Price Overlay study.

There is some difference between these two EUR Index results. See attached screenshot.
As I need individual strength of each currency of 8 majors, which method do you suggest to separate every one of them decorrelating from a single study (option 1) or decorrelating each symbol one by one(2) then combine them into a single chart?

Thanks.
Date Time Of Last Edit: 2019-03-05 12:49:54
imageFX_Dec.JPG / V - Attached On 2019-03-05 12:47:28 UTC - Size: 129.64 KB - 672 views
[2019-03-05 14:45:10]
bjohnson777 (Brett Johnson) - Posts: 284
ARDAN: When a custom study starts doing strange things that it didn't used to do, it usually needs to be recompiled for the new SC version. Each time you update SC, you should recompile anyways. The externals may look the same, but the internal SC interface has likely changed. On more extreme examples, previous configs may have also gotten stuck in the chart. If that's the case, copy out the human readable configs and rebuild the chart.

The open chart limit makes an attempt to stop an infinite loop that sometimes happens with SC upgrades. 100 is usually enough. I default it to 200 to handle stray cases.

SC can get a little cranky with multiple time frames open (in theory it shouldn't care). If so, make a separate chart book for daily/weekly/monthly charts. That will keep everything clean.

----------

ILIM KIRGIZ: You have a few things going on.

For your selected Currency To Decorrelate, only symbols with that currency should be in the Symbol List. I think the others are erroring out and are ignored. This would explain the low FLAG values.

In the Other Currencies Symbol List, the symbols should have the Currency To Decorrelate symbol and one other symbol to multiply against. Having a bunch of extra symbols may be ignored or behavior will be undefined.

Any Currency Decorrelation is going to be a heavy calculation (especially tick by tick if you're using it). It's better to run one study instance and then pick out what you need with an overlay.

If you want a little more accuracy, you could play with the weightings a little. For example, USD and EUR will have far more volume than CHF and NZD, yet they are being treated as equal by default.

If there was an easy way to handle all the extra pairs in the chart study, they probably wouldn't do much and would likely skew weightings again. I'm guessing most banks have their own internally decorrelated value for each currency. Adding extra pairs as a kind of average would be like "(2.0 + 2.0) / 2 = 2.0".
[2019-03-07 20:01:50]
ARDAN - Posts: 66
Thank you, Brett. Compiling the source code resolved the looping issue.
[2019-03-15 06:26:14]
ARDAN - Posts: 66
Hi again Brett,
I've used the source code you published to compile new dlls with Sierra Chart Version 1882 32 bit but I got below error.
The remote build did not succeed. Result:

Forex_CurrencyDecorrelationAndCurrencyStrength.cpp: In function 'void scsf_Forex_CurrencyStrength(SCStudyInterfaceRef)':
Forex_CurrencyDecorrelationAndCurrencyStrength.cpp:1259:39: error: 'struct s_sc' has no member named 'GetStudyPersistentIntFromChart'
int& pOtherSymbolIndexNodeCount = sc.GetStudyPersistentIntFromChart(In_ChartStudy.GetChartNumber(), In_ChartStudy.GetStudyID(), PDpOtherSymbolIndexNodeCount);
^
Forex_CurrencyDecorrelationAndCurrencyStrength.cpp:1261:40: error: 'struct s_sc' has no member named 'GetStudyPersistentPointerFromChart'
char pStrExtractCurrency = (char)sc.GetStudyPersistentPointerFromChart(In_ChartStudy.GetChartNumber(), In_ChartStudy.GetStudyID(), PDpStrExtractCurrency);
^
Forex_CurrencyDecorrelationAndCurrencyStrength.cpp:1263:78: error: 'struct s_sc' has no member named 'GetStudyPersistentPointerFromChart'
s_ForexSymbolIndexNode pOtherSymbolNodeArray = (s_ForexSymbolIndexNode)sc.GetStudyPersistentPointerFromChart(In_ChartStudy.GetChartNumber(), In_ChartStudy.GetStudyID(), PDpOtherSymbolNodeArray);
^

-- End of Build -- 22:25:5

How I can resolve this?
Thanks.
[2019-03-15 13:28:30]
bjohnson777 (Brett Johnson) - Posts: 284
The SC Devs often make changes to the internals that require code fixes. I already fixed this one in the last release. Just download the new source from post 1 and recompile.

I usually upgrade my SC version late Sunday or Monday depending on my schedule and health. If there are changes that break the compile, they're usually fixed then. If there is a fix, I'll post a brief notice of it. Make sure you're subscribed to any forum threads that you're using code from and you'll get the alert.
[2019-03-18 07:53:47]
ILIM KIRGIZ - Posts: 187
I use 8 timeframes inside a chartbook each have FX DEC study for the respective timeframe.
I sometimes see this occurrence stated in the main post as a note.
"Note: The index lines will not be correctly drawn until all the other charts have finished downloading historical data. Sometimes malformed index lines get drawn until the other charts finish downloading. Sometimes those lines will be jumping around, too. This is normal behavior. If the index lines get stuck, either select Main Menu >> Chart >> Recalculate, hit CTRL-INSERT, hit INSERT, or go into the study settings and exit to manually force a redraw."

I also use Kiwi's resync study(shared in this post Kiwi Resync Study - Memory leak?) for this purpose. Is there any other way to overcome this issue? Thanks.
[2019-03-18 11:50:42]
bjohnson777 (Brett Johnson) - Posts: 284
Kiwi's code is just a blind reload. I'm not sure what the SC dev's are going to release. Generally speaking, that's not really something you want to be doing on a regular basis. Years ago when I was trading with Schwab, their chart program would overload and go out to lunch for a minute or so trying to catch up internally (Schwab used M$.Net and it was horrible). If you have multiple charts doing that and you're trying to make a trade, you're going to be at the mercy of how many other charts are reloading at once. There might be a risk for a timeout when talking to the trade server, too. If the trade server only gets part of the trade data when SC stops for a recalc, that might abort the trade and cause strange behaviors.

Once all the chart histories catch up, everything "should" stay in sync. My code depends on the SC internals for this.

With 8 time frames, you may want to try splitting those off into separate chartbooks. Internal SC threading may handle those better.
[2019-03-18 16:48:39]
User90125 - Posts: 715
Separate instances, maybe?
[2019-03-18 17:27:07]
ILIM KIRGIZ - Posts: 187
Thank you both.
I will test putting this chartbook to a new instance of Sierra Chart. The bad thing is I need to keep two copies of 28 forex pairs in 2 different data folders.
[2019-03-19 12:03:56]
bjohnson777 (Brett Johnson) - Posts: 284
If you're going for 2+ instances... I can't remember the exact term off hand, but there's a way to chain 2 SC's together so one will handle the network data and pass it to the other. Digging through the documentation should turn this up. That will keep downloading data at the same speed. If you're using tick data and don't need past ticks, be sure to compress that down to 1 minute bars every week or so. That will also relieve a large processing load.
Date Time Of Last Edit: 2019-03-19 12:04:20
[2020-09-15 04:54:44]
sjkafeero - Posts: 21
Thank you for this amazing piece of study. Unfortunately, its no longer being successfully compiled by SC version 2158 64-bit. How can I get accwss to the update Currency Strength study?
I get the error message:
The remote build did not succeed. Result:

Forex_CurrencyDecorrelationAndCurrencyStrength.cpp: In function 'void scsf_Forex_CurrencyDecorrelation(SCStudyInterfaceRef)':
Forex_CurrencyDecorrelationAndCurrencyStrength.cpp:557:25: error: 'struct s_sc' has no member named 'DailyDataBarPeriod'
557 | else {pBarPeriod = sc.DailyDataBarPeriod;} //also enables sc.DaysPerBar
| ^~~~~~~~~~~~~~~~~~

-- End of Build -- 05:54:01

Thank you
[2020-09-15 12:21:46]
bjohnson777 (Brett Johnson) - Posts: 284
Looks like lots of things got broken in the new SC version. I got this fix to "Remote Build" on 2168 I upgraded this morning. A quick test shows things working now, but give this a try and make sure you get the expected results. If there's a problem, I'll be back around late this evening to try and fix it.

Edit: (New source code is always attached to the top post.)
Date Time Of Last Edit: 2020-09-15 12:22:21

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account