When backtesting strategies, I am interested to see trades' profit / loss summary, distributed by time of entering the trade. For example, average P/L of trades opened between 7am-8am, 8am-9am and so on.
Will appreciate any suggestions.
Profit distribution by hours [SOLVED]
-
- Posts: 63
- Joined: 13 Sep 2016
- Has thanked: 30 times
- Been thanked: 8 times
-
- Posts: 63
- Joined: 13 Sep 2016
- Has thanked: 30 times
- Been thanked: 8 times
- TJ
- Posts: 7745
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
Re: Profit distribution by hours
Profit or Entry???When backtesting strategies, I am interested to see trades' profit / loss summary, distributed by time of entering the trade. For example, average P/L of trades opened between 7am-8am, 8am-9am and so on.
Will appreciate any suggestions.
Do you mean profit taken by the specific hour?
or do you mean trades initiated only by the specific hour?
or Trades entered AND closed between 7am-8am, 8am-9am and so on?
Have you thought through the logic?
-
- Posts: 63
- Joined: 13 Sep 2016
- Has thanked: 30 times
- Been thanked: 8 times
Re: Profit distribution by hours
Thank you for your reply TJ.
I mean trades opened = initiated, in those intervals.
I noticed that in some hours it is preferable to avoid entering trades (for my specific system). Screening trades that are supposed to be initiated in those hours improve my results. I would like to see the statistics for each hour though, and not only for the obvious cases.
I mean trades opened = initiated, in those intervals.
I noticed that in some hours it is preferable to avoid entering trades (for my specific system). Screening trades that are supposed to be initiated in those hours improve my results. I would like to see the statistics for each hour though, and not only for the obvious cases.
- TJ
- Posts: 7745
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
Re: Profit distribution by hours
Thank you for your reply TJ.
I mean trades opened = initiated, in those intervals.
I noticed that in some hours it is preferable to avoid entering trades (for my specific system). Screening trades that are supposed to be initiated in those hours improve my results. I would like to see the statistics for each hour though, and not only for the obvious cases.
I would think, you can export the trades to excel and do the analysis there.
-
- Posts: 63
- Joined: 13 Sep 2016
- Has thanked: 30 times
- Been thanked: 8 times
Re: Profit distribution by hours
If I have no choice, that's what I will do, I was hoping there will be an easier solution.
Re: Profit distribution by hours
Regarding <Backtesting> only, why not just optimize times via code with your current untouched strategy .... and get the output from the optimization report.
Just a simple example ...
<starttime> & <endtime> can be optimized. You could go more sophisticated ways for fractions of hours etc, but may you want to start from there ....
Kind Regards
Ben
Just a simple example ...
Code: Select all
input: starttime(0845), endtime(1435);
if time >= starttime and time < endtime then
begin
...... you current strategy rules
end;
Kind Regards
Ben
-
- Posts: 63
- Joined: 13 Sep 2016
- Has thanked: 30 times
- Been thanked: 8 times
Re: Profit distribution by hours
Thanks bensat.
I thought optimization would go through all the different combinations of starting and ending times and that's a lot of processing, but when I think of it, the following should work:
and then I only need to do the optimization on a single input with increments of 100 starting from 0000 to 2300.
I thought optimization would go through all the different combinations of starting and ending times and that's a lot of processing, but when I think of it, the following should work:
Code: Select all
input: starttime(0000);
variables: endtime(0);
endtime = CalcTime(starttime,60);
if time >= starttime and time < endtime then
begin
......
end;
Re: Profit distribution by hours
Maybe, if this is what you want. But you will limit your optimizations by yourself. More importantly, you limit your statistical output. Your strategy can show much better parameters with trading times between 0300 and 0600 instead of just analyzing one hour only.
Kind Regards.
Ben
Kind Regards.
Ben
-
- Posts: 63
- Joined: 13 Sep 2016
- Has thanked: 30 times
- Been thanked: 8 times
Re: Profit distribution by hours [SOLVED]
I think I will need to aggregate the results from segments in any case, for example if I see that I need to avoid the times US and say European (say Germany) markets open and close.
I am working with 1 minute bars and backtesting / optimizing on 6-12 months. Optimization of hundreds of possibilities takes a lot of time..
I am working with 1 minute bars and backtesting / optimizing on 6-12 months. Optimization of hundreds of possibilities takes a lot of time..