Money mangement code

Questions about MultiCharts and user contributed studies.
houss75
Posts: 50
Joined: 09 Feb 2014
Been thanked: 1 time

Money mangement code

Postby houss75 » 11 Dec 2014

I'm looking to write a trading system code that trade a porfolio of stock.
I want to know if there is a reserved word that can allow the system to take position that
doesn't exceed the initial capital invested.
for example if a have an initial capital of 10000$ all the open positions simultanesly have to never be greater than 10000$ over all the backtest.
Here is my code:

Code: Select all

Input:
StopLossPct( .2 ),
NbarExit(5),
RegimeLookback(200),
TradeSize(10000),
RISK_PER_POSITION(0.2);

Variables:
vShares(100),
MA200(0),
ExitMA(0),
con(0),
nshares(0);

MA200 = Average(Close, RegimeLookback);
ExitMA = Average(Close, MAExitPeriod);
con=TradeSize*RISK_PER_POSITION;
nshares=con/C;

If condition1 and condition2 then buy nshares shares this bar at close;

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Money mangement code

Postby Henry MultiСharts » 12 Dec 2014

Hello houss75,

InitialCapital - Returns a numerical value, indicating the amount of initial capital set in the strategy properties.
Portfolio_InvestedCapital - Returns absolute value indicating the amount of cash assets invested in portfolio securities on the moment of strategy calculation.

You can also use the portfolio money management settings to control the invested capital.


Return to “MultiCharts”