NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


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-07-2011, 08:29 PM   #1
JimPunkrockford
Junior Member
 
Join Date: May 2010
Posts: 24
Thanks: 3
Thanked 0 times in 0 posts
Default is EMA+/-(2*ATR) indicator on indicator?

i did the indicator on indicator tutorial and still can't get it to work. i do have it in strategy as

{
DrawLine("My line2" + CurrentBar, 1, EMA(21)[1] + (ATR(14)[1]) * (1 + 1), 0, EMA(21)[0] + (ATR(14)[0]) * (1 + 1), Color.Red);

DrawLine("My line" + CurrentBar, 1, EMA(21)[1] + (ATR(14)[1]) * (1 + -3), 0, EMA(21)[0] + (ATR(14)[0]) * (1 + -3), Color.Green);
}

i'd love to turn this into a indicator, but i can't seem to get it to work.
JimPunkrockford is offline  
Reply With Quote
Old 10-08-2011, 09:11 AM   #2
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,218
Thanks: 24
Thanked 1,231 times in 1,002 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by JimPunkrockford View Post
i did the indicator on indicator tutorial and still can't get it to work. i do have it in strategy as

{
DrawLine("My line2" + CurrentBar, 1, EMA(21)[1] + (ATR(14)[1]) * (1 + 1), 0, EMA(21)[0] + (ATR(14)[0]) * (1 + 1), Color.Red);

DrawLine("My line" + CurrentBar, 1, EMA(21)[1] + (ATR(14)[1]) * (1 + -3), 0, EMA(21)[0] + (ATR(14)[0]) * (1 + -3), Color.Green);
}

i'd love to turn this into a indicator, but i can't seem to get it to work.
What error is in the log?
koganam is online now  
Reply With Quote
Old 10-08-2011, 01:24 PM   #3
JimPunkrockford
Junior Member
 
Join Date: May 2010
Posts: 24
Thanks: 3
Thanked 0 times in 0 posts
Default

well if i just cut/paste from strategy to an indicator i get this


JimPunkrockford is offline  
Reply With Quote
Old 10-08-2011, 08:31 PM   #4
JimPunkrockford
Junior Member
 
Join Date: May 2010
Posts: 24
Thanks: 3
Thanked 0 times in 0 posts
Default

actually i get these errors if i try anything. if i edit a NT indicator and change the name and hit "compile" i get these same error messages. so clearly i have something larger going on here.
JimPunkrockford is offline  
Reply With Quote
Old 10-08-2011, 10:00 PM   #5
sledge
Senior Member
 
Join Date: Aug 2010
Location: Washington, D.C.
Posts: 1,187
Thanks: 178
Thanked 301 times in 259 posts
Default

Quote:
Originally Posted by JimPunkrockford View Post
actually i get these errors if i try anything. if i edit a NT indicator and change the name and hit "compile" i get these same error messages. so clearly i have something larger going on here.
?????

I edit ADL, changed the name to A2DL (got warning "you can not save system indicators", ) and it compiled.

