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 06-01-2009, 11:28 AM   #1
dirtybrown
Junior Member
 
Join Date: Jan 2008
Posts: 19
Thanks: 0
Thanked 0 times in 0 posts
Default resetting indicators

Hi. I am still new to Ninjatrader development. The functionality of the attached indicator is to simply print arrows based on the number of variables that occur within a certain number of seconds. They are datetimes. I manually set their values because this is just one small piece of a bigger puzzle I don't have access to so that's why I am manually setting them for now:

protected override void Initialize()
{
CalculateOnBarClose = true;
Overlay = true;
DateTime Now = System.DateTime.Now;
SpanThreshold = SpanThreshold.AddMilliseconds(-100000);

UpTriangleTime=UpTriangleTime.AddMilliseconds(-100009);
DownTriangleTime=DownTriangleTime.AddMilliseconds( 7);

lastdowncarattime=lastdowncarattime.AddMillisecond s(5);
lastupcarattime=lastupcarattime.AddMilliseconds(-100009);

pricebelowbluetime=pricebelowbluetime.AddMilliseco nds(-100009);
priceabovebluetime=priceabovebluetime.AddMilliseco nds(5);

lastupdottime=lastupcarattime.AddMilliseconds(-100009);
lastdowndottime=lastdowncarattime.AddMilliseconds( 777);

yelbelowbluetime=yelbelowbluetime.AddMilliseconds(-100009);
yelabovebluetime=yelabovebluetime.AddMilliseconds( 1);

}

but the indicator repaints on every bar, is there code in the wrong place?
Attached Files
File Type: zip FuzzifiedSignals.zip (2.4 KB, 3 views)
dirtybrown is offline  
Reply With Quote
Old 06-01-2009, 11:38 AM   #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

dirtybrown,

You should not place things in the Initialize() method like that. If you want something only run once please use if (CurrentBar == 0 && FirstTickOfBar) at the beginning of OnBarUpdate().
NinjaTrader_Josh is offline  
Reply With Quote
Old 06-01-2009, 12:19 PM   #3
dirtybrown
Junior Member
 
Join Date: Jan 2008
Posts: 19
Thanks: 0
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by NinjaTrader_Josh View Post
dirtybrown,

You should not place things in the Initialize() method like that. If you want something only run once please use if (CurrentBar == 0 && FirstTickOfBar) at the beginning of OnBarUpdate().
hmm, Ok I initialized the variables like this:

if (CurrentBar == 0 && FirstTickOfBar) {


DateTime Now = System.DateTime.Now;
SpanThreshold = SpanThreshold.AddMilliseconds(-100000);

UpTriangleTime=UpTriangleTime.AddMilliseconds(-100009);
DownTriangleTime=DownTriangleTime.AddMilliseconds( 7);

lastdowncarattime=lastdowncarattime.AddMillisecond s(5);
lastupcarattime=lastupcarattime.AddMilliseconds(-100009);

pricebelowbluetime=pricebelowbluetime.AddMilliseco nds(-100009);
priceabovebluetime=priceabovebluetime.AddMilliseco nds(5);

lastupdottime=lastupcarattime.AddMilliseconds(-100009);
lastdowndottime=lastdowncarattime.AddMilliseconds( 777);

yelbelowbluetime=yelbelowbluetime.AddMilliseconds(-100009);
yelabovebluetime=yelabovebluetime.AddMilliseconds( 1);
return;

}

but still getting the repaints
Attached Files
File Type: zip FuzzifiedSignals.zip (2.4 KB, 4 views)
dirtybrown is offline  
Reply With Quote
Old 06-01-2009, 12:34 PM   #4
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

Please describe what you mean by repaints. Your draw objects are given unique names so your indicator will keep adding more and more objects.
NinjaTrader_Josh is offline  
Reply With Quote
Old 06-01-2009, 12:38 PM   #5
dirtybrown
Junior Member
 
Join Date: Jan 2008
Posts: 19
Thanks: 0
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by NinjaTrader_Josh View Post
Please describe what you mean by repaints. Your draw objects are given unique names so your indicator will keep adding more and more objects.
I'm running this on a 1 tick chart with a straight line printing instead of candlestick. When the new tick comes though, the indicator reprints itself on the at the top (or bottom) of the previous tick. See attachment
Attached Images
File Type: png 2.PNG (5.2 KB, 16 views)
File Type: png 1.PNG (4.0 KB, 9 views)
dirtybrown is offline  
Reply With Quote
Old 06-01-2009, 01:47 PM   #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

You should not give each tick a new unique name for the object. You should only give it unique names as per bar.
NinjaTrader_Josh is offline  
Reply With Quote
Old 06-01-2009, 01:49 PM   #7
dirtybrown
Junior Member
 
Join Date: Jan 2008
Posts: 19
Thanks: 0
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by NinjaTrader_Josh View Post
You should not give each tick a new unique name for the object. You should only give it unique names as per bar.
I thought about that and tried drawing like this:

DrawArrowUp("up1", 0, Low[0] - x, Color.Green);

Doesn't seem to make a different for me at least. Is there another way I should be naming it?
dirtybrown is offline  
Reply With Quote
Old 06-01-2009, 01:53 PM   #8
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 I follow. When you use a static name any future calls to that same signal name will modify the old object instead of drawing a new object. If you have additional objects with other names then those will be shown as well.
NinjaTrader_Josh is offline  
Reply With Quote
Old 06-01-2009, 02:04 PM   #9
dirtybrown
Junior Member
 
Join Date: Jan 2008
Posts: 19
Thanks: 0
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by NinjaTrader_Josh View Post
Not sure I follow. When you use a static name any future calls to that same signal name will modify the old object instead of drawing a new object. If you have additional objects with other names then those will be shown as well.
I only want the arrow to print when the conditions given are true. I tried to give it a dynamic name like this:


/DrawArrowUp("t"+ CurrentBar.ToString(), 0, Low[0] - x, Color.Green);

and the same thing happens, the previous print of the indicator disappears and it's redrawn on a new tick.

I think maybe I need to move the for loop to a lower scope
dirtybrown is offline  
Reply With Quote
Old 06-01-2009, 02:06 PM   #10
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

If you are using loops it could be the cause of redrawing itself. If you want the objects to "disappear" please use RemoveDrawObject().
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
Resetting account performance ? T2020 Miscellaneous Support 2 09-08-2008 07:25 AM
Data values resetting Burga1 Indicator Development 5 05-23-2008 03:25 PM
Resetting SIM trades gygraham Strategy Analyzer 1 04-14-2008 07:01 PM
resetting Sim101 account Oli Miscellaneous Support 2 02-27-2007 04:03 AM
chart resetting question Lupus Charting 1 03-28-2006 08:50 AM


All times are GMT -6. The time now is 01:14 PM.