i've actually pinched this code from another user on this site but have been unable to make the modifications to work. Basically the code is looking at the slope of the closed trades equity curve and then passing this to a money management algorithm which resizes the trade size depending on whether the strategy is going through a winning or losing streak.
There are two parts to this, firstly the code to be placed within the strategy code and then secondly the code for the money management algorithm(MM) to be placed in the MM signal section within Portfolio Trader.
At present i have this code for the MM signal but am not sure if i have assigned code correctly to variables or arrays:
for idx = 0 to portfolioStrategies -1 begin
TargetRank[idx] = pmms_get_strategy_named_num(idx, "TargetRank");
EquitySlope[idx] = pmms_get_strategy_named_num(idx, "EquityCurveSlope");
// Adjust position size based on equity slope
AdjustedPositionSize[idx] = 1.25;
If EquitySlope[idx]>= .150 then AdjustedPositionSize[idx] = 1.5;
If EquitySlope[idx] <= .075 and EquitySlope[idx]> -.075 then AdjustedPositionSize[idx] = .75;
If EquitySlope[idx] <= -.075 then AdjustedPositionSize[idx] = 0;
// Send the adjusted position size back to the strategy
what does the compiler tell you when you try to compile your code? The first one doesn't declare the arrays at all, which basically means you are trying to use a structure within the code that you didn't create first. You need to declare and initialize arrays just like you do with variables plus depending on the array you need to set the sizes.
You should be able to find the examples you need in the MC wiki and the EasyLanguage Essentials PDF (or check your second code piece).
The following user says Thank You to ABCTG for this post: