Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
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 for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
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.
Can you help answer these questions from other members on NexusFi?
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.
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
@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:
ran into that problem also.....no one had an answer.....so under NT7 i would create my strategy with strategy builder go in an copy the code that belonged to my strategy...then... you could just take the ATMStrategy ...copy it and incorporate the strategy …
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
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.
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.
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
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.
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.