How to choose the best period for indicators? - futures io
futures io futures trading



How to choose the best period for indicators?


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Tradeer with 6 posts (1 thanks)
    2. looks_two TWDsje with 3 posts (7 thanks)
    3. looks_3 Fat Tails with 2 posts (2 thanks)
    4. looks_4 casey44 with 1 posts (1 thanks)
      Best Posters
    1. looks_one TWDsje with 2.3 thanks per post
    2. looks_two Fat Tails with 1 thanks per post
    3. looks_3 casey44 with 1 thanks per post
    4. looks_4 Tradeer with 0.2 thanks per post
    1. trending_up 1,352 views
    2. thumb_up 11 thanks given
    3. group 6 followers
    1. forum 11 posts
    2. attach_file 5 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

How to choose the best period for indicators?

(login for full post details)
  #1 (permalink)
Frankfurt/Hessern/Germany
 
Platform: Ninjatrader
Broker: Dorman Trading, CQG
Trading: Futures
 
Tradeer's Avatar
 
Posts: 13 since May 2020
Thanks: 11 given, 5 received

Hi guys this is my first thread and glad to be here
I have the following question,

How to choose the best period for indicators?

The indicator I want to test is the double stochastic.

The indicator should be evaluated in the range ( => 90 SHORT ) and ( =< 10 LONG ).
It should ideally separate out small movements and give signals for only tick relevant targets. e.g. 10Tick, 30 Tick, 50Tick or 100Tick.
I wanted to do a backtest on it but don't know how to do it for an indicator to optimize periods.

For info I am using a 1 range chart.
Currently I use a period of 256 which is the maximum of Ninjatrader.
I use this period because I want to filter out the small fluctuations.
A picture for example is attached

What is the best approach to find the best period for me.
Maybe someone here in the forum has already done something like this it would help me a lot and I would appreciate it.

I have experience in programming C# and javascript and have already programmed some stuff for it. Like a game for Android published in the Google play store but would still call myself a beginner. In ninjascript I have also programmed small things like simple strategies and indicators but programming with ninjascript is still difficult for me.


Started this thread Reply With Quote

Journal Challenge February 2021 results (so far):
Competing for $1500 in prizes from Topstep
looks_oneSBtrader82 's Trading Journalby SBtrader82
(167 thanks from 31 posts)
looks_twoJust BEING a Trader: Letting Go!!by iqgod
(116 thanks from 33 posts)
looks_3Wisdom is Emptinessby Mtype
(68 thanks from 25 posts)
looks_4Deetee’s DAX Trading Journal (time based)by Deetee
(31 thanks from 17 posts)
looks_5Journal for peanuts1956by peanuts1956
(23 thanks from 13 posts)
 
 
(login for full post details)
  #2 (permalink)
SpeculatorSeth
Salt Lake City, Utah
 
Platform: Jigsaw, NinjaTrader8
 
Posts: 621 since Apr 2016
Thanks: 19 given, 655 received

Ahh you were asking about this on my stream today?

After trying a few optimization runs it seems that 20-30 works best for this. I am able to get a positive total net profit if I set the stop and reward factor really high. However, it's only making money on the longs. So there's probably not any edge to it, we're just picking up on the tendency for the market to move up.

Attached Files
Register to download File Type: cs DoubleStochasticsStrat.cs (3.2 KB, 7 views)
Reply With Quote
The following 3 users say Thank You to TWDsje for this post:
 
(login for full post details)
  #3 (permalink)
Frankfurt/Hessern/Germany
 
Platform: Ninjatrader
Broker: Dorman Trading, CQG
Trading: Futures
 
Tradeer's Avatar
 
Posts: 13 since May 2020
Thanks: 11 given, 5 received



TWDsje View Post
Ahh you were asking about this on my stream today?

After trying a few optimization runs it seems that 20-30 works best for this. I am able to get a positive total net profit if I set the stop and reward factor really high. However, it's only making money on the longs. So there's probably not any edge to it, we're just picking up on the tendency for the market to move up.

Hey Seth,

thanks for your reply. I have tested your attached strategy but there were some issues. There shouldn't be entrys at a crossabove or crossbelow. There should be entrys at <= 10 || >= 90. And there was one problem with the SetProfitTarget the Stop was multiplied by the target. Thanks for the approach I will optimize it for me. I attached the strategy with entrys <= 5 || >= 95. I will test it out what is the best period for different tick targets


Attached Files
Register to download File Type: cs DStochOpt.cs (3.4 KB, 4 views)
Started this thread Reply With Quote
 
(login for full post details)
  #4 (permalink)
Flagstaff AZ/USA
 
Experience: Beginner
Platform: NT8
Trading: micros
 
casey44's Avatar
 
Posts: 194 since Jan 2010
Thanks: 3,105 given, 244 received

@Tradeer, wondered if you'd tried the NT Strategy Builder for optimizing... Given your background you may not need help with it but fwiw there is a thread for that:


And if have Elite membership, there's a thread subtitled “ want-your-ninjatrader-strategy-created-free”

Good luck, hope you'll post further, interesting study.

Visit my futures io Trade Journal Reply With Quote
The following user says Thank You to casey44 for this post:
 
(login for full post details)
  #5 (permalink)
Frankfurt/Hessern/Germany
 
Platform: Ninjatrader
Broker: Dorman Trading, CQG
Trading: Futures
 
Tradeer's Avatar
 
Posts: 13 since May 2020
Thanks: 11 given, 5 received


casey44 View Post
@Tradeer, wondered if you'd tried the NT Strategy Builder for optimizing... Given your background you may not need help with it but fwiw there is a thread for that:


And if have Elite membership, there's a thread subtitled “ want-your-ninjatrader-strategy-created-free”

Good luck, hope you'll post further, interesting study.

Hi casey, thanks for your reply and the link to a thread about the strategy builder.

I have worked with the strategy builder before and it is a very good tool for learning ninjascript.
The file I have attached matches my equivalents
but I still wonder if there is a better method.

So these are my results I worked with a 12 tick stop, it is a rough calculation but a good guideline.
The test had only a duration of 1 year, because otherwise ninjatrader crashes with me.
The 1 tick range bars consume a lot of RAM I already have 32GB but it is apparently not enough.

TEST RESULTS:
(MES) 1 Range chart

Indicator: Doublestochastic period 5-256 increment by 10
Fixed stop: 12Tick
Time frame: 11.2019- 01.2021

10Ticktarget (5period)
20Ticktarget (25period)
30Ticktarget (105period)
40Ticktarget (75period)
50Ticktarget (115,225,215period)
60Ticktarget (115period)
70Ticktarget (175,155,235period)
80Ticktarget (245period)
90Ticktarget (165period)
100Ticktarget (205period)
120Ticktarget (165period)
150Ticktarget (25period)
200Ticktarget (145period)

It is a rough backtest, it will probably vary for you.
I will do more precise tests in the future, for now I use the 115 period for my discretionary trading style.

Started this thread Reply With Quote
The following user says Thank You to Tradeer for this post:
 
(login for full post details)
  #6 (permalink)
SpeculatorSeth
Salt Lake City, Utah
 
Platform: Jigsaw, NinjaTrader8
 
Posts: 621 since Apr 2016
Thanks: 19 given, 655 received


Tradeer View Post
Hey Seth,

thanks for your reply. I have tested your attached strategy but there were some issues. There shouldn't be entrys at a crossabove or crossbelow. There should be entrys at <= 10 || >= 90. And there was one problem with the SetProfitTarget the Stop was multiplied by the target. Thanks for the approach I will optimize it for me. I attached the strategy with entrys <= 5 || >= 95. I will test it out what is the best period for different tick targets


Correct. So if you set the strategy to go short any time myOscillator[0] >= 90 then it would continue to try and take shorts over and over again. Waiting for the cross of 90 ensures that it only takes one trade.

