is there a way to get total shares of specified entry

Questions about MultiCharts and user contributed studies.
horizon1231
Posts: 11
Joined: 21 Jan 2015

is there a way to get total shares of specified entry

Postby horizon1231 » 21 Jan 2015

for eg I have many entry signals in one strategy, and I want to get a entry ("buy name")' total entry shares ,
is there a way?

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: is there a way to get total shares of specified entry

Postby JoshM » 21 Jan 2015

Re: is there a way to get total shares of specified entry

for eg I have many entry signals in one strategy, and I want to get a entry ("buy name")' total entry shares ,is there a way?
This can be retrieved with the PosTradeSize() keyword.

If you want to work with the entry name as a workaroud, instead of the trade count number (that is needed for use with `PosTradeSize()`), see PosTradeEntryName().

horizon1231
Posts: 11
Joined: 21 Jan 2015

Re: is there a way to get total shares of specified entry

Postby horizon1231 » 21 Jan 2015

Hi thanks for reply.
since the order is triggered by condition,so I dont know the order number ie pos TradeNumber.
I want to retrieve order size by entry name,something like PosTradeSize(PosAgo, entryname)

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: is there a way to get total shares of specified entry

Postby JoshM » 22 Jan 2015

since the order is triggered by condition,so I dont know the order number ie pos TradeNumber.
I want to retrieve order size by entry name,something like PosTradeSize(PosAgo, entryname)
I think you can combine `PosTradeSize()` with PosTradeCount() for that. Because `PosTradeCount()` returns how many trades (i.e., entries) there were into a specific position.

If you loop through all `PosTradeCount()` trades for a specific position, you can use the `PosTradeEntryName()` to check whether the different trades have the entry name you're looking for.

For example (untested, but to highlight the idea):

Code: Select all

Variables:
entryNameLookingFor("ABCDEF"),
currentEntryName(""),
sharesOfSpecificEntry(0),
x(0);

for x = 0 to PosTradeCount(1) {previous position} begin

currentEntryName = PosTradeEntryName(1, x);

if (currentEntryName = entryNameLookingFor) then begin

sharesOfSpecificEntry = PosTradeSize(1, x);
break;

end;

end;

Print("There were ", sharesOfSpecificEntry,
" shares in the entry with name ",
entryNameLookingFor);


Return to “MultiCharts”