how to assign "fixed contract size" to variable

Questions about MultiCharts and user contributed studies.
FutureTrader
Posts: 79
Joined: 28 Mar 2013
Has thanked: 3 times
Been thanked: 4 times
Contact:

how to assign "fixed contract size" to variable

Postby FutureTrader » 02 Jul 2015

Hey. I need to assign the "fixed contract size" from the strategy properties to a variable, so I can either use those or use my own contract size.

At the moment I've got the following code, so I need to write the "Buy" line two times.

Code: Select all

inputs:
system.use.pool.position.sizing(true);

variables:
system.contracts(0);

system.contracts = 5;

if system.use.pool.position.sizing then begin
Buy system.contracts contracts next bar at market;
end else begin
Buy next bar at market;
end;
It would be great I could assign the "fixed contract size" to a variable, so I can

Code: Select all

if system.use.pool.position.sizing then begin
system.contracts = 5;
end else begin
system.contracts = "strategies properties settings";
end;

Buy system.contracts contracts next bar at market;

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: how to assign "fixed contract size" to variable

Postby TJ » 02 Jul 2015

Hey. I need to assign the "fixed contract size" from the strategy properties to a variable, so I can either use those or use my own contract size.
::

Go create a function with the name "strategies properties settings" and assign it whatever contract number you want.

Whenever you need to change the number,
simply recompile the function and the new number will be propagated to all the strategies.

FutureTrader
Posts: 79
Joined: 28 Mar 2013
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: how to assign "fixed contract size" to variable

Postby FutureTrader » 02 Jul 2015

Hey. I need to assign the "fixed contract size" from the strategy properties to a variable, so I can either use those or use my own contract size.
::

Go create a function with the name "strategies properties settings" and assign it whatever contract number you want.

Whenever you need to change the number,
simply recompile the function and the new number will be propagated to all the strategies.

TJ, thanks. That's exactly how I assign the contract number to system.contracts, I have a separate function. But for some fast testing purposes and for other backward compatibility I'd like to have the "assign fixed contract to variable" possibility, too.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: how to assign "fixed contract size" to variable

Postby TJ » 02 Jul 2015

Hey. I need to assign the "fixed contract size" from the strategy properties to a variable, so I can either use those or use my own contract size.
::

Go create a function with the name "strategies properties settings" and assign it whatever contract number you want.

Whenever you need to change the number,
simply recompile the function and the new number will be propagated to all the strategies.

TJ, thanks. That's exactly how I assign the contract number to system.contracts, I have a separate function. But for some fast testing purposes and for other backward compatibility I'd like to have the "assign fixed contract to variable" possibility, too.
I don't quite understand what you are looking for...
If you want to change the contract size,
can't you simply make the variable an "Input" parameter for the strategy?


Return to “MultiCharts”