Similarly the strategy is setup for your target to be a multiple of your risk. So if you want equal risk reward you just set the target to be 1. Normally I rename it to "reward factor" not sure why I didn't do that this time.

Reply With Quote
The following 3 users say Thank You to TWDsje for this post:
 
(login for full post details)
  #7 (permalink)
Frankfurt/Hessern/Germany
 
Platform: Ninjatrader
Broker: Dorman Trading, CQG
Trading: Futures
 
Tradeer's Avatar
 
Posts: 13 since May 2020
Thanks: 11 given, 5 received


TWDsje View Post
Correct. So if you set the strategy to go short any time myOscillator[0] >= 90 then it would continue to try and take shorts over and over again. Waiting for the cross of 90 ensures that it only takes one trade.

Similarly the strategy is setup for your target to be a multiple of your risk. So if you want equal risk reward you just set the target to be 1. Normally I rename it to "reward factor" not sure why I didn't do that this time.

Ah ok i see you mean the risk to reward ratio that's a good idea.

Yes my added file makes multiple trades but only when you are stopped out otherwise not. You are welcome to take a look at it.

I have tested your file with the forward optimization.
Time period 01.01.2019 - 07.01.2021

Here are the results for info if anyone is interested.



The best is a period of 251 with a risk reward ratio of 20. The stop is 8 ticks.

I have now come to the realization that the period of 115 is not suitable for my approach and now use a period above 200.

Started this thread Reply With Quote
 
(login for full post details)
  #8 (permalink)
Frankfurt/Hessern/Germany
 
Platform: Ninjatrader
Broker: Dorman Trading, CQG
Trading: Futures
 
Tradeer's Avatar
 
Posts: 13 since May 2020
Thanks: 11 given, 5 received


Tradeer View Post
Ah ok i see you mean the risk to reward ratio that's a good idea.

Yes my added file makes multiple trades but only when you are stopped out otherwise not. You are welcome to take a look at it.

I have tested your file with the forward optimization.
Time period 01.01.2019 - 07.01.2021

Here are the results for info if anyone is interested.



The best is a period of 251 with a risk reward ratio of 20. The stop is 8 ticks.

I have now come to the realization that the period of 115 is not suitable for my approach and now use a period above 200.

Another good way if you are unsure which period to use are the fibonacci sequences
Here are a few sequences:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765

Started this thread Reply With Quote
 
(login for full post details)
  #9 (permalink)
Market Wizard
Berlin, Europe
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,855 since Mar 2010
Thanks: 4,238 given, 26,728 received


Tradeer View Post
Hi guys this is my first thread and glad to be here
I have the following question,

How to choose the best period for indicators?

The indicator I want to test is the double stochastic.

The indicator should be evaluated in the range ( => 90 SHORT ) and ( =< 10 LONG ).
It should ideally separate out small movements and give signals for only tick relevant targets. e.g. 10Tick, 30 Tick, 50Tick or 100Tick.
I wanted to do a backtest on it but don't know how to do it for an indicator to optimize periods.

For info I am using a 1 range chart.
Currently I use a period of 256 which is the maximum of Ninjatrader.
I use this period because I want to filter out the small fluctuations.
A picture for example is attached

What is the best approach to find the best period for me.
Maybe someone here in the forum has already done something like this it would help me a lot and I would appreciate it.

I have experience in programming C# and javascript and have already programmed some stuff for it. Like a game for Android published in the Google play store but would still call myself a beginner. In ninjascript I have also programmed small things like simple strategies and indicators but programming with ninjascript is still difficult for me.



Develop a trading strategy and run a portfolio backtest across different instruments. Then run the strategy through an optimizer and check for the best value for your indicator period.

By the way, 256 is NOT the maximum period available for NinjaTrader. You may also set your indicator to a period like 1000 bars. Also the number of bars that are used for an indicator do not depend on the indicator period alone:

