Number of Trades per day

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
WHO
Posts: 5
Joined: 06 Jul 2011

Number of Trades per day

Postby WHO » 12 Apr 2012

Does anyone have a script that limits the number of trades per trading day .Meaning ,being able to set it to one trade per day , then at a later date ,two etc.

Steve

User avatar
furytrader
Posts: 354
Joined: 30 Jul 2010
Location: Chicago, IL
Has thanked: 155 times
Been thanked: 217 times

Re: Number of Trades per day

Postby furytrader » 13 Apr 2012

I don't have a pre-built script but, assuming you're using intraday day data, you would retrieve the total # of trades (PowerLanguage keyword 'TotalTrades') that have been completed up to the start of that day (so, for example, in the e-Mini S&P 500, you'd check at 8:30 am CST) and then, with each bar, compare that # with the current number of total trades (again, by calling the TotalTrades keyword). If the difference is greater than your limit, you don't allow additional trades for that day.

There is also the "EntriesToday" keyword, but that may not capture trades that have been completed.

User avatar
Roman MultiCharts
Posts: 50
Joined: 28 Nov 2011
Has thanked: 21 times
Been thanked: 67 times

Re: Number of Trades per day

Postby Roman MultiCharts » 13 Apr 2012

Does anyone have a script that limits the number of trades per trading day .Meaning ,being able to set it to one trade per day , then at a later date ,two etc.

Steve
Steve, you may try to use this script in order to limit the number of trades per day:

Code: Select all

inputs:
Trades_Per_Day(5);

variables:
EntryCount(0),
Trading_On(true);

If EntriesToday(date)>= Trades_Per_Day then Trading_On = False;

If Trading_On = true then begin

//script of your signal

end;
Trading_On = true;
I don't have a pre-built script but, assuming you're using intraday day data, you would retrieve the total # of trades (PowerLanguage keyword 'TotalTrades') that have been completed up to the start of that day (so, for example, in the e-Mini S&P 500, you'd check at 8:30 am CST) and then, with each bar, compare that # with the current number of total trades (again, by calling the TotalTrades keyword). If the difference is greater than your limit, you don't allow additional trades for that day.

There is also the "EntriesToday" keyword, but that may not capture trades that have been completed.
furytrader, "EntriesToday" keyword captures all the complete trades of the day. Moreover, it is the fastest solution. Thank you for your suggestion.

WHO
Posts: 5
Joined: 06 Jul 2011

Re: Number of Trades per day

Postby WHO » 14 Apr 2012

Thank you Roman and Fury

Roman, your script worked exactly as to how i posed the question.What may be easier is if you could look over this script and delete the inital capital ie taking the dollar amount out of the script and then using MC properties for Init capital and dollars per trade for calculations ? You will have to excuse my total ignorance on this subject as i have no idea of how to program.

Steve

Code: Select all

inputs:Price(C),
FastLength(12),
SlowLength(26),
InitCapital(5000) ,
CapitalDivisor_HCL(c);

variables: var0( 0 ), var1( 0 ), var2( 0 ) ;

Value1 = (InitCapital + netprofit)/CapitalDivisor_HCL;

var0 = XAverage( Price , FastLength );
var1 = XAverage( Price ,SlowLength );

condition1 = CurrentBar > 2 and var0 crosses above var1 ;

if condition1 then
Begin
Buy ("MA")value1 shares this Bar ;
End;

If var0 crosses under var1 then
Sell ("MAX") this Bar at Close;

User avatar
Roman MultiCharts
Posts: 50
Joined: 28 Nov 2011
Has thanked: 21 times
Been thanked: 67 times

Re: Number of Trades per day

Postby Roman MultiCharts » 16 Apr 2012

Hello Steve,

You may use the following script.

Code: Select all

inputs:Price(C),
FastLength(12),
SlowLength(26),
CapitalDivisor_HCL(c);

variables: var0( 0 ), var1( 0 ), var2( 0 ) ;

Value1 = (InitialCapital + netprofit)/CapitalDivisor_HCL;

var0 = XAverage( Price , FastLength );
var1 = XAverage( Price ,SlowLength );

condition1 = CurrentBar > 2 and var0 crosses above var1 ;

if condition1 then
Begin
Buy ("MA")value1 shares this Bar ;
End;

If var0 crosses under var1 then
Sell ("MAX") this Bar at Close;
In this script, Initial Capital info will be taken from the Strategy Properties.

WHO
Posts: 5
Joined: 06 Jul 2011

Re: Number of Trades per day

Postby WHO » 17 Apr 2012

Thanks Roman,

It didnt change !!! its still reading the capital from the script

Best

Steve

WHO
Posts: 5
Joined: 06 Jul 2011

Re: Number of Trades per day

Postby WHO » 20 Apr 2012

Disregard my last post Roman.

It works just fine

Thank you much

Steve


Return to “User Contributed Studies and Indicator Library”