Is it possibile to get a system to optimize itself each x?
Forums › ProRealTime English forum › ProOrder support › Is it possibile to get a system to optimize itself each x?
- This topic has 16 replies, 4 voices, and was last updated 8 years ago by Robin.
-
-
04/18/2016 at 8:36 PM #5605
Hi,
Is it possibile to get a system to optimize a variable itself, for example, each month, and then use the new variable?
Thanks!
04/19/2016 at 7:53 AM #5615Hello, yes it is possible (never done it before, but got ideas on this..). But it also mainly depends of the strategy itself and how many variables to optimize and the criteria you’d like to be optimize? gain, drawdown%, sharpe ratio, etc.. ?
Beware that it would involve a lot of work though!
04/19/2016 at 6:20 PM #5676Wow, that would be amazing! 🙂
I have two systems in mind, one I wrote and one i found here:
https://sites.google.com/site/prorealtimecodes/my-backtests/ma-cross-optimised
Acctually a simple MA Cross, works good in backtests on OMX 5 min, probably on DAX as well. (I added stops and target.)I would like to use the 3 last past month to optimize “x” and “y”, “pl” and “pp”, and use the variable on the upcoming 4 month. The variable with highest gain.
So I would like to use januari, februari and march data, to use on upcoming april.
This optimizing would then happen each month, using 3 last past months.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354//-------------------------------------------------------------------------// Main code : MA Cross Optimized//-------------------------------------------------------------------------// ma_cross_optimised//works really well on 5 min ftse//variable y, slow ma//variable x, fast maREM Buyindicator1 = Average[x](close)indicator2 = Average[y](close)c1 = (indicator1 crosses over indicator2)IF c1 THENBUY 1 shares AT MARKET nextbaropenENDIFREM Sellindicator3 = Average[x](close)indicator4 = Average[y](close)c2 = (indicator3 CROSSES UNDER indicator4)IF c2 THENSELL AT MARKET nextbaropenENDIFREM Shortindicator5 = Average[x](close)indicator6 = Average[y](close)c3 = (indicator5 CROSSES UNDER indicator6)IF c3 THENSELLSHORT 1 shares AT MARKET nextbaropenENDIFREM Exit shortindicator7 = Average[x](close)indicator8 = Average[y](close)c4 = (indicator7 CROSSES OVER indicator8)IF c4 THENEXITSHORT AT MARKET nextbaropenENDIF// Stops and targetsSET STOP pLOSS plSET TARGET pPROFIT pp04/19/2016 at 6:26 PM #5677I use about min value: 1 max value: 300 and step: 5, when I optimize X and Y.
The author says: “Shows results of best historical ma crossing for time frame. No guarantee of future success though!”I think possibile future success could benefit from optimization each month 🙂
04/28/2016 at 3:28 PM #6161Hi, is this post still work in progress?
I currently trade similar 5 minute systems and manually optimise the variables each weekend for the upcoming week, looking back over a 4 week period to keep up with current market conditions. Getting the system to optimise itself would be a great help, especially when you need to optimise more than 1 market/system.
From what Nicolas said, it may be a lot of work, but it would be a really useful timesaver in the long run. You will also be able to play with the period of time looked back for the optimisation and see which period gives the best results over time.
Many thanks for all your help, this is a great website.
04/28/2016 at 5:15 PM #6169Thank you Robin for your compliment.
Optimization of what already happened is like rewrite the whole history. It not guarantee at all, that past behaviour of something would be the same in future. “Simple” optimization of parameters alone is not effective, it needs a lot of others confirmation to reduce the possibilities that optimized result are not curve-fitted. Human always needs everything to be the more perfect and that introduce a bias in our manner to build things, like trading strategies, and that’s where we fail.
Making an auto-optimization module would be quiet interesting for development and coding purpose, but be sure that it would not make anyone a millionaire 🙂
04/28/2016 at 5:46 PM #617104/28/2016 at 9:19 PM #6180Hi Nicolas,
From what you have said, my current weekly optimisation based on the previous 4 weeks performance, isn’t a good method in the long run. To try not to overfit, if I keep the moving averages the same, I can get consistent results, I just need to adapt the stop loss and the take profit to achieve higher profits each week. I tried using a percentage of ATR for both the stop and take profit, but on a 5 minute chart there is too much noise for this to be effective, and I can’t use multi timeframes (% of daily ATR) to cut through the noise. Is there anything you suggest to keep up with the changing volatility in the market so I optimise the stop and take profit (also the moving averages?)?
Trading, for example GBPUSD, using the basic unoptimised test settings below for the averages and a 1:2+ stop and take profit, this system is profitable each month. Recently I thought I should automate it as it’s a very simple, mechanical system. I do add some other indicators when I day trade manually, but want to simplify it so it’s not over fitted to past performance, as you have suggested.
123456789101112131415161718192021DEFPARAM CumulateOrders = falsex = time > 080000 and time < 160000indicator1 = closeindicator2 = TriangularAverage[18](close)indicator3 = TriangularAverage[45](close)c1 = (indicator1 crosses over indicator2)c2 = (indicator2 > indicator3)IF NOT SHORTONMARKET and x and c1 and c2 THENBUY 1 PERPOINT AT MARKETENDIFc3 = (indicator1 crosses under indicator2)c4 = (indicator2 < indicator3)IF NOT LONGONMARKET and x and c3 AND c4 THENSELLSHORT 1 PERPOINT AT MARKETENDIFSET STOP pLOSS 30SET TARGET pPROFIT 60Do you have any suggestions as to how I can improve this system? In backtesting and live forward auto-trading, I have found optimising to be more successful, but I could have just been lucky. If you can help me find flexible and optimised stop and take profit solutions, I’ll be eternally grateful 🙂
Thanks for all your help,
Robin.
04/29/2016 at 10:36 AM #6192Hi Robin, Do you mean for example, an stop loss or target profit changing position when price reach a determinated level?
If you want breakeven profit every time the markets gives you the chance, should be something like this:
1234IF LongOnMarket AND Close>PositionPrice+Spread THENBreakEven = PositionPrice+myProfitENDIFSELL AT BreakEven STOPIf you want this stop based only on ATR indicator, can’t help you more ATM.
Adolfo.
04/29/2016 at 2:35 PM #6218Hi Adolfo,
Thanks for your post. I’m looking for stop and target systems that evolve with market volatility until entry, and are then fixed for the duration of the trade. I was thinking of something based on ATR, but I’m sure there are other measures of volatility that could be used. Using ATR would be fine, but there is too much noise on a lower timeframe to get something consistently working.
Cheers,
Robin.
04/29/2016 at 2:40 PM #6220If you can keep the same moving average values and keep consistent good results, then keep your strategy the same and don’t even try to make it much better with optimization. I’m not a guru, this is what I think, so make your own decision about it 🙂
What your are pointing about the ATR takeprofit and stoploss is much clever, it is commonly accepted that ATR tp and sl computed on the fly are much efficient because they are adapted to the current market behaviour.
A % of the daily ATR is possible to calculate on the smaller timeframe. In ProBuilder, it is possible to get the daily OHLC with the instructions : DOPEN, DHIGH, DLOW and DCLOSE.
04/29/2016 at 3:07 PM #622604/29/2016 at 3:42 PM #6229Directly from Wikipedia :
First, you’ll have the calculate the true range with :
The true range is the largest of the:
- Most recent period’s high minus the most recent period’s low
- Absolute value of the most recent period’s high minus the previous close
- Absolute value of the most recent period’s low minus the previous close
Then make an exponential average of the result over n period.
04/29/2016 at 3:50 PM #623004/30/2016 at 6:18 PM #6268I’m trying to write the Daily True Range as an indicator. I wrote the code below but although it accepts the code without error, nothing appears in the indicator screen. I’m new to coding so not sure where i’m going wrong:
12345678910a=DHigh(close)b=DClose(1)c=DLow(close)x=max(a,b)y=min(b,c)DailyTrueRange = (x-y)RETURN DailyTrueRange COLOURED(0,255,0) AS "DailyTrueRange"I then need to write the code to create the Daily Average True Range indicator so I can call it to my system and use a % of it. Would the code for DATR be as below? I’m not sure how I’d combine the DTR and the Wilder average (or exponential average) to create the DATR.
DATR=WilderAverage[n](DTR[n](close))
Many thanks for your help,Robin.
-
AuthorPosts
Find exclusive trading pro-tools on