NexusFi: Find Your Edge

Home Menu


Position Sizing - Equity Curve Trading

Discussion in EasyLanguage Programming

    1. trending_up 3,019 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments

Search this Thread

Position Sizing - Equity Curve Trading

  #1 (permalink)
Experience: Advanced
Platform: MultiCharts
Trading: Global Futures
Posts: 6 since Apr 2016
Thanks Given: 2
Thanks Received: 0

Hello guys,

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

pmms_set_strategy_named_num( idx, "PosSizeScaler", AdjustedPositionSize[idx] );

Secondly there is the code to be placed in the strategy itself:


Array: a_NetPL[](0);
condition1 = Array_setmaxindex(a_NetPL,LRSlopeLen);

oLRSlope( 0 ),
oLRAngle( 0 ),
oLRIntercept( 0 ),
oLRValueRaw( 0 ) ;

TotTds = TotalTrades;

If TotTds> TotTds[1] then begin
For value1 = LRSlopeLen downto 2 begin
a_NetPL[value1] = a_NetPL[value1-1];
a_NetPL[1] = (PreviousEquity - netprofit)/EquityScaler;
If TotTds>= LRSlopeLen then Value1 = LinRegArray( a_NetPL, LRSlopeLen, 0, oLRSlope, oLRAngle, oLRIntercept, oLRValueRaw ) ;
oLRSlope = oLRSlope / RSize;

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Platforms and Indicators
Trade idea based off three indicators.
Traders Hideout
NT7 Indicator Script Troubleshooting - Camarilla Pivots
Better Renko Gaps
The Elite Circle
Pivot Indicator like the old SwingTemp by Big Mike
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
48 thanks
Just another trading journal: PA, Wyckoff & Trends
35 thanks
Tao te Trade: way of the WLD
25 thanks
Bigger Wins or Fewer Losses?
24 thanks
GFIs1 1 DAX trade per day journal
21 thanks
  #3 (permalink)
 ABCTG   is a Vendor
Posts: 2,435 since Apr 2013
Thanks Given: 482
Thanks Received: 1,628


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).



Follow me on Twitter Reply With Quote
Thanked by:
  #4 (permalink)
Experience: Advanced
Platform: MultiCharts
Trading: Global Futures
Posts: 6 since Apr 2016
Thanks Given: 2
Thanks Received: 0

Thanks ABCTG, i'll do that.


Started this thread Reply With Quote

Last Updated on April 24, 2016

© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts