Forex Factory (https://www.forexfactory.com/)
-   Platform Tech (https://www.forexfactory.com/forum/69-platform-tech)
-   -   Pair Strength Analyzer indicator (https://www.forexfactory.com/thread/513671-pair-strength-analyzer-indicator)

hanover Nov 18, 2014 2:10am | Post# 1

Pair Strength Analyzer indicator
 
7 Attachment(s)
NOTE: I'm happy to share some of the indicators that I've written for my own use, but I'm not offering a general programming service. Sorry, and please don't take this personally, but I will henceforth be ignoring and disliking any posts that are off topic, because they clutter the thread and make it more difficult for members to follow information relating to the PSA indicator.

Pair Strength Analyser (PSA) indicator

This is an indicator that I use as an adjunct to my strength indicators (here and here), to confirm strength/weakness by using a very different algorithm. I wrote it back in 2011, but I’ve finally decided to share it publicly. It's the most flexible and versatile strength indicator that I've seen (it was intentionally designed that way), especially as it allows for data from multiple timeframes and periods to be weighted, and then the result for each pair, and currency, to be presented as a single, consolidated value. (However, this arguably makes it less user-friendly; you're presented with a completely 'blank slate' consisting of a large number of entry parameters with no recommended settings).

The indicator uses linear regression models to rank both pairs and currencies, from the strongest trending down to the most sideways moving, according to the parameter settings that you choose to apply. For further description, instructions, disclaimer, and terms, please read the attached PDF document.
(For a more detailed explanation of how the LengthsForRegr, PeriodsForRegr and WeightsForRegr settings work, see this post; for more info on the RescaleUsingATR setting, see this and this; for the ResetPrevValues setting, this; for the FinalScaleValue setting, see this).

The indicator runs correctly for me on AxiTrader MT4 build 1170 and my Windows 7 setup. However, I have no idea whether it will work on other builds or computer setups. If you can’t get it to run, please look elsewhere for another strength indicator (there are many alternatives listed in the green typeface here), as I don’t wish to spend a lot of time troubleshooting or answering questions posted in this thread. Perhaps you've entered an invalid parameter setting: please read both this post, and the PDF, carefully.

The indicator has only been tested for the 8 major currencies AUD, CAD, CHF, EUR, GBP, JPY, NZD and USD. There's no guarantee that it will provide meaningful values for exotics, metals, commodities, indices, cryptos, etc, whose 'pipvalue' values can vary from br0ker to br0ker. (NOTE: however, you can now have the displayed values calculated on the basis of % change rather than the slope of regression lines; more info here).

The screenshot below shows that NZDJPY is the strongest uptrending pair (most positive value), GBPCAD is the strongest downtrending pair (most negative value), and AUDUSD is the most 'sideways moving' pair (value nearest to zero). However, if you change the parameter settings, the newly calculated values may be very different, hence changing the rankings of the pairs in the list. Also, please note that this indicator suffers from the same limitations as all price-derived strength meters (more info here and here).

The indicator is attached. Source code (.mq4 file) is NOT available. Please don’t ask me to remove the copyright message.

Finally, please don’t ask me which settings to use to trade most profitably (I use the indicator like this). The answer is that it depends on your personal trading strategy (more here). I’m supplying an indicator, not a trading system.

I hope that you find the indicator useful. To anybody who does, and posts a message of thanks, I appreciate the positive feedback.

David

Attachment 3405396
___________________________

Terms and Conditions

 All code is supplied FREE of charge. It may NOT be sold or distributed commercially. Unless otherwise shown, no source code is available.

 Software is offered on an 'as is' basis. I'm not offering a programming or troubleshooting service.

 There is no guarantee that the software is fit for purpose, or free of errors. Download and use the indicator(s) at your own risk; I accept no liability for computer damage or financial losses.
___________________________

Modifications History

Updated May 6, 2020New parameter setting option: IncludePairsInCrosstab
If FALSE, the indicator works as it did before, i.e. only the currencies summary (as opposed to pairs) is output to the specified CurrencyCrosstabFile.

If TRUE, the data across each line (row) of the file is date/time, pairs data, currencies data (instead of simply date/time, currencies data). Also:
The instruments displayed on screen are sorted alphabetically, to ensure that their values remain consistently in the same column of the output. (If you want the instruments to display on screen sorted by strength/weakness, you will need to run a second instance of the indicator on another chart, with a different UniqueID). If you add/delete pairs in the list, you will need to re-align prior history in the output file manually.
 Only the first column of values is output, regardless of the value in PrevValuesToDisplay.
The data can't be used in either of the attached Plot PSA Crosstab indicators. If IncludePairsInCrosstab is true, attempting to plot the data in a crosstab file will likely cause unpredicatble results.
As with the prior versions of the Crosstab option, a line (row) gets added to the end of the file once per RefreshPeriod, and also any time the indicator is manually refreshed. You will need to let the indicator to run for a while to accumulate a decent size history; obviously the shorter the RefreshPeriod, the faster historical data will be collected and appended to the file (and the more quickly the file will become large!)
For more info on the Crosstab option, see note 3 in the 'Updated Sept 29, 2017' section below.
___________________________

Updated March 30, 2020Addresses this request by adding new parameter setting SortMethod. Valid options are:
0 (default value) = List is sorted according to FinalSortValue (explained here) and CcySummaryOpt settings, i.e. works as it did previously.
a = Pairs list is sorted in ascending alphabetical order of SymbolID.
A = Both pairs and currency lists are sorted in ascending alphabetical order.
d = Pairs list is sorted in descending alphabetical order of SymbolID.
D = Both pairs and currency lists are sorted in descending alphabetical order.
___________________________

Updated March 14, 2020Added new parameter setting SmoothSlopeUsingLogarithms. Applies only if RescaleUsingATR is not = %. Reduces the calculated slope by appying a natural logarithm to its value, thereby reducing the variance between different slope values.
___________________________

Updated March 6, 2020Fixed a couple of small bugs. Also added new parameters:

ShowAngleText -- if true, displays the angle (or movement %, if RescaleUsingATR = %) above each line, if you have MT4's 'Show object descriptions' (type F8 for Properties/Common tab) checked ON; or in the help popup bubble when you hover the mouse cursor over a line, if checked OFF.

ShiftLinesToConvergence -- if true, and RescaleUsingATR is not = %, the lines are shifted up/down (without changing their slope) so that they all converge to the current price. If false, the regression lines are not shifted. Has no effect for RescaleUsingATR = %, since the lines converge to the current price regardless.
___________________________

Updated March 3, 2020PSA now includes the option of actually plotting the regression lines, from which its calculations are based, on the price chart. This allows you to see the slopes and weights of the lines that contribute to the final printed value. The new parameter settings are:

PlotRegressionLines -- if set to true, the lines will be plotted.

LineColorForTF -- enter up to 9 colors, separated by commas, that correspond the timeframes you've specified in PeriodsForRegr. The lines are always solid, and their width is determined by your WeightsForRegr entries. You can enter valid MT4 tokens (e.g. Crimson, Goldenrod, SaddleBrown, MediumSeaGreen, DarkSlateGray, etc -- see the color chart here) or RnnnGnnnBnnn where each nnn is a value between 0 and 255 representing the red, green and blue components of the color (e.g.B255G255 is Aqua).

Example: if
PeriodsForRegr = H4,D1
WeightsforRegr = 5,1
LineColorForTF = White,Yellow
Then the regression lines plotted for H4 will be white, width 5; while the regression lines for D1 will be yellow, width 1. Lines are plotted for each entry in LengthsFor Regr, and are shifted up/down (without changing their slope) so that they all converge at the current price. Of course this applies to the current chart's pair only. However, you can change to charts of different pairs, and compare all of the slopes that are averaged to give the final consolidated value.

If you set RescaleUsingATR to %, then PSA simply plots the trendlines from the closing price of the historical candle, to the current price, reflecting the % change (note that for timeframes other than the current chart, the lines are adjusted so that they plot from where the closing price of the candle on the selected TF (in PeriodsForRegr).)

If you set PlotRegressionLines back to false, the lines will vanish from the chart.

The latest version can be downloaded from the attachments below.
___________________________

Updated Feb 19, 2020 — enhancement to FinalScaleValue, it now works as explained here.
___________________________

Updated Sept 7, 2019 — New alerts feature and settings added:

PSA is now capable of generating both chart (audio/visual) and email-based alerts. Push notifications are not available, because the indicator was written prior to build 600. I'm not intending to provide b600 or MT5 versions. The email based alerts assume that you've completed the Email tab in the MT4 Options settings correctly (contact your telecoms provider if you need help with SMTPs etc).

There are 4 new parameter settings:

bool ChartAlerts = false;
Controls whether or not audio/visual 'popup' alerts will occur.

string AlertEmailSubject = "";
If blank, no email alerts will occur. If non-blank, this text will appear in the email subject, and the alert message in the email body.

int AlertThreshold = 0;
This determines at what value alerts will trigger, for items in the pairs/instruments section. For example, if set to 90, an alert will be generated whenever the printed value has moved from < 90 on the previous refresh, to >= 90 on the current refresh; or the printed value has moved from > -90 on the previous refresh, to <= -90 on the current refresh. The refresh frequency is controlled by the PSA's RefreshPeriod setting.
If alerts for multiple instruments occur simultaneously, they are all gathered up and posted as a single alert.
To stop alerts from being triggered for pairs/instruments, leave this set at the default value of 0.

int AlertThresholdCcy = 0;
This works exactly the same way as AlertThreshold, except that it operates for the currencies section.

To confirm that it's working correctly, set PrevValuesToDisplay to 1. Then you can see what the values were on the previous refresh, and compare them to the current one. Note that if a value fluctuates above and below a threshold value repeatedly between refreshes, repeated alerts will be generated.

Everything else should work as it did before. I've tested the alerts as best as I can, but it's the weekend now and markets are closed. I'm away on vacation until the end of the month.
___________________________

Updated Aug 9, 2019 — I've made a small fix that allows PSA to correctly calculate and display the values of symbols with lowercase characters.
___________________________

Updated Aug 5, 2019 — I've made PSA a little more bulletproof, to correct any user entries that are less than meaningful:
(1) Any missing, zero or negative values in the list of entries in LengthsForRegr are assumed to be 1. Also, if you leave LengthsForRegr completely blank, it's assumed to be a list with just one value: 1
(2) If you forget to match the number of entries in PeriodsForRegr and WeightsForRegr, any missing (or zero, or negative) values in WeightsForRegr are assumed to be 1
Everything else — the calculations, display, outputs, etc — remain unchanged.
___________________________

Updated Oct 22, 2018 — PSA_Crosstab v2.ex4 added to downloads.
___________________________

Updated Aug 26, 2018 — I have made two enhancements (download the new version in the link below):
1. If you enter an asterisk (*) as the second parameter of HighlightPairs, the current chart's pair will be highlighted in the list displayed by PSA.
2. New parameter setting: SmoothnessMultiplier.
 If set to 0, PSA operates as it did before.
 If set to a positive (>0) value, PSA will calculate a standard deviation of all of the regression line slopes, in an attempt to establish which is the smoothest (as opposed to steepest) trending pair. Each of these values is then multiplied by your SmoothnessMultiplier value, before being displayed as an additional column at the right of the list (sorry, there is currently no facility to sort the list by the values in this column). If you use RescaleUsingATR, the slope values are likewise rescaled before their standard deviation is calculated. The lower the standard deviation value displayed, the smaller the slope deviation between the lines (the closer the displayed value gets to 0, the closer all of the lines are to being exactly the same slope) and hence the smoother the price movement. And vice versa.
___________________________

Updated Dec 17, 2017 — PSA now has the facility to use %gain as the basis for its calculations, as an alternative to regression line slopes. Enter %,nnn into the RescaleUsingATR parameter to facilitate this. Explained in more detail here.
___________________________

Updated Oct 25, 2017 — Fixed bug as outlined here.
___________________________

Updated Sept 29, 2017 — the PSA indicator (latest version -- see download file below) now contains these new features:

1. The histogram facility has been updated to allow a user-defined font. Hence the CSM font (download from ZIP file below; see this post for more info) can be applied to give the result displayed in first screenshot in post #215. If the font entry is omitted, the indicator uses the 'Wingdings' font as its default, like it did previously. (The effect in the screenshot is also created by setting the second entry to 73, which is the ASCII code for uppercase 'I').

2. A background panel facility is now available via the new parameter BGHeightHstartWidthColor. Entries, separated by commas, are
i) height (per row),
ii) horizontal start position (pixel number) -- this should closely match your Hpos entry in WindowCornerHposVposVspacing,
iii) width of background box,
iv) color of background box (can be any valid MT4 token, e.g. Maroon, MidnightBlue, SaddleBrown, or RnnnGnnnBnnn where 0<=nnn<=255 for red, green, blue components).
To have no background panel displayed, leave the parameter blank, and the indicator will operate as it did previously.
See screenshots in post #215 for examples.

3. An output file of the PSA's historical values (for currencies only, not pairs/instruments) is now available via the new parameter CurrencyCrosstabFile. Enter the name of the file, which will be output to the ..../MQL4/Files folder (or your specified subfolder). Leave the parameter blank, and no file will be output. File format is as shown in sample below, and a new row is appended to the file every time the PSA values are updated (RefreshPeriod), or the indicator is manually refreshed (use a text editor like Notepad to manually remove any unwanted rows). First entry on each row is the MT4 date/time that the row was output. If you're using multiple instances of the PSA (whether attached to the same or different charts), you should specify a different file name for each instance, to avoid the same file from being overwritten by multiple sources, causing unpredictable results.
Inserted Code
2017/09/18 01:00:02,AUD, -7886,CAD, -9771,CHF, -7199,EUR, -5234,GBP, 53589,JPY, -23520,NZD, 3160,USD, -72
2017/09/18 01:15:00,AUD, -8116,CAD, -9966,CHF, -6531,EUR, -4707,GBP, 53054,JPY, -23309,NZD, 3210,USD, 202
2017/09/18 01:30:02,AUD, -7854,CAD, -9916,CHF, -6451,EUR, -4574,GBP, 52946,JPY, -23479,NZD, 3340,USD, -1
2017/09/18 01:45:01,AUD, -8463,CAD, -9871,CHF, -6654,EUR, -4753,GBP, 53120,JPY, -23029,NZD, 3457,USD, 62
2017/09/18 02:00:01,AUD, -8421,CAD, -9770,CHF, -6630,EUR, -5000,GBP, 52863,JPY, -23007,NZD, 3639,USD, 189
2017/09/18 02:15:18,AUD, -8070,CAD, -9830,CHF, -6603,EUR, -4833,GBP, 52860,JPY, -23471,NZD, 3609,USD, 173
2017/09/18 02:30:02,AUD, -7764,CAD, -9947,CHF, -6581,EUR, -4851,GBP, 52584,JPY, -23371,NZD, 3564,USD, 204
2017/09/18 02:45:00,AUD, -7997,CAD, -10167,CHF, -6731,EUR, -5003,GBP, 52853,JPY, -23826,NZD, 3697,USD, 922
2017/09/18 03:00:00,AUD, -8127,CAD, -10176,CHF, -6819,EUR, -4696,GBP, 53071,JPY, -23764,NZD, 3387,USD, 926
2017/09/18 03:15:01,AUD, -7773,CAD, -10340,CHF, -6931,EUR, -4797,GBP, 53120,JPY, -23774,NZD, 3747,USD, 571
2017/09/18 03:30:04,AUD, -7727,CAD, -10294,CHF, -6419,EUR, -4596,GBP, 52941,JPY, -23879,NZD, 3420,USD, 356
2017/09/18 03:45:01,AUD, -7660,CAD, -10160,CHF, -7201,EUR, -4454,GBP, 53194,JPY, -24231,NZD, 3471,USD, 780
2017/09/18 04:00:01,AUD, -7336,CAD, -10246,CHF, -7049,EUR, -4330,GBP, 52979,JPY, -24529,NZD, 3726,USD, 504
2017/09/18 04:15:00,AUD, -7000,CAD, -10024,CHF, -7311,EUR, -4490,GBP, 52879,JPY, -24561,NZD, 3994,USD, 356
2017/09/18 04:30:01,AUD, -6244,CAD, -9823,CHF, -7251,EUR, -4619,GBP, 52787,JPY, -25073,NZD, 3984,USD, 12
An indicator like the 'Plot PSA Crosstab.ex4' (see download file below) can then be used to plot historical values that were previously displayed by the PSA (see screenshot in post #215). Note that if the PSA's RefreshPeriod is different to the chart TF, then the values plotted won't align under the correct candles on the chart.
___________________________

Updated Sept 5, 2017 — indicator now contains these new features:

If you set CcySummaryOpt to:
0 = currency summary options (at foot of list) is not displayed
1 = each currency value is the sum of all of its constituent pair values
2 = currency values are further scaled into the interval (-n,n) where n is the FinalScaleValue (assuming n>0)
3 = currency values are further scaled into the interval (0,n) where n is the FinalScaleValue (assuming n>0)
Currencies are always sorted from the highest positive value (most bullish) to the highest negative value (most bearish)

If you set FinalScaleValue to:
0 = the value displayed for each pair is simply the average of the regression line slopes; values are sorted from the steepest to the flattest (average) slope
n (where n>0) = values are further scaled into the interval (-n,n)
-n (i.e. n<0) = no scaling is performed, but values are re-sorted from the highest positive value (most bullish) to the highest negative value (most bearish)
___________________________

Updated Dec 6, 2015 — indicator now contains these new features:

1. HighlightPairs setting: PSA will now place a user-defined highlight mark beside any pairs you choose, making it easier to find them as they move up/down the list.

2. ShowCcySummary has been replaced by CcySummaryOpt: there are now 4 different options for the Currency Summary Table.

See attached PDF file for instructions.
___________________________

Updated Jan 10, 2015 — indicator now contains these new features:

1. PrevValuesToDisplay setting: Previous values can now be displayed as differences (increase/decrease from prior value) instead of the actual value itself.

2. The optional Histogram settings are now much more customizable. Any Wingdings symbol may be used as the bar character (see chart of Wingdings symbol codes here).

3. Parameters can now optionally be entered via a parameter/presets file (sample attached).

See attached PDF file for instructions.
___________________________

Updated Mar 31, 2015 — fixed bug described here by adding a new parameter: UniqueID. Updated files are attached below.

See attached PDF file for instructions.
___________________________

Updated May 1, 2015 — added new parameter setting HighlightPairs. Updated files are attached below.

See attached PDF file for instructions.
___________________________

Download Files
Updated March 14, 2020Added new parameter setting SmoothSlopeUsingLogarithms.
CSM fonts.zip
Plot PSA Crosstab.ex4
Plot PSA Crosstab v2.ex4
Pair Strength Analyzer.pdf
Presets---PSA.TXT
Pair Strength Analyzer.ex4

FerruFx Nov 18, 2014 2:25am | Post# 2

As always, well done

Rooi Nov 18, 2014 2:33am | Post# 3

Pair Strength Analyzer (PSA) Iím supplying an indicator, not a trading system. I hope that you find the indicator useful. David {file} {image} {image}

Thanks for sharing.

Will have a look at it

Rooi

bluefish Nov 18, 2014 2:44am | Post# 4

Thank you very much Hanover!

Motiram Nov 18, 2014 3:38am | Post# 5

Pair Strength Analyzer (PSA) This is an indicator that I use as an adjunct to my strength indicators, to confirm strength/weakness by using a very different algorithm. Iíve finally decided to share it publicly.
I hope that you find the indicator useful. David
Thank you Hanover for sharing Pair Strength Analyzer. Definitely your contribution will help a lot.
Regards,
Moti

Dr.Phoenix Nov 18, 2014 3:47am | Post# 6

Thanks, David.
As always, Perfect.

rizla101 Nov 18, 2014 4:01am | Post# 7

As always many thanks for another great contribution. All the best to you.

hannele Nov 18, 2014 6:14am | Post# 8

Wow perfect, Thank You David, very very generous and very very useful for me, thank you
cheers
hannele

j4d Nov 18, 2014 12:14pm | Post# 9

Pair Strength Analyzer (PSA) This is an indicator that I use as an adjunct to my strength indicators, to confirm strength/weakness by using a very different algorithm. I wrote it back in 2011, but Iíve finally decided to share it publicly. There is nothing magical about the indicator; it is merely another way of calculating trend strength. It ranks both pairs and currencies, from the strongest trending down to the most sideways moving, according to the parameter settings that you choose...
Hey David.. Thanks for sharing..

Hope your well..

ukmartin Nov 18, 2014 12:41pm | Post# 10

Many thanks for the Indicator

Akvisto Nov 18, 2014 3:28pm | Post# 11

Hi David,

also have to thank you..makes more easy to find trading chances...

All the best

Jo

4xPIPAHOLIC Nov 18, 2014 7:16pm | Post# 12

Nice, really nice

Thank you
4x

Erebus Nov 18, 2014 9:38pm | Post# 13

1 Attachment(s)
Totally AWESOME
Click to Enlarge

Name: 19-11-2014 12-36-50 PM.png
Size: 103 KB

sam30 Nov 18, 2014 9:53pm | Post# 14

more secret weapon shared here...

thanks a lot

po3lnyi Nov 18, 2014 10:40pm | Post# 15

Thanks a lot

forexdave1 Nov 18, 2014 11:15pm | Post# 16

This is really great, thank you Hanover. It would be excellent if we could start an alternate thread on discoveries and possible methods using this tool.

seatrader888 Nov 19, 2014 12:33am | Post# 17

thank you, hanover/david!

brgrds,
st888

Thass Nov 19, 2014 12:59am | Post# 18

Excellent !! Thank you.

sharemaster2 Nov 19, 2014 4:38am | Post# 19

Pair Strength Analyzer (PSA) This is an indicator that I use as an adjunct to my strength indicators, to confirm strength/weakness by using a very different algorithm. I wrote it back in 2011, but Iíve finally decided to share it publicly. There is nothing magical about the indicator; it is merely another way of calculating trend strength. It ranks both pairs and currencies, from the strongest trending down to the most sideways moving, according to the parameter settings that you choose...
Hi Han...

This Indicator is very good for those that trade the Basket pairs which I do. It really helps to know which pair group are likely going to be movers for the trading session and simply focus on those basket of Pairs. Basket Trading has its risks but with the right tools and a little bit of understanding and patience, you easily can make a few thousand pips a month after months. This changes your game and lifestyle indeed.

Thanks for deciding to share the tool hope you keep up with that spirit and share more tools you probably still have in your closet. The more you share the more good happens to you.

All the best and more green pips to you.

pipdripper Nov 19, 2014 4:58am | Post# 20

Feel great seeing the maestro back to the ff community.

It's an honor to have you back, David!


© Forex Factory