NexusFi: Find Your Edge


Home Menu

 





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 SpeculatorSeth 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 SpeculatorSeth 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 3,361 views
    2. thumb_up 11 thanks given
    3. group 6 followers
    1. forum 11 posts
    2. attach_file 5 attachments




 
Search this Thread

How to choose the best period for indicators?

  #1 (permalink)
 
Tradeer's Avatar
 Tradeer 
Frankfurt/Hessern/Germany
 
Platform: Ninjatrader
Broker: Dorman Trading, CQG
Trading: Futures
Posts: 19 since May 2020
Thanks Given: 16
Thanks Received: 29

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

Can you help answer these questions
from other members on NexusFi?
About a successful futures trader who didn´t know anyth …
Psychology and Money Management
Trade idea based off three indicators.
Traders Hideout
Quant vue
Trading Reviews and Vendors
REcommedations for programming help
Sierra Chart
ZombieSqueeze
Platforms and Indicators
 
  #2 (permalink)
 SpeculatorSeth   is a Vendor
 
Posts: 780 since Apr 2016
Thanks Given: 22
Thanks Received: 1,018

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
Elite Membership required to download: DoubleStochasticsStrat.cs
Reply With Quote
  #3 (permalink)
 
Tradeer's Avatar
 Tradeer 
Frankfurt/Hessern/Germany
 
Platform: Ninjatrader
Broker: Dorman Trading, CQG
Trading: Futures
Posts: 19 since May 2020
Thanks Given: 16
Thanks Received: 29



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
Elite Membership required to download: DStochOpt.cs
Started this thread Reply With Quote
  #4 (permalink)
 
casey44's Avatar
 casey44 
Louisville KY
 
Experience: Beginner
Platform: NT8
Trading: micros
Frequency: Daily
Duration: Minutes
Posts: 248 since Jan 2010
Thanks Given: 4,055
Thanks Received: 313

@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 NexusFi Trade Journal Reply With Quote
Thanked by:
  #5 (permalink)
 
Tradeer's Avatar
 Tradeer 
Frankfurt/Hessern/Germany
 
Platform: Ninjatrader
Broker: Dorman Trading, CQG
Trading: Futures
Posts: 19 since May 2020
Thanks Given: 16
Thanks Received: 29


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
Thanked by:
  #6 (permalink)
 SpeculatorSeth   is a Vendor
 
Posts: 780 since Apr 2016
Thanks Given: 22
Thanks Received: 1,018


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
Thanked by:
  #7 (permalink)
 
Tradeer's Avatar
 Tradeer 
Frankfurt/Hessern/Germany
 
Platform: Ninjatrader
Broker: Dorman Trading, CQG
Trading: Futures
Posts: 19 since May 2020
Thanks Given: 16
Thanks Received: 29


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
  #8 (permalink)
 
Tradeer's Avatar
 Tradeer 
Frankfurt/Hessern/Germany
 
Platform: Ninjatrader
Broker: Dorman Trading, CQG
Trading: Futures
Posts: 19 since May 2020
Thanks Given: 16
Thanks Received: 29


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
  #9 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,103


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
Thanked by:
  #10 (permalink)
 
Tradeer's Avatar
 Tradeer 
Frankfurt/Hessern/Germany
 
Platform: Ninjatrader
Broker: Dorman Trading, CQG
Trading: Futures
Posts: 19 since May 2020
Thanks Given: 16
Thanks Received: 29



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




Last Updated on January 12, 2021


© 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