NexusFi: Find Your Edge


Home Menu

 





Multicharts SetCustomFitnessValue for Equity Curve


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one Nicolas11 with 1 posts (1 thanks)
    2. looks_two Quick Summary with 1 posts (0 thanks)
    3. looks_3 treydog999 with 1 posts (0 thanks)
    4. looks_4 benharrell with 1 posts (0 thanks)
    1. trending_up 4,629 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 4 posts
    2. attach_file 1 attachments




 
Search this Thread

Multicharts SetCustomFitnessValue for Equity Curve

  #1 (permalink)
 
benharrell's Avatar
 benharrell 
Pittsburgh, Pa
 
Experience: Intermediate
Platform: Ninjatrader
Broker: Zen-Fire
Trading: CL,ES,6E
Posts: 235 since Aug 2009
Thanks Given: 350
Thanks Received: 96

I am in the process of trying to figure out how to use the SetCustomFitnessValue in MC to optimize a specific system for a more linear equity curve. I have done some searching on the Multicharts forum, and here, and can't seem to find anyone trying or producing any examples. I did find an old EasyLanguage post, if you search on google for "set custom fitness value equity curve"

The resulting signal that I produced using code from that Forum (Kreslik), was:

 
Code
vars: 
   vTotalBars(0), 
   vAvgBarEqGrowth(0), 
   vAvgLinShift(0), 
   vLinEquity(0), 
   vMaxDev(0), 
   FitnessVal(0),
   tDiffSum(0), 
   tCounter(0); 

arrays: 
   aCumEquity[](0); 

if BarNumber >= 1 then 
   begin 
      Array_SetMaxIndex(aCumEquity, BarNumber); 
      aCumEquity[BarNumber] = NetProfit + OpenPositionProfit; 
      vTotalBars = BarNumber; 
   end;
   
if (numwintrades + numlostrades) > 0 then 
      begin 
         vAvgBarEqGrowth = aCumEquity[vTotalBars] / vTotalBars; 
         vLinEquity = vAvgBarEqGrowth; { linear equity at bar 1 
            will be equal to the average bar equity growth value} 

         for tCounter = 1 to vTotalBars 
            begin 
               tDiffSum = tDiffSum + (aCumEquity[tCounter] - vLinEquity); 
               vLinEquity = vLinEquity + vAvgBarEqGrowth; 
            end; 

         vAvgLinShift = tDiffSum / vTotalBars; { average deviation 
            from the perfectly linear, though shifted equity curve} 
         vLinEquity = vAvgBarEqGrowth; 

         for tCounter = 1 to vTotalBars 
            begin 
               vMaxDev = MaxList(vMaxDev, 
                  AbsValue(aCumEquity[tCounter] - (vLinEquity + vAvgLinShift))); 
               vLinEquity = vLinEquity + vAvgBarEqGrowth; 
            end; 

         FitnessVal = aCumEquity[vTotalBars] / vMaxDev; 
         SetCustomFitnessValue(FitnessVal);
      end;
The result was that MultiCharts crashed, I am using the most recent version of MC 8 64bit. I am not the best with EasyLanguage, but I am interested in finding out how to fix this. This is pretty experimental on my part, I don't know if it even makes sens to try and optimize for an equity curve alone.

If anyone is interested in helping, it might be great for the community to get this going.

By the way, I didn't post the link tot he forum where the code originated but would be willing to if it was allowed/required.

Visit my NexusFi Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
REcommedations for programming help
Sierra Chart
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
How to apply profiles
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
45 thanks
Just another trading journal: PA, Wyckoff & Trends
31 thanks
Bigger Wins or Fewer Losses?
24 thanks
Tao te Trade: way of the WLD
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
  #3 (permalink)
 
Nicolas11's Avatar
 Nicolas11 
near Paris, France
 
Experience: Beginner
Platform: -
Trading: -
Posts: 1,071 since Aug 2011
Thanks Given: 2,232
Thanks Received: 1,769


Hi,

It is the first time I use custom fitness. But, this is something I wanted to test. So I take the opportunity of your message.

As you can see in the code, an array is created (aCumEquity). Its size is the number of bars on the screen. So, it may be huge. But should be OK.

However, at each bar, the code traverses twice all the existing bars on the screen: "for tCounter = 1 to vTotalBars". This is what seems strange to me. It generates an enormous amount of calculation.

On my computer, the implementation of a simple strategy (unprofitable MA crossover) takes a lot of time. And my computer has more or less frozen when I tried an optimization.

Do you think that the code within "if (numwintrades + numlostrades) > 0 [...] end" shall be executed at each bar, or only at the last?

If your answer is "only at the last", you could try to replace by "if LastBarOnChart AND (numwintrades + numlostrades) > 0 [...] end" and see what happens.

On my computer, it allowed a quick optimization (UPDATE: see screenshot below). But you have to check that the code is still fulfilling its purpose.

Nicolas


Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #4 (permalink)
 
treydog999's Avatar
 treydog999 
seoul, Korea
 
Experience: Intermediate
Platform: Multicharts
Broker: CQG, DTN IQfeed
Trading: YM 6E
Posts: 897 since Jul 2012
Thanks Given: 291
Thanks Received: 1,039

I was looking on how to do this myself. I found a feature request put in by @BigMike on the multicharts Project Manager it says released. But i cant find it in the custom or pull down menu for optimization? Anyone figure out how to use it yet?

MultiCharts Project Management - Issue MC-896 - New optimization type - linear equity curve with minimal deviation

Reply With Quote
  #5 (permalink)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 690


treydog999 View Post
I was looking on how to do this myself. I found a feature request put in by @BigMike on the multicharts Project Manager it says released. But i cant find it in the custom or pull down menu for optimization? Anyone figure out how to use it yet?

MultiCharts Project Management - Issue MC-896 - New optimization type - linear equity curve with minimal deviation

It's available on the forum here. There's also a MC .NET version created by the same user.

Reply With Quote




Last Updated on September 6, 2013


© 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