Currency strength (like Hanover)

Place your new trading idea here to see if someone can automate it.
Locked
garyfritz

Currency strength (like Hanover)

Post by garyfritz »

Steve asked me to open a new thread on this...

This morning I posted a "currency strength" indicator that displays the relative strength of each currency, similar to the Hanover indicator we all know. But it sounds like mine is much simpler.

I was experimenting with it a bit, and I came up with something that looks very promising. I don't have the expertise to build it into an EA -- nor do I have the time, I was supposed to be working today, not playing with Empty4 :lol: -- so I'll toss it into the ring here and let Steve &etc look at it.

The initial indicator I wrote seemed to work well, but it was pretty noisy:
CurrStrength.gif
So I added a smoothing pass that runs the index values through an EMA:
CurrStrengthSmoo.gif
That made it a lot easier to read, and it would be a lot easier to use it for signals in an EA.

I started looking at the direction of the currency indices. In the chart below I have the CAD (orange) and JPY (purple) indices on the indicator, and CADJPY on the chart above it.

The vertical lines are a very rough attempt to mark signals generated by this logic:
* If the lines move in opposite directions, go long (green line) if CAD line is increasing, short (red line) if CAD line is decreasing.
* If the lines move in the same direction, go flat. (white line)
CurrStrengthSigs.gif
In a quick hand check, it appeared to do a very nice job catching the moves. But that relies on me reading the chart, and of course I'm not as particular as an EA. :)

Look interesting?

The indi with the smoothing is attached. I know how that saps your will to live, Steve :lol: but the important part is fairly straightforward. Just copy AUDUSD, USDCAD, USDCHF, EURUSD, GBPUSD, USDJPY, USDNZD into arrays, then calculate the index values:

Code: Select all

USD = MathPow(UsdChf[i]*UsdJpy[i]*UsdCad[i]/EurUsd[i]/GbpUsd[i]/AudUsd[i],1./7.);
AUDval[i] = USD*AudUsd[i];
CADval[i] = USD/UsdCad[i];
CHFval[i] = USD/UsdChf[i];
EURval[i] = USD*EurUsd[i];
GBPval[i] = USD*GbpUsd[i];
JPYval[i] = USD/UsdJpy[i];
NZDval[i] = USD*NzdUsd[i];
USDval[i] = USD;
Then calculate an EMA of each of the XXXval arrays, and the relative (noisy) index value for XXX is (XXXval - XXXEMA) / XXXEMA. Smooth that again with another EMA and you have the smoothed results above. (Smooth it *again* and you could use it for a signal line -- the index is going up if it's above its signal line & vice versa. That's not in the attached indicator.) The core logic starts at line 176 and it's fairly straightforward -- it just looks bad because I'm doing everything 8 times.

Warning: the indi seems to work fine on M1 - H4, but for some reason it goes wonky on D1 and above. I don't know why but I suspect it has to do with nefarious mysteriousness in the way Empty4 loads up the data history.

Gary
You do not have the required permissions to view the files attached to this post.
User avatar
nanningbob
Trader
Posts: 4560
Joined: Sun Dec 04, 2011 1:23 pm

Re: Currency strength (like Hanover)

Post by nanningbob »

I am familiar with Hanover's work but it seemed to eat up a lot of computer memory. Will look at this. Thanks.
I trade http://www.stevehopwoodforex.com/phpBB3 ... =38&t=3964,
I talk about my philosophy of trading here.
http://www.stevehopwoodforex.com/phpBB3 ... =38&t=3627
"The key to converting something useful to others is simplicity. Complexity is the enemy to execution." Tony Robbins
astral77
Trader
Posts: 171
Joined: Tue Nov 15, 2011 9:26 pm
Location: London

Re: Currency strength (like Hanover)

Post by astral77 »

Fantastic work Gary. Well Done. I loosely compared it with hanover and it seems to show comparable results. Will check it out later when my mind is functioning properly.

Kind Regards
Fx93
Trader
Posts: 83
Joined: Mon Apr 09, 2012 6:32 pm

Re: Currency strength (like Hanover)

Post by Fx93 »

Is it possible to treat this like stochastics for example, with an OB/OS level?

Also, from playing around with indicators, it would seem one could plot the difference level between these various lines, which would oscillate around 0. There may even occur divergence between price and these readings. One could postulate OB/OS levels of these differences for CT trades, being regression to the mean. Just some thoughts.
garyfritz

Re: Currency strength (like Hanover)

Post by garyfritz »

The indicator itself doesn't have fixed ranges like Stoch does. You could however do a "stoch-like" calculation using the indicator values, i.e. if the current value is halfway between the recent max & min, it has a "stoch" of 50, etc. I don't know if it would have any value for divergences &etc.

One other thing that I should warn you all about: I mentioned D1 doesn't work. And occasionally you will get wild spikes that throw the whole thing off. I don't know what causes this but I suspect problems in the data. (E.g. I discovered PFG's NZDUSD data is bogus, taking on values in the 63 range during last November. It looks like they got NZDUSD and NZDJPY mixed up. That could be causing the D1 problems.) So if your crim has wild data errors in any of the 8 pairs the indicator uses to calculate the indexes, it will cause problems with the indicator and presumably with an EA based on the same calculations.

Normally though, other than the D1 problems, all recent data seems OK.
garyfritz

Re: Currency strength (like Hanover)

Post by garyfritz »

Blast. Steve, I'm losing the will to live...

I tried to figure out why D1 didn't work. In the process of doing that, I remembered why I haven't looked at indicator code for a long time... it's because I never did figure out the #%#^#!! model for how the @#%@#$ things execute. I forgot they go back and re-execute bars arbitrarily when new data comes in. The code I wrote worked smashingly on static data over the weekend, but with new ticks coming in, now it's generating gibberish.

So, WARNING: this indicator code DOES NOT work properly when the markets are open, and at the moment I don't know how to fix it. The historical data it plots is OK, but recent bars will be garbage.

Sorry about that!!!
garyfritz

Re: Currency strength (like Hanover)

Post by garyfritz »

I've studied the indicator semantics some more, and I'm still not sure how to fix this.

Indicators use buffers. When new bars come in, Empty4 automagically increases the size of the buffer arrays and the price arrays and shifts everything by 1, and calls the start() function for any new bars. This works fine when you're doing some simple calculation like buffer[n] = High. The non-Relative case of the indicator works like that -- it just calculates the currency index values for the current bar, using the current pair data that was just copied into some arrays. No problem.

But the Relative indicator case isn't that simple. It uses **history** of past bars to calculate the EMA. The relative indicator value is (CurrentValue-EMA)/EMA. I used a variable to hold the current value of the EMA, and I updated that var on each bar. So e.g. I calculate the EMA on bar 100 using the previous EMA value from bar 101, and then I use that bar-100 EMA value to calculate the EMA on bar 99. If you go directly from oldest bar to newest bar -- as you do with static data when the market is closed -- that works fine. But when new bars come in, start() gets called again on just a few bars. You can't use a carried-forward variable to hold the EMA value because the bars don't get painted in consecutive order.

And I don't think you can use a parallel array either. I could store the EMA values for each bar in a parallel array, and refer to that pre-computed history when new bars come in. But when new bars come in, the indicator buffers get increased and shifted, and the parallel arrays **wouldn't**.

The only way I can think to do this is to scan back through the price arrays and calculate an SMA for each bar. That way each bar's SMA value is independent of what order the bars get displayed. That's pretty grubby but I don't see how else to do it. And I'm not sure I can do the smoothing that way.

Or maybe I could just force it to recalculate the entire chart each time, instead of using the Indicator_counted() function to minimize updates. That might actually be a lot LESS work, calculating a simple EMA on each bar, than having to loop back through the previous 50 bars, on each bar, to calculate an SMA on each bar. But not if I have to re-do the entire chart on each tick...

Help? Anybody with indicator experience, can you offer me some advice?

This is such a BLOODY STUPID IDIOTIC model!!! This is WHY there is such a problem with repainting indicators -- because the stupid damn thing keeps recalculating the last few bars, changing its mind retroactively. I've coded indicators on half a dozen different trading platforms and I've never seen anything like this -- nothing this complicated, nothing this confusing, and nothing that produces erroneous repainting indicators. Stupid %@#!$! braindead @%^@$%! CRAP!!T4!! :evil: :evil: :evil:
User avatar
Mediator
Trader
Posts: 13
Joined: Wed Nov 16, 2011 7:06 am
Location: Germany

Re: Currency strength (like Hanover)

Post by Mediator »

Hi gary,

live could be so easy, take the CCFp Indicator.
I recommend it some time in an EA board from steve to exchange the hanover module with this indicator but don't know where.

it provides you the same information and works on every TF you like Daily and higher too.

Attached is a modified version with many setting.

Cheers

Mediator
You do not have the required permissions to view the files attached to this post.
Guest

Re: Currency strength (like Hanover)

Post by Guest »

garyfritz wrote:This is such a STUPID IDIOTIC model!!! This is WHY there is such a problem with repainting indicators -- because the stupid damn thing keeps recalculating the last few bars, changing its mind retroactively. I've coded indicators on half a dozen different trading platforms and I've never seen anything like this -- nothing this complicated, nothing this confusing, and nothing that produces erroneous repainting indicators. Stupid %@#!$! braindead @%^@$%! CRAP!!T4!! :evil: :evil: :evil:
No, the problem is too many programmers do not know the proper way to create indicators.

Oh, and if Metrader 4 is such crap, why do continue to use it?
User avatar
SteveHopwood
Owner
Posts: 9754
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Re: Currency strength (like Hanover)

Post by SteveHopwood »

I know exactly how you feel Gary. Lots of sympathy.

Sq is one of the indi geniuses here, so I have sent him a pm asking him to take a look.

:D
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. [email protected] is the account.

To see The Weekly Roundup of stuff you guys might have missed Click here

My special thanks to Thomas (tomele) for all the incredible work he does here.
Locked

Return to “Ideas for Possible Automation”