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 12-05-2008, 01:22 PM   #1
Ninja B
Member
 
Join Date: Apr 2008
Posts: 99
Thanks: 0
Thanked 0 times in 0 posts
Lightbulb Quick MA an alternative to Juirk MA

I remember a good while ago Elliot looking for something like this and he shared the Modified Optimal Elliptical Filter. The indicator is in Easy language. If someone could translate it, it would be very useful to all NT users.

Here's a pic comparing them. Jurik is cyan and Quick is yellow. Also attached is the code is in the zip file.

okay also posting the code.

Quote:
// Plots a fractional-bar Quick Moving Average
// with the option to select gapless daily opens.
//
// copyright 2008 John McCormick jmactrader.com
//
// feel free to copy and use this code royalty free
// as long as it retains the above acknowledge
//

inputs:
Price(Close),
Quick_Length(9),
displace(0),
gapless(0); // set gap to a non-zero value to skip over opening daily gaps

Var: Length(maxlist(1,Quick_Length));

// GapLess

Vars: // gapless O,H,L,C where O=C[1]
RelO(0),
RelH(0),
RelL(0),
RelC(0),
gap(0),
Accum(0),
WtMean(0);

if date<>date[1] then begin
gap = O-C[1];
Accum = Accum+gap;
end;

RelO = O-Accum;
RelC = C-Accum;
RelH = H-Accum;
RelL = L-Accum;

// Gapless bars - end

WtMean = (RelH+RelL+RelC)/3;

// End Gapless

if gapless=0
then plot1[displace](FMA_Smooth(price,length),"FMA_Quick")
else plot1[displace](FMA_Smooth(RelC,length)+accum,"FMA_Quick");

Function-------------------------------------------------------

// generates very smooth and responsive moving average
// copyright 2008 John McCormick jmactrader.com
// feel free to copy and use this code royalty free
// as long as you don't remove the above acknowledgement
//

Inputs:
Price(numericseries),
Length(numericsimple);

Vars:
j(0),
workinglen(maxlist(1,absvalue(Length))),
peak(workinglen/3),
tot(0),
divisor(0);

Array:
val[100](0);

if workinglen>100 then workinglen=100; // use larger array to handle lengths over 100


tot=0;
divisor=0;
for j=1 to floor(workinglen+1) begin
if j<=peak then val[j]=j/peak
else val[j]=(workinglen+1-j)/(workinglen+1-peak);
tot=tot+price[j-1]*val[j];
divisor=divisor+val[j];
end;
if divisor<>0 then FMA_smooth=tot/divisor;
The code under the dashes is the smoothing function.
Attached Images
File Type: jpg 15f4nqe.jpg (57.4 KB, 367 views)
Attached Files
File Type: zip QUICK.zip (4.6 KB, 109 views)
Last edited by Ninja B; 12-06-2008 at 09:43 AM.
Ninja B is offline  
Reply With Quote
Old 12-05-2008, 01:41 PM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

As a last resort you can try a 3rd party NinjaScript Consultant here if you want: http://www.ninjatrader.com/webnew/pa...injaScript.htm
NinjaTrader_Josh is offline  
Reply With Quote
Old 12-05-2008, 03:14 PM   #3
Elliott Wave
Senior Member
 
Join Date: Mar 2008
Posts: 731
Thanks: 0
Thanked 1 time in 1 post
Default

MOEF is in this thread if anyone needs it.

http://www.ninjatrader-support2.com/...ad.php?p=42360

BTW, when it comes to short periods I've found that the closest thing to the JMA is the ADXVMA. For longer periods I think ZiNonLagMA and StepMA are just as good if not better than the JMA.

Also if you post the actual code you might have better luck than an ELD file which requires TS to open.
Elliott Wave is offline  
Reply With Quote
Old 12-06-2008, 09:44 AM   #4
Ninja B
Member
 
Join Date: Apr 2008
Posts: 99
Thanks: 0
Thanked 0 times in 0 posts
Default

^^^ Thanks. I use StepMA also. It's great. Posted the actual code.
Ninja B is offline  
Reply With Quote
Old 01-09-2009, 02:10 AM   #5
WhoKnows
Member
 
Join Date: Nov 2008
Location: Australia
Posts: 64
Thanks: 0
Thanked 0 times in 0 posts
Default

As a Ninja beginner and non-programmer, I am entering the steep learning curve of going beyond the strategy builder.

I am trying to generate some strategies with the huge selection of MovingAverages. I see several indicators where lines change in color depending on trend conditions. However how do you use this in strategies?

As a simple approach I tried to use the ZiNonLagMA in a strategy, E.g. Just trying to buy where yellow goes to green and sell when green to yellow or red.

Is there a way to use the Plot Values "UpTrend", "DownTrend" and "NonTrend" directly in a strategy with some sort of a boolean expression?
e.g. If ..... is "UpTrend" then ....
It does not work with the strategy builder.


After looking at the indicator code, I tried to use the sTrend expression in a strategy with
UpTrend: "if ( ZiNonLagma.sTrend[0] > 0 && ZiNonLagma.sTrend[1] > 0 )" then ....
DownTrend: "if ( ZiNonLagma.sTrend[0] < 0 && ZiNonLagma.sTrend[1] < 0 )" then ....
It did not do what I wanted, but these expressions appear to trigger at least something.

However I got totally stuck with the NonTrend part.
If I understand the code in the indicator file correctly the NonTrend is determined first (before the Up and Downtrend) via a user definable filter calculation.

// Plot Non Trend
Values[2].Set( 0, serie[0] );

sTrend[0] = sTrend[1];

if ( serie[0] - serie[1] > filter * TickSize / splitTick )
sTrend.Set( 0, 1);
else if ( serie[1] - serie[0] > filter * TickSize / splitTick )
sTrend.Set(0, -1);
else
sTrend.Set(0, 0);



I tried using "ZiNonLagma.sTrend[0] = ZiNonLagma.sTrend[1]" as exit condition, but that did not work.


Anybody an idea or pointer on how to use the ZiNonLagMA correctly in a strategy?

PS I attached my non working teststrategy and the ZiNonLagMa indicator as this indicator was non easy to find... just stumbled on it when reading the posts.
Attached Files
File Type: zip ZiNonLagmaIndicaorAndNonWorkingStrategy.zip (4.0 KB, 82 views)
WhoKnows is offline  
Reply With Quote
Old 01-09-2009, 07:14 AM   #6
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Not sure exactly what you are trying. You cannot create plots from a strategy. However you can create DataSeries and the access it the information just like a plot.
NinjaTrader_Josh 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
Above MA bar is green, below MA bar is red? BottomShark77 NinjaScript File Sharing Discussion 1 12-01-2008 05:24 AM
Rethink MA pivot44 Suggestions And Feedback 1 11-20-2008 02:14 PM
MA Envelopes niterider Charting 1 06-26-2008 09:11 AM
MA Crossover joecgoodman Indicator Development 3 06-03-2008 02:08 PM
MA suggestion nicko9 Historical NinjaTrader 6.5 Beta Threads 1 03-12-2008 03:10 AM


All times are GMT -6. The time now is 01:43 AM.