Convert MQ4 to Ninjatrader - NinjaTrader | futures io social day trading
futures io futures trading


Convert MQ4 to Ninjatrader
Updated: Views / Replies:1,423 / 14
Created: by Realtimetrader Attachments:8

Welcome to futures io.

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

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

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

Reply
 8  
 
Thread Tools Search this Thread
 

Convert MQ4 to Ninjatrader

  #11 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,653 since Mar 2010
Thanks: 4,226 given, 25,602 received
Forum Reputation: Legendary

Chande Kroll Stop for NinjaTrader

I have reviewed the Chande Kroll Stop in detail, and there are basically two points to consider:


Formula used for average true range

The book "The New Technical Trader" by Tushar Chande and Stanley Kroll was published in 1994. Chapter 7 "Controlling Risk: The Key To Profitablity" has the stop explained under the label "Volatility-Based Trailing Stops". From the text it becomes clear that Chande and Kroll have used a 10-period simple moving average of the true range.

The Chande Kroll Stop as implemented by ProRealTime relies on Wilder's ATR(10), which is an exponential moving average of the true range with a smoothing constant k = 0.1.

The third option would be a 10-period exponential moving average with a smoothing constant of k = 0.182.

All three options will be available for the NinjaTrader implementation of the Chande Kroll stop. The original formula used by Chande and Kroll will be the default option ("Arithmetic").


Intra-bar calculation of the ATR

Nearly all volatility based trailing stops are not designed for trading them intra-bar. An average true range should not be calculated when the current bar is still incomplete. In fact with the first tick of a new bar, the true range for that bar is usually zero or close to zero. The result is an instant drop of the ATR(10) of about 10%. Such a drop in volatility may lead to an adjustment of the stop and even trigger a breach of the stopline. However, it is not the stopline that should approach price due to a discontinuity in the formula, but it is price which should either move the stop along or breach it.

The first solution that came to my mind was to use the average true range calculated one bar ago. However, this approach would not work correctly for large breakout bars, as the stop would not take into account the volatility of the breakout. Therefore I have settled for a solution where I use the greater of the ATR(10) calculated for the prior and calculated for the current bar. This solution is the only easy way to calculatw the Chande Kroll Stop intra-bar and does not violate the original idea of its creators. Nevertheless, in case that you wish to use the indicator with setting "CalculateOnBarClose = True", you may revert to the original formula which is labeled "Current_Bar". The modified formula labeled "Current_And_Prior_Bar" will be chosen as the default setting.


Keeping it simple

The indicator is best used with default settings. However, if you wish to compare it with indicators of other software packages such as ProRealTime, you will find the options to make it compatible. For example, if you wish to show the indicator as it does in the ProRealTime version, you would select Wilder's smoothing for the ATR (not in line with the original stop) and would further calculate the ATR for the "Current_Bar" (and should not set the indicator to "COBC=False").


Comparison 1: Original ATR formula (blue & firebrick, solid) versus Wilder's smoothing (black & purple, dashdot)

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).



Comparison 2: Modified default formula (blue & firebrick, solid) versus original formula (black & purple, dashdot)

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).

Reply With Quote
The following 3 users say Thank You to Fat Tails for this post:
 
  #12 (permalink)
Elite Member
Overijssel
 
Futures Experience: Master
Platform: Ninja
Favorite Futures: FDAX
 
Posts: 14 since Aug 2010
Thanks: 3 given, 1 received


Fat Tails View Post
I have reviewed the Chande Kroll Stop in detail, and there are basically two points to consider:


Formula used for average true range

The book "The New Technical Trader" by Tushar Chande and Stanley Kroll was published in 1994. Chapter 7 "Controlling Risk: The Key To Profitablity" has the stop explained under the label "Volatility-Based Trailing Stops". From the text it becomes clear that Chande and Kroll have used a 10-period simple moving average of the true range.

The Chande Kroll Stop as implemented by ProRealTime relies on Wilder's ATR(10), which is an exponential moving average of the true range with a smoothing constant k = 0.1.

The third option would be a 10-period exponential moving average with a smoothing constant of k = 0.182.

All three options will be available for the NinjaTrader implementation of the Chande Kroll stop. The original formula used by Chande and Kroll will be the default option ("Arithmetic").


Intra-bar calculation of the ATR

