Linear Regression Universal Strategy, how to improve it?
Forums › ProRealTime English forum › ProOrder support › Linear Regression Universal Strategy, how to improve it?
- This topic has 32 replies, 6 voices, and was last updated 2 years ago by
GraHal.
-
-
08/25/2022 at 4:36 PM #19963408/25/2022 at 9:25 PM #19963908/25/2022 at 9:37 PM #19964008/25/2022 at 9:43 PM #19964308/25/2022 at 10:04 PM #19964408/25/2022 at 10:50 PM #19964508/26/2022 at 8:52 AM #19965708/26/2022 at 9:26 AM #199658
For now, I have reluctantly given up on David’s original TS as it not work without ’round’ and with ’round’ it gets Rejected for not enough historical data.
I have a version of MaoRai54 running in Live Demo on 2 mins TF on EURUSD for the last 2 days, but it has yet to take a trade.
The original MaoRai54 posted version took too few trades for my trading profile. If I recall correctly there were many days / weeks even (?) where no trades were taken … due I think to too many restrictive conditions? I’d love to be corrected so if anybody wants to post results?
08/26/2022 at 9:51 AM #199662The “linear regression universal system” which I started yesterday in demo (time frame 1 day) is still running and has made two transactions…
Probably something else going on yesterday, that’s why it rained error messages…
1 user thanked author for this post.
08/26/2022 at 10:08 AM #19966308/26/2022 at 10:33 AM #199668I started yesterday in demo (time frame 1 day) is still running
On the strength of above, I just started my M5 version of David TS.
First full 5 min bar it got Rejected for
not enough historical data to calculate at least one indicator etc
Seems Rejections are linked to TF’s at < 1 day fo some weird reason?Anybody got any ideas (Roberto?) … here’s the code (optimised for 10K bars) that gets Rejected at first full 5 min bar,
123456789101112131415161718192021222324252627282930313233343536373839//-------------------------------------------------------------------------// Main code : David LinReg DJI M5 10K v1gh//-------------------------------------------------------------------------//https://www.prorealcode.com/topic/linear-regression-universal-strategy-how-to-improve-it/#post-199478//Linear Regression Universal Strategy//DJI// timeframe : M5// Spread: 5// created and coded by davidelaferla//————————————————————————-defparam cumulateorders=falseDEFPARAM PRELOADBARS = 10000//***********************************************************************************************************ONCE A15 = 25.0ONCE A16 = 10.0ONCE A17 = 0.8N = 1//------------------ VARIABILI DEL SISTEMA---------------------------------------//CNHJPY Values: -------------------------------------------- Ottimization infoVolatilityperiod=A15 //15// different fixed value for each currency pair: range=3-20, with step=1Regression1period=A16 //18// Linear Regression Imput Signal: range=6-100 with step=1Regression2period=A17 //1.3//Linear Regression Output Signal: range=1-2, with step=0.01//***********************************************************************************************//------------------ INDICATOR ---------------------------------------hv=HistoricVolatility[VolatilityPeriod](close)hv2=HistoricVolatility[VolatilityPeriod](typicalprice)st=linearregression[ROUND(Regression1Period*hv)](close)lr=linearregression[ROUND(Regression1Period*Regression2Period*hv2)](typicalprice)// Condizioni per uscire da posizioni short e entrare su posizioni longIF st<lr THENBUY n contract AT lr stopENDIF// Condizioni per uscire da posizioni long e entrare su posizioni shortIF st>lr THENSELLshort n contract At st stopENDIF08/26/2022 at 11:10 AM #199670@ JS
@GraHal
Comments on my itf :
- I started from the version of Davide then I applied different TF to try to get more triggers
- I added the long part at the beginning to have increase/decrease of number of contracts based on profits. that’s why you’ll see many variables
- in addition H1 and H2 are the best hour to operate
- furthermore, to reduce the amount of losses based on contract q.ty I divide the SL by the number of contracts. So in case of multiple q.ty the maximum SL amount remains the one of 1 contract
- finally, I’m running it with basic TF 15M and, at the moment, only for Eur/$. I’ll try other later.
The result of backtest are quite poor but constant:
- Eur/$ period July 2018 – Aug 2022
- winning rate 71%
- 1897 trades
- +0,90 $ average per trade
08/26/2022 at 12:22 PM #199672Hi GraHal, hi all,
maybe worth trying these 2 modifications together for lines 29-30 of your #199668?
(a) change the period to max(1, ROUND(Regression1Period*Regression2Period*hv2)) in order to avoid a zero period in case of low hv or hv2, and still keep the “round” spirit (read: not use ceil when not necessary above 1)
(b) add an “if” statement on barindex to make sure hv and hv2 actually exist when calculting these periods for lr and st: if barindex>=VolatilityPeriod then…
All together:
1234if barindex>=VolatilityPeriod thenlr=linearregression[max(1,ROUND(Regression1Period*Regression2Period*hv2))](typicalprice)st=linearregression[max(1,ROUND(Regression1Period*hv))](close)endifIf it doesn’t work I can try to have another look, but it’s all I can think of for now…
1 user thanked author for this post.
08/26/2022 at 12:33 PM #19967308/26/2022 at 1:16 PM #199675ok, as it solved display issues with returned lr and st in probuilder, I was hoping to avoid the pain of adding another system in proorder… but I tried and got it rejected too.
With it working in probuilder and not proorder it made me look at orders code lines, two thoughts: (1) I never tried sending pending order « from the wrong side », and position of price wasn’t checked to decide if pending order at stop or at limit is more appropriate, so I modified code as follows in case wrong side pending order was messing things up :
IF st<lr THEN
if close<lr then
BUY n contract AT lr stop
elsif close>lr then
BUY n contract AT lr limit
ENDIF
endif
//
IF st>lr THEN
if close>st then
SELLshort n contract At st stop
elsif close<st then
SELLshort n contract At st limit
endif
ENDIFand (2) st and lr are highly likely to be within minimum stop distance and without stop readjustment box checked system is likely to get stopped fast, so I tried again checking the box…
But even with those further 2 changes, got it rejected again… sorry…
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on