numLong (string name): int
numShort (string name): int
valLong (string name): var
valShort (string name): var
Returns the number resp. the current profit of all open long resp. short trades with the current asset and a given name.
This function is often used to limit the number of open trades for a certain trade algorithm, thus reducing the risk.
name - optional algorithm identifier of max. 15 characters, or 0 for the current algorithm, or "*" for finding all trades of the current asset regardless of their algorithm.
Number of open trades (numLong/numShort)
Total current profit of open trades (valLong/valShort)
- For generating more detailed statistics of open trades, they can be enumerated with the for_each_trade(tr) macro. The TRADE struct and all relevant trade macros are defined in include\trading.h.
- For finding the number or profit sum of all open trades regardless of their asset and algorithm, use the NumShort, NumLong, and TradeVal variables.
- The simulation opens trades at the begin of the next bar, while life trading opens them immediately. For consistency between simulation and trading, trades that were just opened - i.e. at the current bar - are not considered by the functions.
if(numShort("Cycle") < 3) // only 3 open trades of type "Cycle"
exitLong/Short, enterLong/Short, statusLong/Short, WinLong/Short