NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 10-28-2009, 09:55 AM   #1
nandradev
Junior Member
 
Join Date: Oct 2009
Location: Bogota,Colombia
Posts: 2
Thanks: 0
Thanked 0 times in 0 posts
Send a message via Skype™ to nandradev
Default Elder's Impulse indicator

Hello, I have been working with metatrader but new using ninja trader, I have been using this indicator I found in another forum, I wish to know if there is anybody cappable to translate this mt4 indicator to NT, this indicator works with an EMA and MACD Histogram, when MACD Histogram slope is up (slope up means two bars, if the last bar is higher than the previous one; and slope down when the last bar is lower than the previous one, no matter if lines are above or down the zero line), and the EMA slope is positive, it bar will be blue; if EMA slope is negative and MACD histogram is down, it bar will be red, and in other case will be gray.
changes in parameters like MACD and EMA can be done.

I have attached an image of how does it look like.
Thank you

this is the needed indicator language:

//+------------------------------------------------------------------+
//| eSignal.mq4 |
//| Copyright © 2007, Hartono Setiono |
//| http://www.mitrakom.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, Hartono Setiono"
#property link "http://www.mitrakom.com"
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_width1 4
#property indicator_color2 Blue
#property indicator_width2 4
#property indicator_color3 Lime
#property indicator_width3 4
//#property indicator_color4 Silver
//#property indicator_width4 1
//---- input parameters
extern int TimeFrame=0;
extern int EMA_Period=13;
extern int MACD_FastPeriod=12;
extern int MACD_SlowPeriod=26;
extern int MACD_SignalPeriod=9;
extern bool UseMT4MACD=false;
extern int DisplayType=1;
extern string N1="DisplayType Setting:";
extern string N2="1:Bar/Histogram Only";
extern string N3="2:Bar as MACD Histogram";
extern string N4="3:Bar as OSMA Histogram";
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double MACDLineBuffer[];
double MACDSignalLineBuffer[];
double MACDHistogramBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
IndicatorBuffers(6);

//---- indicators
SetIndexStyle(0,DRAW_HISTOGRAM);
//SetIndexArrow(0,110);
SetIndexBuffer(0,ExtMapBuffer1);

SetIndexStyle(1,DRAW_HISTOGRAM);
//SetIndexArrow(1,110);
SetIndexBuffer(1,ExtMapBuffer2);

SetIndexStyle(2,DRAW_HISTOGRAM);
//SetIndexArrow(2,110);
SetIndexBuffer(2,ExtMapBuffer3);
/*
if(DisplayType==2)
{
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(3,MACDSignalLineBuffer);
}
*/
SetIndexEmptyValue(3,0.0);
SetIndexBuffer(3,MACDSignalLineBuffer);
SetIndexEmptyValue(4,0.0);
SetIndexBuffer(4,MACDLineBuffer);
SetIndexEmptyValue(5,0.0);
SetIndexBuffer(5,MACDHistogramBuffer);

switch(TimeFrame)
{
case 1 : short_name="Period_M1"; break;
case 5 : short_name="Period_M5"; break;
case 15 : short_name="Period_M15"; break;
case 30 : short_name="Period_M30"; break;
case 60 : short_name="Period_H1"; break;
case 240 : short_name="Period_H4"; break;
case 1440 : short_name="Period_D1"; break;
case 10080 : short_name="Period_W1"; break;
case 43200 : short_name="Period_MN1"; break;
default : {short_name="Current Timeframe"; TimeFrame=0;}
}
short_name="Impulse Indicator("+short_name+", "+EMA_Period+":"+MACD_FastPeriod+","+MACD_SlowPeri od+","+MACD_SignalPeriod+")";
IndicatorShortName(short_name);
SetIndexLabel(1,NULL);
SetIndexLabel(2,NULL);
SetIndexLabel(3,NULL);
//SetIndexLabel(4,NULL);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int i,limit,y=0,counted_bars=IndicatorCounted();
double ema1, main1, signal1, ema0, main0, signal0, macd1, macd0, main;
double alpha = 2.0 / (MACD_SignalPeriod + 1.0);
double alpha_1 = 1.0 - alpha;
double BarValue;

