Profit distribution by hours  [SOLVED]

Questions about MultiCharts and user contributed studies.
TraderWalrus
Posts: 63
Joined: 13 Sep 2016
Has thanked: 30 times
Been thanked: 8 times

Profit distribution by hours

Postby TraderWalrus » 13 Sep 2016

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.

TraderWalrus
Posts: 63
Joined: 13 Sep 2016
Has thanked: 30 times
Been thanked: 8 times

Re: Profit distribution by hours

Postby TraderWalrus » 15 Sep 2016

One by one please, not everyone at once :)

User avatar
TJ
Posts: 7176
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 990 times
Been thanked: 2049 times

Re: Profit distribution by hours

Postby TJ » 15 Sep 2016

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 or Entry???


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?

TraderWalrus
Posts: 63
Joined: 13 Sep 2016
Has thanked: 30 times
Been thanked: 8 times

Re: Profit distribution by hours

Postby TraderWalrus » 15 Sep 2016

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.

User avatar
TJ
Posts: 7176
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 990 times
Been thanked: 2049 times

Re: Profit distribution by hours

Postby TJ » 15 Sep 2016

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.

TraderWalrus
Posts: 63
Joined: 13 Sep 2016
Has thanked: 30 times
Been thanked: 8 times

Re: Profit distribution by hours

Postby TraderWalrus » 15 Sep 2016

If I have no choice, that's what I will do, I was hoping there will be an easier solution.

User avatar
bensat
Posts: 331
Joined: 04 Oct 2014
Has thanked: 46 times
Been thanked: 104 times

Re: Profit distribution by hours

Postby bensat » 15 Sep 2016

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 ...

Code: Select all

input: starttime(0845), endtime(1435);

if time >= starttime and time < endtime then
begin

...... you current strategy rules

end;
<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

TraderWalrus
Posts: 63
Joined: 13 Sep 2016
Has thanked: 30 times
Been thanked: 8 times

Re: Profit distribution by hours

Postby TraderWalrus » 15 Sep 2016

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:

Code: Select all

input: starttime(0000);
variables: endtime(0);

endtime = CalcTime(starttime,60);

if time >= starttime and time < endtime then
begin
......
end;
and then I only need to do the optimization on a single input with increments of 100 starting from 0000 to 2300.

User avatar
bensat
Posts: 331
Joined: 04 Oct 2014
Has thanked: 46 times
Been thanked: 104 times

Re: Profit distribution by hours

Postby bensat » 15 Sep 2016

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

TraderWalrus
Posts: 63
Joined: 13 Sep 2016
Has thanked: 30 times
Been thanked: 8 times

Re: Profit distribution by hours  [SOLVED]

Postby TraderWalrus » 15 Sep 2016

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..


Return to “MultiCharts”