limit the number of daily trades  [SOLVED]

Questions about MultiCharts and user contributed studies.
ravel44
Posts: 28
Joined: 05 Jul 2012
Has thanked: 7 times

limit the number of daily trades

Postby ravel44 » 02 Nov 2015

Hello !
I spent a whole week trying to find a way/keywords to limit the number of trades per day in my strategy and couldn t find a solution. Any help would be appreciated, thanks

evdl
Posts: 401
Joined: 19 Jan 2011
Location: Netherlands
Has thanked: 85 times
Been thanked: 124 times

Re: limit the number of daily trades

Postby evdl » 03 Nov 2015

You can try this:

Code: Select all

Inputs:
Max_trades(2);

If (EntriesToday(date) <= max_trades) then begin

your code

end;
EntriesToday is a function in MC.

With this example, you can have a max of 2 trades per day.

ravel44
Posts: 28
Joined: 05 Jul 2012
Has thanked: 7 times

Re: limit the number of daily trades

Postby ravel44 » 03 Nov 2015

You can try this:

Code: Select all

Inputs:
Max_trades(2);

If (EntriesToday(date) <= max_trades) then begin

your code

end;
EntriesToday is a function in MC.

With this example, you can have a max of 2 trades per day.
Thank U. Is EntriesToday function still available though ? i don t see anything when I type in MC wiki, it s returning an error when I try compiling the following code by itself

Code: Select all

if EntriesToday(Date) = 0 then begin;

evdl
Posts: 401
Joined: 19 Jan 2011
Location: Netherlands
Has thanked: 85 times
Been thanked: 124 times

Re: limit the number of daily trades

Postby evdl » 03 Nov 2015

This is the function code (make a new function, returntype:Numeric. Function storage: Simple. And name it EntriesToday.

Code: Select all

inputs: TargetDate_YYYMMDD( numericsimple ) ;

variables: var0( 0 ) ;

var0 = 0 ;

for Value1 = 0 to 10
begin
condition1 = EntryDate( Value1 ) = TargetDate_YYYMMDD ;
if condition1 then
var0 = var0 + 1 ;
end ;

EntriesToday = var0 ;
Thought this was a original function in MC. But I can be mistaken. In that case I collected this function along the way from a helpfull person on the web.

tony
Posts: 420
Joined: 14 Jun 2013
Has thanked: 30 times
Been thanked: 81 times
Contact:

Re: limit the number of daily trades

Postby tony » 03 Nov 2015

I use the following method

Code: Select all


IF Date <> Date[1]

then var1 = TotalTrades; // holds value for the entire day

var2 = ( TotalTrades - var1 ) // shows net completed trades for the day

IF var2 < 3 // whatever total completed trades I want to limit to

Then Begin



ravel44
Posts: 28
Joined: 05 Jul 2012
Has thanked: 7 times

Re: limit the number of daily trades

Postby ravel44 » 05 Nov 2015

So the trick I found so far is to use :

Code: Select all

if totaltrades<1 then
This allow the strategy to run if there was no trades on the chart so far.

In my strategy, the trade is executed at the open, so I limited the number of bars back for the instruments so that the entry of the previous day doesn t show up on the chart.
This solution works well for now.

ravel44
Posts: 28
Joined: 05 Jul 2012
Has thanked: 7 times

Re: limit the number of daily trades  [SOLVED]

Postby ravel44 » 09 Nov 2015

So here's what I did and it does seem to work ( limit the # of daily trades to 1):

Code: Select all

inputs:dailytradeslimit(1);
vars:startnumtrades(0);

If date>date[1] then startnumtrades = totaltrades;
If TotalTrades - startnumtrades < dailytradeslimit then
... followed by strategy
Thanks to everybody for helping !


Return to “MultiCharts”