limit=Bars-counted_bars;
for(i=limit-1; i >= 0; i--)
{
y = iBarShift(NULL,TimeFrame,Time[i]);
ema0=iMA(NULL,TimeFrame,EMA_Period,0,MODE_EMA,PRIC E_CLOSE,y);
ema1=iMA(NULL,TimeFrame,EMA_Period,0,MODE_EMA,PRIC E_CLOSE,y+1);
if(UseMT4MACD)
{
main0=iMACD(NULL, TimeFrame, MACD_FastPeriod, MACD_SlowPeriod, MACD_SignalPeriod, PRICE_CLOSE,0,y);
main1=iMACD(NULL, TimeFrame, MACD_FastPeriod, MACD_SlowPeriod, MACD_SignalPeriod, PRICE_CLOSE,0,y+1);
signal0=iMACD(NULL, TimeFrame, MACD_FastPeriod, MACD_SlowPeriod, MACD_SignalPeriod, PRICE_CLOSE,1,y);
signal1=iMACD(NULL, TimeFrame, MACD_FastPeriod, MACD_SlowPeriod, MACD_SignalPeriod, PRICE_CLOSE,1,y+1);

main=main0;
macd0=main0-signal0;
macd1=main1-signal1;
} else
{
MACDLineBuffer[y] = iMA(NULL,TimeFrame,MACD_FastPeriod,0,MODE_EMA,PRIC E_CLOSE,y)-
iMA(NULL,TimeFrame,MACD_SlowPeriod,0,MODE_EMA,PRIC E_CLOSE,y);
MACDSignalLineBuffer[y]=(alpha*MACDLineBuffer[y]) + (alpha_1*MACDSignalLineBuffer[y+1]);
MACDHistogramBuffer[y]=MACDLineBuffer[y]-MACDSignalLineBuffer[y];

main=MACDLineBuffer[y];
macd0=MACDHistogramBuffer[y];
macd1=MACDHistogramBuffer[y+1];
}

switch(DisplayType)
{
case 1:BarValue=1; break;
case 2:BarValue=main; break;
case 3:BarValue=macd0; break;
}

if(ema0<ema1 && macd0<macd1) //both down
{
ExtMapBuffer1[i]=BarValue;
ExtMapBuffer2[i]=0;
ExtMapBuffer3[i]=0;
} else
if(ema0>ema1 && macd0>macd1) //both up
{
ExtMapBuffer1[i]=0;
ExtMapBuffer2[i]=BarValue;
ExtMapBuffer3[i]=0;
} else //otherwise
{
ExtMapBuffer1[i]=0;
ExtMapBuffer2[i]=0;
ExtMapBuffer3[i]=BarValue;
}
}
return(0);
}
//+------------------------------------------------------------------+
Attached Images
File Type: jpg impulse indicator.JPG (33.8 KB, 108 views)
nandradev is offline  
Reply With Quote
Old 10-28-2009, 10:03 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,547
Thanks: 261
Thanked 1,012 times in 993 posts
Default

Welcome to our forums and thanks for sharing this source code - please have a look at this thread where the same indicator was developed (at least it should come close I believe) - http://www.ninjatrader-support2.com/...ead.php?t=6160
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 10-28-2009, 10:26 AM   #3
nandradev
Junior Member
 
Join Date: Oct 2009
Location: Bogota,Colombia
Posts: 2
Thanks: 0
Thanked 0 times in 0 posts
Send a message via Skype™ to nandradev
Default thank you

thank you bertrand, is almost what I am looking for, I send a message to wessel, asking for help with this indicator, thank you very much
nandradev is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Elder's - Force Index T2020 Indicator Development 24 05-17-2009 10:03 PM
Indicator: Removing and Custom Formatting an Indicator’s Chart Label NinjaTrader_Josh Reference Samples 0 12-30-2007 06:49 PM


All times are GMT -6. The time now is 11:26 PM.