- a SMA (1000) is calculated from the closes of the last 1000 bars
- an EMA (1000) is calculated from the current close and the prior value for the EMA(1000)
- for a Double Stochastics this slightly more complex as there are several steps involved, some of them similar to the calculation of the SMA and others similar to the calculation of the EMA

The limitation of 256 bars only applies in case that you have set the interal data series of the indicator to MaximumBarsLookBack.TwoHundredFiftySix. In this case the data series do not use as much RAM (it is a RAM saver only) when compared to the setting MaximumBarsLookBack.Infinite. No problem, if you run a PC with 16 GByte of RAM or more.

Reply With Quote
The following user says Thank You to Fat Tails for this post:
 
(login for full post details)
  #10 (permalink)
Frankfurt/Hessern/Germany
 
Platform: Ninjatrader
Broker: Dorman Trading, CQG
Trading: Futures
 
Tradeer's Avatar
 
Posts: 13 since May 2020
Thanks: 11 given, 5 received



Fat Tails View Post
Develop a trading strategy and run a portfolio backtest across different instruments. Then run the strategy through an optimizer and check for the best value for your indicator period.

By the way, 256 is NOT the maximum period available for NinjaTrader. You may also set your indicator to a period like 1000 bars. Also the number of bars that are used for an indicator do not depend on the indicator period alone:

- a SMA (1000) is calculated from the closes of the last 1000 bars
- an EMA (1000) is calculated from the current close and the prior value for the EMA(1000)
- for a Double Stochastics this slightly more complex as there are several steps involved, some of them similar to the calculation of the SMA and others similar to the calculation of the EMA

The limitation of 256 bars only applies in case that you have set the interal data series of the indicator to MaximumBarsLookBack.TwoHundredFiftySix. In this case the data series do not use as much RAM (it is a RAM saver only) when compared to the setting MaximumBarsLookBack.Infinite. No problem, if you run a PC with 16 GByte of RAM or more.

Hi Fat Tails,

thanks for your answer and tips! I appreciate it.
I have already tested a period of 200-1000 with interesting results.
Yes the RAM memory should not really be a problem, nevertheless Ninajtrader often crashes, especially with the normal optimization which almost doesn't work at all with range bars for a longer period.

Started this thread Reply With Quote
 
(login for full post details)
  #11 (permalink)
Market Wizard
Berlin, Europe
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,855 since Mar 2010
Thanks: 4,238 given, 26,728 received


Tradeer View Post
Hi Fat Tails,

thanks for your answer and tips! I appreciate it.
I have already tested a period of 200-1000 with interesting results.
Yes the RAM memory should not really be a problem, nevertheless Ninajtrader often crashes, especially with the normal optimization which almost doesn't work at all with range bars for a longer period.

When NinjaTrader crashes, this is likely due to indicators or strategies that have not been properly coded. Backtesting with range bars should not cause any problems either.

Reply With Quote
The following user says Thank You to Fat Tails for this post:
 
(login for full post details)
  #12 (permalink)
SpeculatorSeth
Salt Lake City, Utah
 
Platform: Jigsaw, NinjaTrader8
 
Posts: 621 since Apr 2016
Thanks: 19 given, 655 received

There are definitely issues with the strategy analyzer. There is some sort of lingering memory leak. You'll run out of memory as you run tests even if the strategy only uses built in indicators. Setting IncludeTradeHistoryInBacktest = false and IsInstantiatedOnEachOptimizationIteration = false can help, but you'll probably still run into situations where you just need to restart Ninja to free up memory. More iterations also increase memory usage. So when I had 16gb ram I could only run about 1000 iterations.

Reply With Quote
The following user says Thank You to TWDsje for this post:


futures io Trading Community Platforms and Indicators NinjaTrader > How to choose the best period for indicators?


Last Updated on January 12, 2021


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Journal Challenge w/$1500 prizes from Topstep!

February
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
 

Call Option Buying: The New Pain Trade? w/Carley Garner

Elite only
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts