![]() |
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
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Jan 2008
Posts: 19
Thanks: 0
Thanked 0 times in 0 posts
|
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? |
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
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().
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#3 | |
|
Junior Member
Join Date: Jan 2008
Posts: 19
Thanks: 0
Thanked 0 times in 0 posts
|
Quote:
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 |
|
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
Please describe what you mean by repaints. Your draw objects are given unique names so your indicator will keep adding more and more objects.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Jan 2008
Posts: 19
Thanks: 0
Thanked 0 times in 0 posts
|
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
|
|
|
|
|
|
#6 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
You should not give each tick a new unique name for the object. You should only give it unique names as per bar.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#7 | |
|
Junior Member
Join Date: Jan 2008
Posts: 19
Thanks: 0
Thanked 0 times in 0 posts
|
Quote:
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? |
|
|
|
|
|
|
#8 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
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.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#9 | |
|
Junior Member
Join Date: Jan 2008
Posts: 19
Thanks: 0
Thanked 0 times in 0 posts
|
Quote:
/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 |
|
|
|
|
|
|
#10 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
If you are using loops it could be the cause of redrawing itself. If you want the objects to "disappear" please use RemoveDrawObject().
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |