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.
Invested Capital per entryname or signal?
- Kate MultiCharts
- Posts: 593
- Joined: 21 Oct 2020
- Has thanked: 9 times
- Been thanked: 148 times
Re: Invested Capital per entryname or signal?
Hello fatgecko,
You can calculate Portfolio_InvestedCapital for each separate instrument.
Portfolio_InvestedCapital = entryprice(0) * bigpointvalue * currentcontracts
Here's an example:
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);
Re: Invested Capital per entryname or signal?
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?
- Kate MultiCharts
- Posts: 593
- Joined: 21 Oct 2020
- Has thanked: 9 times
- Been thanked: 148 times
Re: Invested Capital per entryname or signal?
fatgecko,
Try checking PosTradeEntryPrice, PosTradeSize, PosTradeCount.
Here's an example of how you can get invested capital per signal/entryname:
As a result, you'll get invested capital for each Entry Name.
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 (" ");
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