Nearly all volatility based trailing stops are not designed for trading them intra-bar. An average true range should not be calculated when the current bar is still incomplete. In fact with the first tick of a new bar, the true range for that bar is usually zero or close to zero. The result is an instant drop of the ATR(10) of about 10%. Such a drop in volatility may lead to an adjustment of the stop and even trigger a breach of the stopline. However, it is not the stopline that should approach price due to a discontinuity in the formula, but it is price which should either move the stop along or breach it.

The first solution that came to my mind was to use the average true range calculated one bar ago. However, this approach would not work correctly for large breakout bars, as the stop would not take into account the volatility of the breakout. Therefore I have settled for a solution where I use the greater of the ATR(10) calculated for the prior and calculated for the current bar. This solution is the only easy way to calculatw the Chande Kroll Stop intra-bar and does not violate the original idea of its creators. Nevertheless, in case that you wish to use the indicator with setting "CalculateOnBarClose = True", you may revert to the original formula which is labeled "Current_Bar". The modified formula labeled "Current_And_Prior_Bar" will be chosen as the default setting.


Keeping it simple

The indicator is best used with default settings. However, if you wish to compare it with indicators of other software packages such as ProRealTime, you will find the options to make it compatible. For example, if you wish to show the indicator as it does in the ProRealTime version, you would select Wilder's smoothing for the ATR (not in line with the original stop) and would further calculate the ATR for the "Current_Bar" (and should not set the indicator to "COBC=False").


Comparison 1: Original ATR formula (blue & firebrick, solid) versus Wilder's smoothing (black & purple, dashdot)

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).



Comparison 2: Modified default formula (blue & firebrick, solid) versus original formula (black & purple, dashdot)

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).

Hi Fat Tails
We have in the past already contact (mail). I appreciate your contribution to the forum enormous. Also, the way you now explains to the Chande Kroll Stop system is enormous. I hope that many traders have something to do with the Chande Kroll Stop. It is a useful tool and I worked there for years. I have searched a long time on the internet whether it was available for NinjaTrader. You give me and other traders have the opportunity to use this indicator. Great job my compliments.

Reply With Quote
 
  #13 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,653 since Mar 2010
Thanks: 4,226 given, 25,602 received
Forum Reputation: Legendary

Two options to deal with volatility based stops


I am still hesitating as there are several options to build volatility based stops that work intra-bar.


Comparing Chande Kroll Stop to the SuperTrendM11:

The SuperTrend belongs to the same class of volatility based stops as does the ChandeKrollStop. The long stop is determined by subtracting a multiple of the ATR from a moving average or moving median. The short stop is calculated by adding the same multiple of the ATR to the moving average or median. The problems I had encountered when coding the SuperTrendM11 were similar

(1) The ATR should not be calculated intra-bar, because it is too small when the new bar only consists of a few ticks. The solution I had adopted was to take the ATR one bar ago. This solution makes sure that the stop line does not temporarily move towards price while the range of the current bar is still incomplete.

(2) I had also taken the moving average and median one bar ago. This avoids recalculating the moving average and median intra-bar. In case that price moves against the current trend, there are no side effects from this modification. However, if price makes a large intra-bar move with the current trend

-> the stop line which is calculated from the prior value of moving average or median is further away
-> the stop adjustment takes only place with a delay of 1 bar
-> intra-bar profits generated by the large move are protected to a lesser extent

(3) However there is a practical advantage that comes from calculating the stop based on values 1 bar ago. The stop remains unchanged throughout the life of the bar. When the stop is touched in a backtest, it is clear that the stop was hit because price has approached it. Otherwise, if the stop moved along with price, it cannot be determined whether prices hit the stop or the stop hit (the historical fraction of) the candle

This means that the SuperTrendM11 is fool-proof (safe to use for myself) with automated strategies!


Suggested design is not fool-proof:

The approach that I had suggested in post # 11 of this thread may lead to problems when the indicator is used for automated trading. It is not clear whether price moved to the stop or whether the stop approached the bar. Therefore I have now added an option to the indicator, which uses the same basic design as I have already used for the SuperTrend and the Chandelier Stop.

The result is shown in the chart below. You will easily see that the modified Chande Kroll Stop (blue and red) lags by one bar during a strong trend. However, the lag is non-existent during consolidations and reversals. Personally, I prefer this solution to the other approaches. You get an indicator which is slightly different from the original, but it can be used intra-bar without problems and does not cause intra-bar problems with standard backtests.

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).

Reply With Quote
The following 2 users say Thank You to Fat Tails for this post:
 
  #14 (permalink)
Elite Member
Overijssel
 
Futures Experience: Master
Platform: Ninja
Favorite Futures: FDAX
 
Posts: 14 since Aug 2010
Thanks: 3 given, 1 received


Fat Tails View Post
I am still hesitating as there are several options to build volatility based stops that work intra-bar.


Comparing Chande Kroll Stop to the SuperTrendM11:

The SuperTrend belongs to the same class of volatility based stops as does the ChandeKrollStop. The long stop is determined by subtracting a multiple of the ATR from a moving average or moving median. The short stop is calculated by adding the same multiple of the ATR to the moving average or median. The problems I had encountered when coding the SuperTrendM11 were similar

(1) The ATR should not be calculated intra-bar, because it is too small when the new bar only consists of a few ticks. The solution I had adopted was to take the ATR one bar ago. This solution makes sure that the stop line does not temporarily move towards price while the range of the current bar is still incomplete.

(2) I had also taken the moving average and median one bar ago. This avoids recalculating the moving average and median intra-bar. In case that price moves against the current trend, there are no side effects from this modification. However, if price makes a large intra-bar move with the current trend

-> the stop line which is calculated from the prior value of moving average or median is further away
-> the stop adjustment takes only place with a delay of 1 bar
-> intra-bar profits generated by the large move are protected to a lesser extent

(3) However there is a practical advantage that comes from calculating the stop based on values 1 bar ago. The stop remains unchanged throughout the life of the bar. When the stop is touched in a backtest, it is clear that the stop was hit because price has approached it. Otherwise, if the stop moved along with price, it cannot be determined whether prices hit the stop or the stop hit (the historical fraction of) the candle

This means that the SuperTrendM11 is fool-proof (safe to use for myself) with automated strategies!


Suggested design is not fool-proof:

The approach that I had suggested in post # 11 of this thread may lead to problems when the indicator is used for automated trading. It is not clear whether price moved to the stop or whether the stop approached the bar. Therefore I have now added an option to the indicator, which uses the same basic design as I have already used for the SuperTrend and the Chandelier Stop.

The result is shown in the chart below. You will easily see that the modified Chande Kroll Stop (blue and red) lags by one bar during a strong trend. However, the lag is non-existent during consolidations and reversals. Personally, I prefer this solution to the other approaches. You get an indicator which is slightly different from the original, but it can be used intra-bar without problems and does not cause intra-bar problems with standard backtests.

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).

Hi Fat Tails,

As you show me in the graph the difference is extremely small. The Chande Kroll Stop I want to use for manual intraday trading and there I will not have a system (to) make. I understand your explanation completely. The program I leave entirely up to you

Thanks for your reply.

Reply With Quote
 
  #15 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,653 since Mar 2010
Thanks: 4,226 given, 25,602 received
Forum Reputation: Legendary

Answer
This post has been selected as an answer to the original posters question Answer


Realtimetrader View Post
Hi Fat Tails,

As you show me in the graph the difference is extremely small. The Chande Kroll Stop I want to use for manual intraday trading and there I will not have a system (to) make. I understand your explanation completely. The program I leave entirely up to you

Thanks for your reply.


I have settled for a simple implementation that lets you calculate ATR & 10 bar high/low either from the current or the prior bar. Calculating it from the current bar leads to the problems that I have described. Calculating it from the prior bar is playing safe for automated strategies and applying the indicator intra-bar.

But I prefer to let the user decide on selecting the proper formula.

The indicator can be found here:

https://futures.io/download/ninjatrader-7/indicators/1662-download.html

Reply With Quote
The following 4 users say Thank You to Fat Tails for this post:

Reply



futures io > > > > Convert MQ4 to Ninjatrader

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mq4 indicator Conversion To Ninjatrader 7 stef NinjaTrader Programming 1 June 22nd, 2015 09:49 AM
MQ4 to Ninjatrader conversion bryce NinjaTrader Programming 37 September 4th, 2014 05:22 PM
[help] Still unable to convert this MQ4 indicator to Thinkscript Ardian1899 ThinkOrSwim Programming 0 July 3rd, 2014 06:10 AM
Convert MQ4 indicator to Ninjascript rookietrader11 NinjaTrader Programming 3 May 3rd, 2013 06:35 PM


All times are GMT -4. The time now is 07:25 AM.

Copyright © 2017 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
Page generated 2017-12-16 in 0.15 seconds with 30 queries on phoenix via your IP 54.226.113.250