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
limit the number of daily trades [SOLVED]
-
- Posts: 401
- Joined: 19 Jan 2011
- Location: Netherlands
- Has thanked: 85 times
- Been thanked: 124 times
Re: limit the number of daily trades
You can try this:
EntriesToday is a function in MC.
With this example, you can have a max of 2 trades per day.
Code: Select all
Inputs:
Max_trades(2);
If (EntriesToday(date) <= max_trades) then begin
your code
end;
With this example, you can have a max of 2 trades per day.
Re: limit the number of daily trades
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 itselfYou can try this:
EntriesToday is a function in MC.Code: Select all
Inputs:
Max_trades(2);
If (EntriesToday(date) <= max_trades) then begin
your code
end;
With this example, you can have a max of 2 trades per day.
Code: Select all
if EntriesToday(Date) = 0 then begin;
-
- Posts: 401
- Joined: 19 Jan 2011
- Location: Netherlands
- Has thanked: 85 times
- Been thanked: 124 times
Re: limit the number of daily trades
This is the function code (make a new function, returntype:Numeric. Function storage: Simple. And name it EntriesToday.
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.
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 ;
Re: limit the number of daily trades
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
Re: limit the number of daily trades
So the trick I found so far is to use :
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.
Code: Select all
if totaltrades<1 then
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.
Re: limit the number of daily trades [SOLVED]
So here's what I did and it does seem to work ( limit the # of daily trades to 1):
Thanks to everybody for helping !
Code: Select all
inputs:dailytradeslimit(1);
vars:startnumtrades(0);
If date>date[1] then startnumtrades = totaltrades;
If TotalTrades - startnumtrades < dailytradeslimit then
... followed by strategy