[Description("The Accumulation/Distribution (AD) study attempts to quantify the amount of volume flowing into or out of an instrument by identifying the position of the close of the period in relation to that period�s high/low range.")]
public class A2DL : Indicator
{

I created a new indicator, cut and pasted ADX into it, compiled as "MyCustomIndicator", OK, changed named to "MyCustomIndicator2", and that was fine too.

market with low volumes whereas a cross above 20 may indicate the start of a trend (either up or down). If the ADX is over 40 and begins to fall, it can indicate the slowdown of a current trend.")]
public class MyCustomIndicator2 : Indicator
{
#region Variables


Please provide more detailed steps?

I'm assuming latest NT7? I'm on 32bit.
sledge is offline  
Reply With Quote
Old 10-08-2011, 10:14 PM   #6
JimPunkrockford
Junior Member
 
Join Date: May 2010
Posts: 24
Thanks: 3
Thanked 0 times in 0 posts
Default

NT 7.0.1000.6 32bit

i open up ADL do a "save as" change the name and hit "compile" and i get this error

No overload for method 'Set' takes '6' arguments

so not as many errors but still wont compile
JimPunkrockford is offline  
Reply With Quote
Old 10-08-2011, 10:24 PM   #7
sledge
Senior Member
 
Join Date: Aug 2010
Location: Washington, D.C.
Posts: 1,187
Thanks: 178
Thanked 301 times in 259 posts
Default

Quote:
Originally Posted by JimPunkrockford View Post
NT 7.0.1000.6 32bit

i open up ADL do a "save as" change the name and hit "compile" and i get this error

No overload for method 'Set' takes '6' arguments

so not as many errors but still wont compile
bizarre, 32 bit vista . 7.0.1000.7

I opened up ADL, right clicked in the code to "SAVE AS", changed to A2D, warned me about changing all occurrences of ADL (and it appeared to do it), and I hit the compile and it compiled. no errors.

I didn't look at the .7 log change to see if anything related to this was fixed/changed.


/// </summary>
[Description("The Accumulation/Distribution (AD) study attempts to quantify the amount of volume flowing into or out of an instrument by identifying the position of the close of the period in relation to that period�s high/low range.")]
public class a2d : Indicator
{
sledge is offline  
Reply With Quote
The following user says thank you to sledge for this post:
Old 10-08-2011, 10:28 PM   #8
JimPunkrockford
Junior Member
 
Join Date: May 2010
Posts: 24
Thanks: 3
Thanked 0 times in 0 posts
Default

well you did what i did, exactly. and i got the error. thanks a bunch for trying that out for me.
JimPunkrockford is offline  
Reply With Quote
Old 10-08-2011, 11:05 PM   #9
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,218
Thanks: 24
Thanked 1,231 times in 1,002 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by JimPunkrockford View Post
well you did what i did, exactly. and i got the error. thanks a bunch for trying that out for me.
You have multiple errors in what appear to be multiple files. The picture you posted, was a cut off of what you thought was important, and it did not show complete details that could help point you towards a resolution.

If I may make a suggestion: you might be better served if you would take things one step at a time, waiting for a response from those who are trying to help. I actually think that your first problem would have been resolved by now, if you had just responded to what was asked, instead of your trying new experiments. In this case, those new experiments may have introduced new nuances into what was originally a single problem.

I am not being snide: I really do want to help.
koganam is online now  
Reply With Quote
Old 10-08-2011, 11:17 PM   #10
JimPunkrockford
Junior Member
 
Join Date: May 2010
Posts: 24
Thanks: 3
Thanked 0 times in 0 posts
Default

ok here are more complete looking results here
is there something there that shows whats up[

and not to be snarky but my fiddling seems to have uncovered that i am having a more comprehensive problem and not a small programming problem
JimPunkrockford is offline  
Reply With Quote
Old 10-09-2011, 08:51 AM   #11
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,218
Thanks: 24
Thanked 1,231 times in 1,002 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by JimPunkrockford View Post
ok here are more complete looking results here
is there something there that shows whats up
That picture shows that you are editing MyCustomIndicator9, but your errors are all, so far in MyCustomIndicator, which I am going to presume is the first file that you wrote. Double-click on any of the errors, and the editor will open the defective file, at the the site of the error. We can then tackle the correct errant line.

Quote:
and not to be snarky but my fiddling seems to have uncovered that i am having a more comprehensive problem and not a small programming problem
That was not snarky, and your conclusion well may be, but in all cases where there is an error in the first file, any extra coding in new files represent new elements that have been introduced into the analysis of the problem.

In this case, it appears that it is possible that only the original problem still remains, but it appears to be showing up elsewhere. That is not really the case: NT compiles everything into one assembly, so any errors, no matter where they are, must be resolved before you can get a successful compilation. If you have one error, and you write new files, nothing will compile, and it is easy to think that you have multiple errors, when in fact, you still have the same one. OTOH, as all errors will prevent compilation, new files may have introduced new errors that are not yet showing.
koganam is online now  
Reply With Quote
Old 10-09-2011, 03:23 PM   #12
JimPunkrockford
Junior Member
 
Join Date: May 2010
Posts: 24
Thanks: 3
Thanked 0 times in 0 posts
Default

ok. so i deleted all of the files and started over. first i tried to cut/paste from my working strategy (as in my original post), with the command "draw line", it compiled but would not draw anything on the chart.

so next i tried to add "plots" in the indicator generator then paste my declarations and i get this error HERE and when i click on the error code the "plot" is highlighted

so if i understand the error code, i don't give enough info to plot my line, is that correct?
JimPunkrockford is offline  
Reply With Quote
Old 10-09-2011, 03:43 PM   #13
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,218
Thanks: 24
Thanked 1,231 times in 1,002 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by JimPunkrockford View Post
ok. so i deleted all of the files and started over. first i tried to cut/paste from my working strategy (as in my original post), with the command "draw line", it compiled but would not draw anything on the chart.

so next i tried to add "plots" in the indicator generator then paste my declarations and i get this error HERE and when i click on the error code the "plot" is highlighted

so if i understand the error code, i don't give enough info to plot my line, is that correct?
Plot() takes a single double as it parameter, so that line tells what the error is.

If you want to draw a line, then I go back to the very first question that I asked: "What error is in the log?"
koganam is online now  
Reply With Quote
Old 10-09-2011, 04:15 PM   #14
JimPunkrockford
Junior Member
 
Join Date: May 2010
Posts: 24
Thanks: 3
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by koganam View Post
Plot() takes a single double as it parameter, so that line tells what the error is.

If you want to draw a line, then I go back to the very first question that I asked: "What error is in the log?"

ah right, sorry, i didn't understand. HERE is the log file
JimPunkrockford is offline  
Reply With Quote
Old 10-09-2011, 05:10 PM   #15
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,218
Thanks: 24
Thanked 1,231 times in 1,002 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by JimPunkrockford View Post
ah right, sorry, i didn't understand. HERE is the log file
That tells us that on bar0, we are trying to access the bar just before it, which of course, does not exist. We shall dodge the problem by simply not processing the event until we have enough bars.

Try this. Place this line at the beginning of the OnBarUpdate() event handler.
Code:
if (CurrentBar < 1) return;
koganam is online now  
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
ATR indicator christof21 Indicator Development 3 04-25-2010 12:14 PM
building a new ATR indicator easypilot Indicator Development 1 06-20-2009 11:37 AM
Indicator for the SMA of the ATR pureporsche Indicator Development 3 02-08-2009 11:45 AM
ATR Indicator playafh69 Indicator Development 1 01-01-2009 10:28 PM
Simple ATR w/ EMA Indicator tmoose Indicator Development 1 10-15-2008 08:21 AM


All times are GMT -6. The time now is 10:20 AM.