Custom Strategy Optimization Back Testing Performance

kktrades1

Member
Joined
Jan 31, 2023
Posts
9
Likes
2
Hi all,
I wrote a custom strategy to backtest and its taking more than 10 mins to run for 6 months worth of data. Here is the bulk of my code and was wondering if any of you could see anything that would improve the performance. I wrote to support but they sent me here. Below is my email. I've attached the java code as it was too long.

Really appreciate any feedback!
Thank you !!

I am trying to test my strategy and to run the report for about 6 months, it is taking around 10 minutes. I think that is really really long. Below is the code that I am using. Can you tell me if it can be made more efficient so that It runs quicker? Ideally I'd like it not to take longer than 30 seconds to a minute. I copied most of the code from MACross study. May be some of the code can be removed to increase speed of processing. Not sure why we need `onLoad()` method. And I know i am not doing it the suggested way where I create a study for signal and then create a strategy for submitting orders. Wasn't sure if that would increase the efficiency.

I only need to see the fast ma and slow ma on the chart
I need previous values of fast and slow MA's , 20 and 34 emas and previous values of high and low, current 5 period atr to figure out the order entry conditions.

thank you !!
 

Attachments

  • MaTouch.txt
    9.7 KB · Views: 23

Spin

Well-known member
Joined
May 22, 2019
Posts
484
Likes
194
Hello @kktrades1 and sorry for my somewhat late reply :)

I have not had much screen time this last weekend, so I only looked into your code now.
Looks competent !! 😁(y)(y)

And yes, switching from tick to bar for backtesting is faaaar more easier on the CPU. Works for all Strategies that do not use Ticks / intrabar data.
Good find ! :)
 

Khaled

Member
Joined
Jul 31, 2023
Posts
12
Likes
4
@kktrades1 Hi, I'm new to MW and wanted to know if I know how to write a couple of lines of code on Java, what should I do next to get this code work under MW? I understand that I need to compile the file, but I'm unfamiliar with Eclipse. Can you please point out a tutorial on MW website or YouTube? Thanks
 
Top