Indicator Calibration Problems / Bugs

We all know how important it is to have an accurate min/max range and step size for each indicator when building strategies. Because if these values are wrong/off, the indicator becomes useless, as it never generates a valid entry / exit signal and just wastes CPU time. The indicator calibration feature was invented for that, which is nice, but I still see big issues with it. Here are some examples of very strange calibrations, based on GBPJPY H1 in this case, but the problem exists for any other pair / timeframe combination. I´ve compared the relating SQ indicator in MT4 on the GBPJPY H1 timeframe with different period sizes (from 10 to 500) and checked the min/max values the indicator gives in the last 34 years of history data. Here are my findings of what SQ calibrates and the values the indicator really has in MQ4, just listing the ones that are extremely off:

SQ Calibration / MT4

Awesome Oscillator = -20 - 40 / -6 - 6
DeMarker = -3 - 2 / 0 - 1 (this one clearly always oscillates between 0 and 1 in MT4)
Momentum = 0 - 200 / 90 - 110 (it always oscillates between 90 and 110, regardless of the period used)
QQE = -80 - 100 / 0 - 100 (never saw this one having a negative value in MT4)
Vortex = -999999999 - 999999999 / 0.8 - 1.2 (this one seems to be a bug for sure)
Kaufman Efficiency Ratio = 0 - 0 / 0 - 1 (seems to be a bug too, it´s always 0 - 0 during calibration)

I can´t verify BB Range (SQ calibrates 0 - 40) and BarRange (SQ calibrates 0 - 20), nor Biggest Range (0 - 20) and Smallest Range (0 - 2), but given that all of them are full integer numbers, I highly suspect they are wrong too. In general, beside some clear bugs like with Vortex and KER, as well as Momentum, it seems that SQ needs a bit more sensitive calibration process. Right now, it seems to catch the absolute maximums that ever happened in the whole data. But that is pretty useless, because these extreme values sometimes happen just once in 20 years (or whatever time range you are using). So SQ will create a lot of strategies that use overly extreme values that never happen for most indicators, wasting a lot of CPU. In my opinion, a better calibration would be to use the AVERAGE values of the low and the high of each indicator, not just the extreme of each range. This would generate a lot more useful strategies, because most often you want to enter a trade during a normal range, not just once on an extreme, as this would result in a strategy that has just 1 trade anyway. Here is how I would suggest to implement the calibration:

Calculate the MEDIAN min and max value of each indicator on a period of 14, 100, 300, 500 length, then use the average of the previous median min and max values. That would give a useable range of each indicator during the calibration.

Thank you.
Attachments
  • Votes +11
  • Project StrategyQuant X
  • Type Bug
  • Status Fixed
  • Priority High

History

g
#1

geektrader

28.01.2021 06:36

Task created

g
#2

geektrader

28.01.2021 07:26
Voted for this task.
h
#3

hankeys

28.01.2021 08:56
Voted for this task.
h
#4

hankeys

28.01.2021 09:19

Attachment sqx.jpg added

Attachment mt.jpg added

mt.jpg
(490.18 KiB)
sqx.jpg
(138.05 KiB)

did you have same data and same ranges set in SQX and also in the MT platform?


i made some investigation with these results:


AWESOME OSCILATOR - looks good

DEMARKER - you are right, its an oscilator and everytime will be between 0-1, no calibration needed at all, could be hardcoded

MOMENTUM - you are right, SQX is out of borders

QQE - you are right, SQX is out with the negative values

VORTEX - we dont have any "LEVEL" buidling blocks, so we are doing calibration for nothing - question is, if we need some "level" building blocks, it depends what is the logic of this indicator

KER - i am getting good values from calibration, but there is no calibration needed - always between 0-1


so there are really some bad values and FIX is needed




g
#5

geektrader

28.01.2021 09:24

Hi Hankeys,


yes, same data and range, I am checking the full 34 years of history data to oversee the indicator values. I am thinking about coding a MQ4 Expert which outputs all these values in the way I want (formula explained above), so that I can manually enter the values if they cannot fix it. But they surely should.


About Vortex: you can check it in MQ4, the indicator comes with SQ, it outputs between 0.8 and 1.2. Not sure why we do not have any levels for it that are being used, as it outputs in that range. I haven´t checked all the single blocks and their settings yet, that´s the next planned step, but it will take some time, given that we have 400 now. But I will go through all of them manually. It´s the base of each strategy, this stuff must be 100% correct first, otherwise some indicators will be absolutely useless, as they are being used with totally useless values and hence are not really used in the logic of the created strategies, which is a pity.


More to come...

DR
#6

mentaledge

28.01.2021 09:24
Voted for this task.
b
#7

bentra

28.01.2021 09:30
Voted for this task.
g
#8

geektrader

28.01.2021 09:31
Btw, it would still be OK to keep the ones that oscillate between 0 and 100 or 0 and 1, simply because I want to use my personal step-size for these and additionally there are pairs where they do oscillate between 40 and 100 (or something else) and rarely hit 0, so I don´t want to generate strategies that have anything lower than 40, as those would be outliers that happen just 1 time and should not be included in a stable strategy. Hence, please keep them adjustable as they are now ;-)
JK
#9

