NexusFi: Find Your Edge


Home Menu

 





Speeding up an Optimization by Avoiding Settings


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one stepseazy with 3 posts (1 thanks)
    2. looks_two vvhg with 2 posts (0 thanks)
    3. looks_3 kronie with 1 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 1,583 views
    2. thumb_up 1 thanks given
    3. group 4 followers
    1. forum 8 posts
    2. attach_file 0 attachments




 
Search this Thread

Speeding up an Optimization by Avoiding Settings

  #1 (permalink)
 stepseazy 
Ithaca, NY
 
Experience: Beginner
Platform: Ninjatrader
Trading: CL
Posts: 7 since Oct 2011
Thanks Given: 1
Thanks Received: 1

Programers, Ninjas, Martial Artists,

I have written a strategy that optimizes stop levels and take profits, but it takes forever to optimize since I usually use the default optimizer. I'd like it to just skip a setting if the stop is larger than the take profit. Right now I have an if statement so that the algorithm enters the trade only if the stop is <= the take profit. Is there a way to do this where the code just exits? I'm not a professional programmer so I'm not clear on how to approach this and would like suggestions from some pros who know how to make code faster. Thanks.

-steps

My current solution:

protected override void OnBarUpdate()
{
if (!(stopSmaller&&stop1>profit1))
{
EnterLongLimit(DefaultQuantity, (High[barsAgo]+ Low[barsAgo])/2-openDiff, "scale");
}
}

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
Better Renko Gaps
The Elite Circle
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
REcommedations for programming help
Sierra Chart
MC PL editor upgrade
MultiCharts
 
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)
 kevinkdog   is a Vendor
 
Posts: 3,664 since Jul 2012
Thanks Given: 1,892
Thanks Received: 7,359



stepseazy View Post
Programers, Ninjas, Martial Artists,

I have written a strategy that optimizes stop levels and take profits, but it takes forever to optimize since I usually use the default optimizer. I'd like it to just skip a setting if the stop is larger than the take profit. Right now I have an if statement so that the algorithm enters the trade only if the stop is <= the take profit. Is there a way to do this where the code just exits? I'm not a professional programmer so I'm not clear on how to approach this and would like suggestions from some pros who know how to make code faster. Thanks.

-steps

My current solution:

protected override void OnBarUpdate()
{
if (!(stopSmaller&&stop1>profit1))
{
EnterLongLimit(DefaultQuantity, (High[barsAgo]+ Low[barsAgo])/2-openDiff, "scale");
}
}


I'm not a Ninja person (I use Tradestation), but I'm guessing you have to set up the optimizer something like this:

Optimized variables are stop1 and profit1

You want to run cases of stop1 from say 1 to 20, and profit1 from 1 to 20, but stop1 has to be less than profit1


If that is the case, I would change your variables...

profit1 still the same
inc1 = new variable
stop1 = profit1 - inc1 (now this is a calculated variable, not one you set)

then you'd run cases of profit1 from 1 to 20, and inc1 from 1 to whatever

Then, stop1 would always be less than profit1


Hopefully this makes sense.

Follow me on Twitter Reply With Quote
  #4 (permalink)
 stepseazy 
Ithaca, NY
 
Experience: Beginner
Platform: Ninjatrader
Trading: CL
Posts: 7 since Oct 2011
Thanks Given: 1
Thanks Received: 1

Kev,

Very good solution, thanks. That does make a lot of sense. Not sure why I didn't think of that LOL. I wish I could change the optimizer logic though. Maybe I'm being too ambitious.

-steps

Started this thread Reply With Quote
  #5 (permalink)
 
vvhg's Avatar
 vvhg 
Northern Germany
 
Experience: Intermediate
Platform: NT
Trading: FDAX, CL
Posts: 1,583 since Mar 2011
Thanks Given: 1,016
Thanks Received: 2,824


stepseazy View Post
Programers, Ninjas, Martial Artists,

I have written a strategy that optimizes stop levels and take profits, but it takes forever to optimize since I usually use the default optimizer. I'd like it to just skip a setting if the stop is larger than the take profit. Right now I have an if statement so that the algorithm enters the trade only if the stop is <= the take profit. Is there a way to do this where the code just exits? I'm not a professional programmer so I'm not clear on how to approach this and would like suggestions from some pros who know how to make code faster. Thanks.

-steps

My current solution:

protected override void OnBarUpdate()
{
if (!(stopSmaller&&stop1>profit1))
{
EnterLongLimit(DefaultQuantity, (High[barsAgo]+ Low[barsAgo])/2-openDiff, "scale");
}
}


kevinkdog View Post
I'm not a Ninja person (I use Tradestation), but I'm guessing you have to set up the optimizer something like this:

Optimized variables are stop1 and profit1

You want to run cases of stop1 from say 1 to 20, and profit1 from 1 to 20, but stop1 has to be less than profit1


If that is the case, I would change your variables...

profit1 still the same
inc1 = new variable
stop1 = profit1 - inc1 (now this is a calculated variable, not one you set)

then you'd run cases of profit1 from 1 to 20, and inc1 from 1 to whatever

Then, stop1 would always be less than profit1


Hopefully this makes sense.

I think that could be a neat solution, but I would change it.
Let's say you are optimizing profit1 from 1 to 20 and inc 1-19, now when profit1 is 2 and inc is 19 you have a stop value of -17...no good...
This ensures that you don't end up with a negative stop:
 
Code
stop1 = Math.Max(1, profit1 - inc1); //now stop1 will alwas be 1 or bigger

I guess you were originally talking about sth. like (depending on the rest of your calculations, this might well be faster...):
 
Code
if(stop1>profit1) return;

vvhg

Hic Rhodos, hic salta.
Reply With Quote
  #6 (permalink)
 stepseazy 
Ithaca, NY
 
Experience: Beginner
Platform: Ninjatrader
Trading: CL
Posts: 7 since Oct 2011
Thanks Given: 1
Thanks Received: 1

I think what he meant is

profit=stop+inc

where inc >=0, stop>=0

Started this thread Reply With Quote
Thanked by:
  #7 (permalink)
 
vvhg's Avatar
 vvhg 
Northern Germany
 
Experience: Intermediate
Platform: NT
Trading: FDAX, CL
Posts: 1,583 since Mar 2011
Thanks Given: 1,016
Thanks Received: 2,824


stepseazy View Post
I think what he meant is

profit=stop+inc

where inc >=0, stop>=0

That would work, but will always include unneccessary runs as it will always work up to profit = maximum stop + maximum inc.
So if you want to run stop from 1-20 and profit also 1-20 it will in fact run up to profit = 39 ( stop 20 + inc 19).

Vvhg


Sent from my iPad using Tapatalk HD

Hic Rhodos, hic salta.
Reply With Quote
  #8 (permalink)
 
kronie's Avatar
 kronie 
NYC + NY / USA
 
Experience: Advanced
Platform: "I trade, therefore, I AM!"; Theme Song: "Atomic Dog!"
Trading: EMD, 6J, ZB
Posts: 796 since Oct 2009

what about the other improvements?, such as turning off Windows Search (disable), or making the settings on your windows 7 or 8, SSD capable, hence making it take longer on some tasks, like File_Explorer, but faster within Ninja?

something like disabling Windows Search service

Reply With Quote
  #9 (permalink)
 
quantismo's Avatar
 quantismo 
Waco TX.
 
Experience: Advanced
Platform: retired ...maybe
Trading: anything with the slightest edge..
Posts: 242 since Jul 2011
Thanks Given: 335
Thanks Received: 176

I find for me using the default setting in Ninjatrader Optimization is going to take me 10 to 50 times longer then the genetic settings. The results you get in the default should always be fairly close to what you come up with using the genetic settings unless your sampling to few trades over a long time period or very short periods in general.
I suggest forget the default and waiting 3 hours to 3 days for it to complete a complex optimization and do it in 3 to 30 minutes in the genetic mode.

Quantismo

Reply With Quote




Last Updated on September 5, 2014


© 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