Page 1 of 1

how to assign "fixed contract size" to variable

Posted: Jul 02 2015
by FutureTrader
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;

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

Posted: Jul 02 2015
by TJ
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.

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

Posted: Jul 02 2015
by FutureTrader
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.

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

Posted: Jul 02 2015
by TJ
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?