Hi. I'm trying to calculate position size using the following values:
The math is fairly simple, but I see no way how I can use the GetPercentProfit() in the normal signal execution nor can I use the last Close price in the CBT - so I'm stuck.
Anyone here that can guide me on this challenge?
If you are using a mid or low level CBT, you can do something like this:
for (openPos=bo.GetFirstOpenPos(); openPos; openPos=bo.GetNextOpenPos())
pClose = openPos.GetPrice(bar,"C");
currPosSize = openPos.Shares * pClose;
// Your stuff here
In this example, it is assumed that
bar is the name of the variable controlling the primary
for loop in your CBT.
If you don't need to loop through all open positions, you could use
openPos = bo.FindOpenPos(symbol);
instead of the
Thanks for the reply. Still busy working on this. Will reply with feedback.