Convert Custom MACD Script To Work With Ninja Trader API - NinjaTrader | futures io social day trading
futures io futures trading


Convert Custom MACD Script To Work With Ninja Trader API
Updated: Views / Replies:1,475 / 3
Created: by conord Attachments:2

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
 
Thread Tools Search this Thread
 

Convert Custom MACD Script To Work With Ninja Trader API

  #1 (permalink)
Trading Apprentice
Ireland
 
Futures Experience: Intermediate
Platform: Ninja Trader
Favorite Futures: Forex
 
Posts: 3 since Feb 2013
Thanks: 1 given, 0 received

Convert Custom MACD Script To Work With Ninja Trader API

Hi All,

I'm new to Ninja Trader and have been really struggling to convert a short MACD scrip to use as a custom indicator with the Ninja Trader API. The script below if for a MACD crossover and histogram chart similar to Ninja Trader's default one, however the histogram is color coded to indicate if the %K line is positive or negative and also indicates if %K is trending higher or lower, any assistance would be very much appreciated as my frustration has reached boiling point.

Many thanks in advance.

Conor.

<-------------------------------------------------------------------------------------------------------->
declare lower;

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input AverageType = {SMA, default EMA};

plot Value;
plot Avg;
switch (AverageType) {
case SMA:
Value = Average(close, fastLength) - Average(close, slowLength);
Avg = Average(Value, MACDLength);
case EMA:
Value = ExpAverage(close, fastLength) - ExpAverage(close, slowLength);
Avg = ExpAverage(Value, MACDLength);
}

plot Diff = Value - Avg;
plot ZeroLine = 0;

Value.SetDefaultColor(GetColor(1));
Avg.SetDefaultColor(GetColor(8));
Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.DARK_RED);
Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.color("Positive and Up") else Diff.color("Positive and Down") else if Diff < Diff[1] then Diff.color("Negative and Down") else Diff.color("Negative and Up"));
ZeroLine.SetDefaultColor(GetColor(0));

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

The MACD does not have a %K line, but I suppose you talk about the histogram.

When I use the MACD what is most important to me is whether the MACD itself is positive. This is a proxy for momentum. You can basically use the MACD as follows

raw MACD = proxy for momentum = proxy for price change
histogram = proxy for momentum change = proxy for curvature of price move
slope of histogram = proxy for curvature of momentum

If you only look at the histogram and its slope, you are missing the essential point, which is the direction of momentum. I would therefore suggest to build a trendfilter based on the MACD and the histogram, but not take into account the slope of the histogram, or at least underweigh it for the purpose of determining the trend.

The attached indicator is an MACD that can be calculated from 27 different moving averages. It has an integrated trendfilter, which is based on the direction of the raw MACD and the histogram.

MACD > 0 && histogram > 0 -> uptrend
MACD > 0 && histogram < 0 -> no trend
MACD < 0 && histogram > 0 -> no trend
MACD < 0 && histogram < 0 -> downtrend

You could try to modify it in order to suit your needs. Please save the modified version under a new name, and also replace enums, because otherwise the new indicator will not compile.

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

Attached Files
Register to download File Type: zip MACDUniversalX2.zip (56.2 KB, 45 views)
Reply With Quote
The following 3 users say Thank You to Fat Tails for this post:
 
  #3 (permalink)
Trading Apprentice
Ireland
 
Futures Experience: Intermediate
Platform: Ninja Trader
Favorite Futures: Forex
 
Posts: 3 since Feb 2013
Thanks: 1 given, 0 received

Many thanks


Hi Fat Tails, many thanks for your feedback, I am in agreement with your comments regarding interpretation of the MACD, I guess I could of been a little more specific in my initial post. I trade daily charts and find the histogram re-tracement a useful exit signal, but sometimes the histogram will publish similar 2 or 3 similar values consequently which can makes it difficult to interpret by glancing at the histogram. Nevertheless I'm looking forward to having a play about with your attached file.

Best regards,
Conor.

Reply With Quote
 
  #4 (permalink)
Trading Apprentice
Ireland
 
Futures Experience: Intermediate
Platform: Ninja Trader
Favorite Futures: Forex
 
Posts: 3 since Feb 2013
Thanks: 1 given, 0 received

Many thanks again for the feed back, this thread is now closed. Best regard conord

Reply With Quote

Reply



futures io > > > > Convert Custom MACD Script To Work With Ninja Trader API

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Thinkorswim custom script for Stock/ETF / volatility percent percentile range peroulias ThinkOrSwim 11 January 19th, 2015 12:20 PM
Ninja Trader Custom Order Book - 1LDom - Source Code 1LotTrader NinjaTrader Programming 356 February 19th, 2014 12:40 PM
Need help for a very simple script for Ninja Trader vgbouchet NinjaTrader Programming 7 December 1st, 2011 04:06 PM
AND NOT operator on Ninja Trader script?!? vgbouchet NinjaTrader Programming 3 November 27th, 2011 12:53 AM
custom program work gparkis Trading Reviews and Vendors 2 January 13th, 2011 12:17 AM


All times are GMT -4. The time now is 10:51 PM.

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-11 in 0.10 seconds with 20 queries on phoenix via your IP 54.145.16.43