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 05-13-2009, 03:03 AM   #1
nescio
Junior Member
 
Join Date: Feb 2009
Posts: 13
Thanks: 0
Thanked 0 times in 0 posts
Default Problem with KAMA difference indicator

Dear support and forum members,

I was searching for an answer to my problem, but couldn't find one on the forum or internet. Hoping it will not sound to ridiculous to you, here is what I am trying to solve:

I would like to construct an indicator that plots the difference between KAMA[0] and KAMA[n], n days ago; for simplicity I assume n=3. First I coded in OnBarUpdate():

Code:
Plot0.Set(KAMA(Close,2,10,30)[0]);
to just display the KAMA[0] value in a seperate plot which worked out perfectly on a newly opened chart. I then close the chart changed the code to:

Code:
Plot0.Set(KAMA(Close,2,10,30)[0]-KAMA(Close,2,10,30)[3]);
Saved, recompiled, opened a new chart, but nothing showed up in the seperate plot anymore, just the scale from 0 to 1. When I opened the data window no values were displayed for Plot1.

Can somebody help me out with this?

Thank you in advance, kindest regards,

nescio
nescio is offline  
Reply With Quote
Old 05-13-2009, 03:09 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 25,432
Thanks: 417
Thanked 1,598 times in 1,563 posts
Default

Welcome to the support forums at NinjaTrader - please check this tip here -> http://www.ninjatrader-support2.com/...ead.php?t=3170 Most likely you run into this...
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 05-13-2009, 03:19 AM   #3
nescio
Junior Member
 
Join Date: Feb 2009
Posts: 13
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks for your really quick answer. I helped, but now my indicator looks weired as you can see in the screenshot. Any idea?

I changed the code to:
Code:
            if (CurrentBar < 3) 
            {
                return;
            }
            if (Close[0] > Close[1]) 
            {
                Plot0.Set(KAMA(Close,2,10,30)[0]-KAMA(Close,2,10,30)[3]);
            }
Attached Images
File Type: gif KAMAdiffindicator.png (40.9 KB, 40 views)
nescio is offline  
Reply With Quote
Old 05-13-2009, 03:29 AM   #4
nescio
Junior Member
 
Join Date: Feb 2009
Posts: 13
Thanks: 0
Thanked 0 times in 0 posts
Default

Found the problem myself. Used the wrong if clause from copy and pasting from the code you provided. Thank you for your quick support!
nescio is offline  
Reply With Quote
Old 05-13-2009, 03:35 AM   #5
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 25,432
Thanks: 417
Thanked 1,598 times in 1,563 posts
Default

You're welcome, great you got it resolved!
NinjaTrader_Bertrand 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
KAMA coding error? higler Indicator Development 14 07-13-2009 02:57 PM
Converting KAMA to operate on other than close BurtOD Indicator Development 2 02-26-2009 04:51 PM
Tip: How to make NinjaTrader’s ROC indicator to calculate the difference in points? KamaCoder Eric Indicator Development 0 05-17-2008 09:03 AM
What is the difference between indicator and strategy? clearpicks Indicator Development 1 04-21-2008 09:51 AM
Difference between strategy and indicator JangoFolly Automated Trading 3 05-16-2007 09:47 AM


All times are GMT -6. The time now is 03:36 PM.

FULL RISK DISCLOSURE: Futures trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.