Invested Capital per entryname or signal?

Questions about MultiCharts and user contributed studies.
fatgecko
Posts: 6
Joined: 18 Mar 2021
Has thanked: 4 times

Invested Capital per entryname or signal?

Postby fatgecko » 22 Nov 2021

The built-in Portfolio_InvestedCapital variable is great for determining how much equity is currently held in open positions. Is there a way of obtaining a similar value for each entryname or each Signal in a multi-signal Portfolio Trader set up?

Use case: I only want to enter a new position in response to an entry signal if the currently open positions under that signal don't exceed a certain % of my overall portfolio.

User avatar
Kate MultiCharts
Posts: 593
Joined: 21 Oct 2020
Has thanked: 9 times
Been thanked: 148 times

Re: Invested Capital per entryname or signal?

Postby Kate MultiCharts » 24 Nov 2021

Hello fatgecko,

You can calculate Portfolio_InvestedCapital for each separate instrument.
Portfolio_InvestedCapital = entryprice(0) * bigpointvalue * currentcontracts
Here's an example:

Code: Select all

Print( " symbolname ", symbolname, " entryprice(0) ", entryprice(0), " bigpointvalue ", bigpointvalue, " currentcontracts ", currentcontracts, " Portfolio_GetMaxPotentialLossPerContract ", Portfolio_GetMaxPotentialLossPerContract ); Print(" symbolname ", symbolname, " Portfolio_InvestedCapital by symbol = ", entryprice(0) * bigpointvalue * currentcontracts);

fatgecko
Posts: 6
Joined: 18 Mar 2021
Has thanked: 4 times

Re: Invested Capital per entryname or signal?

Postby fatgecko » 24 Nov 2021

Thanks Kate. That provides invested capital per instrument, but I need invested capital per signal and/or entryname - is there any way that can be done?

User avatar
Kate MultiCharts
Posts: 593
Joined: 21 Oct 2020
Has thanked: 9 times
Been thanked: 148 times

Re: Invested Capital per entryname or signal?

Postby Kate MultiCharts » 26 Nov 2021

fatgecko,

Try checking PosTradeEntryPrice, PosTradeSize, PosTradeCount.

Here's an example of how you can get invested capital per signal/entryname:

Code: Select all

once cleardebug; if (currentbar = 100) then buy ("St Name1") 1 contract next bar at market; if (currentbar = 110) then buy ("St Name2") 2 contract next bar at market; if (currentbar = 120) then buy ("St Name3") 3 contract next bar at market; if (currentbar = 130) then buy ("St Name4") 4 contract next bar at market; if (currentbar = 140) then buy ("St Name5") 5 contract next bar at market; print (" -------------------------------------------------------------------------------------- "); print (" currentbar ", currentbar, " symbolname '", symbolname, "' " ); print (" marketposition buy = ", marketposition, " Portfolio_InvestedCapital for all = ", Portfolio_InvestedCapital ); print (" "); if mod(currentbar, 200) = 0 then begin sell ("Bar22") next bar at market; end; Print (" symbolname = ", symbolname, " entryprice(0) = ", entryprice(0), " bigpointvalue = ", bigpointvalue, " currentcontracts = ", currentcontracts, " Portfolio_GetMaxPotentialLossPerContract = ", Portfolio_GetMaxPotentialLossPerContract ); print (" "); Print (" Portfolio_InvestedCapital by symbol '", symbolname, "' = " , entryprice(0) * bigpointvalue * currentcontracts); var: ii(0); for ii = 0 to PosTradeCount(0) - 1 begin print(" "); print(" invested capital for Entry Name = '", PosTradeEntryName(0, ii), "' "); Print(" Entry Price = ", PosTradeEntryPrice(0, ii), " CurrentContracts = ", PosTradeSize(0, ii), " BigPointValue = ", bigpointvalue); Print(" invested capital for Entry Name = ", PosTradeEntryPrice(0, ii) * PosTradeSize(0, ii) * bigpointvalue); end; print (" ");
As a result, you'll get invested capital for each Entry Name.

Code: Select all

-------------------------------------------------------------------------------------- currentbar 184.00 symbolname 'AUD/CAD' marketposition buy = 1.00 Portfolio_InvestedCapital for all = 2700.53 symbolname = AUD/CAD entryprice(0) = 0.91 bigpointvalue = 1000.00 currentcontracts = 15.00 Portfolio_GetMaxPotentialLossPerContract = -5.00 Portfolio_InvestedCapital by symbol 'AUD/CAD' = 13670.40 invested capital for Entry Name = 'St Name1' Entry Price = 0.91 CurrentContracts = 1.00 BigPointValue = 1000.00 invested capital for Entry Name = 911.36 invested capital for Entry Name = 'St Name2' Entry Price = 0.91 CurrentContracts = 2.00 BigPointValue = 1000.00 invested capital for Entry Name = 1822.52 invested capital for Entry Name = 'St Name3' Entry Price = 0.91 CurrentContracts = 3.00 BigPointValue = 1000.00 invested capital for Entry Name = 2733.45 invested capital for Entry Name = 'St Name4' Entry Price = 0.91 CurrentContracts = 4.00 BigPointValue = 1000.00 invested capital for Entry Name = 3645.12 invested capital for Entry Name = 'St Name5' Entry Price = 0.91 CurrentContracts = 5.00 BigPointValue = 1000.00 invested capital for Entry Name = 4555.25


Return to “MultiCharts”