NexusFi: Find Your Edge


Home Menu

 





Position Sizing - Equity Curve Trading


Discussion in EasyLanguage Programming

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




 
Search this Thread
  #1 (permalink)
 CharlieTrader 
London
 
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:


var:

AdjustedPositionSize(0),
IDX(0),
TargetRank(0),
EquitySlope(0);


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] );
end;



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



LRSlopeLen(30);

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

Vars:
TotTds(0),
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];
end;
a_NetPL[1] = (PreviousEquity - netprofit)/EquityScaler;
If TotTds>= LRSlopeLen then Value1 = LinRegArray( a_NetPL, LRSlopeLen, 0, oLRSlope, oLRAngle, oLRIntercept, oLRValueRaw ) ;
oLRSlope = oLRSlope / RSize;
end;


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
April 2026 Jobs Report: +115k vs +65k Expected
Traders Hideout
TradingView Deploys AI to Monitor SEC Filings in Real Ti …
TradingView
Netherlands & Germany Surge as World Cup Field Narro …
Prediction Markets & Event Contracts
Iran Forward Curve: June 30 at 56% vs June 15 at 28% -- …
Prediction Markets & Event Contracts
Orban at 29pct as Hungary Votes Tomorrow -- McIlroy Surg …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
197 thanks
Sober Journey With S&P
27 thanks
30 Sessions
20 thanks
BERN ALGOS algo trading journal
8 thanks
Volume Indicators
8 thanks
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642


CharlieTrader,

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

Regards,

ABCTG


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

Thanks ABCTG, i'll do that.

Cheers


Started this thread Reply With Quote




Last Updated on April 24, 2016


© 2026 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 - Downloads - Top
no new posts