Insanity82007

28.01.2021 12:56
Voted for this task.
k
#10

Karish

28.01.2021 13:49
Voted for this task.
MO
#11

mareko

29.01.2021 10:17
Voted for this task.
m
#12

mabi

29.01.2021 13:54
Voted for this task.
m
#13

Martin

31.01.2021 09:27
Voted for this task.
g
#14

geektrader

03.02.2021 04:10

Attachment SQ_Indicator_Calibrator.mq4 added

Attachment SQ_Indicator_Calibrator.mq4 deleted

Attachment SQ_Indicator_Calibrator.mq4 added

SQ_Indicator_Calibrator.mq4
(37.50 KiB)

I´ve finished an MT4 Expert that calibrates all indicators in the way that I would recommend to do it. Instead of using the absolute min / max values of "all time" like SQX does it right now when it calibrates the indicators automatically, it uses the standard deviation (nicely explained here: https://www.mathsisfun.com/data/standard-deviation.html) of all captures indicator values of each indicator from an array and also randomizes the periods for each indicator, since the resulting ranges for each indicator are vastly different if used with different periods (e.g. RSI with period 14 vs RSI with period 200), which is exactly what will happen once SQX generates strategies. It´s doing that on about 20% of the bars, to speed things up in MT4, as this is *extremely* slow there. You simply run it as an EA and do a backtest on the symbol / time frame and time range that you want to calibrate on. The output in the Journal tab are the recommended min / max / step size values for each indicator, which you can then enter in SQX "Calibrate Indicators" settings page. I am getting a huge increase in accepted strategies, because now SQX, once it generates strategies, "hits the sweet spot" a lot more than with the min / max method it´s been using internally, which generates many completely outlying entry conditions which will only happen once in a few years, which makes no sense.


The code is somewhat documented, so should be self explaining and I absolutely hope that this will be the new way SQX automatically calibrates indicators in the future. Mark: feel free to adapt my code into SQX / Java.


Please also note (as mentioned above) that the calibration for "Vortex" seems to be completely broken in SQX right now. I am also unsure what´s going on with BarRange / Biggest Range / Smallest Range, as, while I am using the formula from your own "mt4SQIndicators.inc" file, I am getting results in the 0.X range, while SQX currently always calibrates something >10 or 20.


As for the EA input settings:


MaxSteps      = 500;     // Max Step Size for the final calculations (just like you can specify it in SQX´s indicator calibration as well)
RoundToDigits = 6;       // Round the final results to how many digits?
LowestPeriod  = 14;      // Lowest Period used for calculating indicators when calibrating them (match to your min lookback period in SQX)
HighestPeriod = 500;     // Highest Period used for calculating indicators when calibrating them (match to your max lookback period in SQX)


Run the backtest as described above and be PATIENT! If you are getting out of memory errors in the journal, it means your backtesting time range is to long. Yes, MT4 sucks. This really needs to be implemented into SQX, as this will be magnitudes faster there (most likely ~1 second vs half an hour in MT4).


Cheers :-)


P.S.: I will extend this a little bit by allowing a multiplier for the standard deviation to cover more extreme (but still useful) ranges, in case someone needs that. Will update soon.

b
#15

bentra

03.02.2021 18:18
Very nice work! Hopefully team includes it or at least exposes the java as a snippet so we can rewrite it ourselves.
VO
#16

GRoundofInferno

03.02.2021 23:55
Voted for this task.
TB
#17

Tomas Brynda

05.02.2021 18:22

Status changed from New to Waiting for information

Attachment calibrationSettings.png added

calibrationSettings.png
(43.68 KiB)
Hi Geektrader,

thank you for your suggestions. I have already implemented the code, so it will be available in the latest dev build next week.

Please take a look at my screenshot. I've decided to make it maximally configurable so anyone can play with it and hopefully we will find some optimal settings which will be then set as default.


Here are a few quick points:

  • Every indicator field which has a @Parameter annotation can be configured to allow extended calibration using multiple values by adding @Calibration annotation
  • If no @Calibration annotation is present, a default value will be used
  • Outputs that are not needed for calibration calculations can be disabled by setting @Calibration annotation with disabled=true - it could fasten the calibration process a little bit
  • During computation, every parameter combination will be evaluated and min and max values will be calculated as mean +/- stdDev from all values. The global min/max values accross all combinations will then be used as a result. 

Just for a demonstration purpose, my example on the screenshot will produce following parameter settings:

RSI Period / sF / wF

10 / 10 / 4.236

20 / 20 / 4.236

50 / 40 / 4.236

100 / 80 / 4.236

200 / 160 / 4.236


min/max values will be calculated from Value1 only 


I think this kind of extension should provide everything you need. You can manually alter the calibration values as you wish.

If you provide me some list containing indicator parameters settings you think would be good to have tested during calibration, I will add it to the existing snippets and it will also be included in the next build.


Best regards,

Tomas





g
#18

geektrader

06.02.2021 04:56

Hi Tomas,


this looks nice! It woud still be good to a have a randomization for the period lengths like in my EA and having the user just set a min and max period (like in my EA too), but the way you suggest it, will also work, of course. One more point, you are saying "and min and max values will be calculated as mean +/- stdDev from all values. The global min/max values across all combinations will then be used as a result." I would prefer if you´d put ALL results from all periods into one array and calculate the StdDev from this instead of calculating the StdDev for each period separately and then using the global min / max of all StdDev´s. This does distort the results a good bit actually, as it is mathematically different compared to calculating the StdDev from ALL values and hence all indicator periods as ONE as done in my EA. However, it´s surely a good step in the right direction.


As for "good" standard indicator values, I am not a fan of that, I prefer to get those totally random as it has shown that my best strategies don´t use any of the standard periods for indicators that are "typical" amongst traders. So I might be the wrong person to ask that :-)


Have a great weekend and surely looking forward to this. Thank you :-)

TB
#19

Tomas Brynda

08.02.2021 11:41

Status changed from Waiting for information to Fixed

Ok, thanks for the feeback. I've made changes in the calculation algorithm as you suggested. 

Values of all calibration runs of the indicator are stored into an array and mean + stddev is calculated from all the values.


Regarding the random values - we've discussed this with Mark and we both don't like the randomized numbers very much, because you never know how will the values be distributed across the range and you can get different results after each calibration. So we've decided to let the numbers definition as I suggested earlier. You can put in some randomized numbers if you want.


Also I deleted the Calibration annotation and the calibration settings will be defined in a special configuration file /user/settings/calibrationSettings.txt. It should be much easier to configure that way.

The values from the config file will be loaded before each calibration, so you can change the values, run calibration and the results will immediately reflect the current settings.


Best regards,

Tomas

g
#20

geektrader

08.02.2021 14:52

Hi Tomas,


that sounds good. As for the randomization, you are saying: " because you never know how will the values be distributed across the range and you can get different results after each calibration". That´s exactly what the randomization is for and exactly what happens once SQX starts to generate strategies - it also randomized all the values. Hence doing the same via the calibration is just what will happen in reality later on and is reflecting this very well. Sure, each run of the calibration comes out with SLIGHTLY different values, but it´s really just slightly, I´ve tested this several times. At least this method reflects the reality of the strategy generation as close as possible.


Thank you :-)

g
#21

geektrader

12.02.2021 03:50
P.S.: I think you should additional allow to switch to the old method, instead of using the StdDev, using the min / max values in each array (the way the calibration worked until now). This way it will be really flexible.
b
#22

bentra

13.02.2021 22:12
@geektrader. Thank you so much for your work on this. Pretty much 100% of what you say makes sense to me and I hope you don't mind a friendly debate to satisfy my curiosity about your idea to add a random element to the calibration. Why would we want to have some calibrations produce a range of 2 to 11 and others 3 to 12 for instance? Isn't it best to just go 2 to 12 every time I press the start button thereby getting the best of both options and keeping a consistent range of strategies? I'm thinking I want my tasks/templates/ranges to always be as consistent as possible. (I'm assuming the auto calibration is turned on.)
g
#23

geektrader

13.02.2021 22:50
@bentra: thanks for the kind words, appreciated. Can you clarify what exactly you mean with "range"? Which range exactly?
b
#24

bentra

13.02.2021 23:22
Calibrated range of an indicator variable (min/max) derived from the calibration function.
g
#25

geektrader

14.02.2021 00:00
Oh, OK, but what exactly should be different? I did not fully understand what you mean.
h
#26

hankeys

14.02.2021 10:20
calibration is made in builder and in builder i know what martket and TF i am building - so calibration should be made on those data (best only on IS) and compute max/min values a make some logical rounding and compute steps
g
#27

geektrader

14.02.2021 17:34
That is exactly what it will do, just that it uses standard deviation instead of the total min/max values, which was the Intention of my suggestion
b
#28

bentra

17.02.2021 07:57
Yeah I love it all thanks again. I was just confused about the idea to randomizing the period lengths for the calibration process itself.
g
#29

geektrader

17.02.2021 20:51
Ah I get it. Well, that´s what SQX does too during the creation process, so that´s what we should simulate during the calibration as well.
g
#30

geektrader

24.02.2021 15:23

Attachment Untitled.png added

Untitled.png
(751.35 KiB)
I am not sure what you´ve implemented in the 131 Dev2, but the calibration results Dev2 gives, have clearly nothing AT ALL to do with what my calibration EA does. What Dev2 calculates right now, is complete nonsense. Just compare to my MT4 calibration EA.
h
#31

hankeys

24.02.2021 21:15
still not fixed the basics, like we are calibrating AROON, OSMA, REFLEX and VORTES but dont have proper building blocks with levels in signals


So whole calibrating for those building blocks is for nothing


on the other side we are still calibrating oscilators which always ranging between 0-1




Votes: +11

Drop files to upload

or

choose files

Max size: 5MB

Not allowed: exe, msi, application, reg, php, js, htaccess, htpasswd, gitignore

...
Wait please