View Full Version : Tick Counter 2 Alert
cclsys
02-09-2009, 09:30 AM
Hi. I am incredibly dense with Ninja script.
To my great surprise I managed to paste in an alert command into the Tick Counter 1 last week. It worked!! Now I still couldn't figure out how to get the number of ticks left that trigger the alarm into a menu panel so that you can change it in the Indicator menu when you change tick charts or markets, but at least it worked.
So I tried pasting in the same code into the TickCounter2 but it just won't compile and I have no idea what to do having played around with various things.
I wonder if anyone would like to take a crack at it?
My insert into TickCounter1 (which I copied in from someone else's code for something else) was:
// Plot the tick count message to the lower right hand corner of the chart
if (Bars.Period.Id == PeriodType.Tick)
{
double tickCount = ShowPercent ? CountDown ? (1 - Bars.PercentComplete) * 100 : Bars.PercentComplete * 100 : CountDown ? Bars.Period.Value - Bars.TickCount : Bars.TickCount;
graphics.DrawString((CountDown ? " Ticks remaining = " + tickCount : "Tick count = " + tickCount) + (ShowPercent ? "%" : ""), ChartControl.Font, textBrush, bounds.X + bounds.Width - textWidth, bounds.Y + bounds.Height - textHeight, stringFormat);
// Generates an alert
if (tickCount<=5)
{Alert("TickBarAlert", NinjaTrader.Cbi.Priority.High, "Tick Bar End", "Alert1.wav", 2, Color.Black, Color.Yellow);
}
The part that I inserted begins with // Generates an alert ...... ends with that last }.
But it won't go into the TickCounter2 code which is somewhat different because of all the nifty new things that have been added to it.
Thxs.
Ash.
NinjaTrader_Josh
02-09-2009, 09:46 AM
Ash,
I am not sure what TickCounter2 is. It sounds like a 3rd party custom indicator. You may want to try and contact the original author of it to see if there are any caveats you should be aware of and guidance in general with their script.
cclsys
02-09-2009, 10:20 AM
TickCounter is the indicator that comes with Ninja. TickCounter2 is a new version recently put out by MJT and now available in the File Sharing area at
http://www.ninjatrader-support2.com/vb/local_links.php?catid=1&sort=N&pp=15&page=10
The indicator link for download is:
http://www.ninjatrader-support2.com/vb/local_links.php?action=jump&id=170&catid=1
It is not a 3rd Party Custom Indicator as far as I understand it although in going back to the page I now realise that it looks like you guys did not put it out officially to replace the first one that comes with the program.
NinjaTrader_Josh
02-09-2009, 10:29 AM
cclsys,
Anything created by a community member and posted to the file sharing section is a 3rd party indicator. You will need to contact the original author for support on this.
cclsys
02-09-2009, 11:10 AM
Josh, I haven't come on the forum much because I am no good at Ninja coding (obviously). But do I understand from your reply that the forum is not a place for people to work on little problems like this? I figured that somebody might like to do this simple thing (for those that know how). All I'm talking about is adding an alert line to the code that's already out there. It's not exactly 'support for a third party indicator'.
cclsys
02-09-2009, 11:15 AM
How about if I do it this way?:
I have some code here that works as part of an Indicator that counts the ticks remaining in a tick chart bar.
// calculate the tick count value
double tickCount = ShowPercent ? CountDown ? (int)((1 - Bars.PercentComplete) * 100) : (int)(Bars.PercentComplete * 100) : CountDown ? Bars.Period.Value - Bars.TickCount : Bars.TickCount;
// Generates an alert
///if (tickCount <= 5)
/// {Alert("TickBarAlert", NinjaTrader.Cbi.Priority.High, "Tick Bar End", "Alert1.wav", 2, Color.Black, Color.Yellow;)}
In the last three lines beginning // Generates and alert ...... down to Color.Yellow;) }
I tried to add in an alert but it just won't 'take' even though the same lines worked fine in another code. I suspect it has something to do with the word 'tickCount' but just can't figure it out.
Can anyone help me with this so I can get an alert to work in there?
The full code is linked in a couple of posts earlier for anyone who wants/needs to look at the whole thing.
NinjaTrader_Josh
02-09-2009, 11:25 AM
cclsys,
The forums is a place to ask questions, but when you are trying to modify someone elses script there is no way we can offer you support in this regard. We just don't have the bandwidth to be going through every forum member's code and figuring out how it works to be able to assist in modifications to their indicators. You would need to ask the original author. Thank you for understanding.
cclsys
02-09-2009, 11:27 AM
So I gather from your answer then that you cannot use the forum for getting help with coding problems? I can understand if you have a company policy at Ninja not to help people but does that go for everyone in the Ninja community as well?
Frankly, I don't understand. Why call it a 'support forum' when support is disallowed and the forum is not used for people to pool ideas and resources as a 'forum' literally is supposed to do. Strange approach.
But if that's the way it is, so be it.
NinjaTrader_Josh
02-09-2009, 11:32 AM
As mentioned, we can help with coding problems. You are asking for help on how to modify another persons indicator. I cannot assist you in modifying other people's code. We do not have the bandwidth to assess what other people are doing in their code and as such are not qualified to answer any questions regarding their 3rd party code. You need to contact the original author for how their code works.
cclsys
02-09-2009, 11:36 AM
cclsys,
The forums is a place to ask questions, but when you are trying to modify someone elses script there is no way we can offer you support in this regard. We just don't have the bandwidth to be going through every forum member's code and figuring out how it works to be able to assist in modifications to their indicators. You would need to ask the original author. Thank you for understanding.
I was replying whilst you were posting this which is confusing so I put this last one in quotes above.
Frankly, I don't really understand.
First, it is not really so much 'modifying somebody else's script' as trying to learn how to put in an alert. I pasted in the snippet from the help menu and it worked in one code, but now I can't get it to work. Mystery.
Second, I understand that Ninja staff can't help with putting in an alert code if that is your policy for some reason, but it seems you feel your job is to reply to every post saying 'we can't help'.
My point is: maybe other members of the forum who are NOT Ninja employees would like to take a crack at this, in which case you don't have to keep replying saying 'we don't help with this.' Just say nothing and let the thread maybe solve the problem or not.
Unless your reply is also saying: 'we do not want anyone asking questions about coding on this 'Ninja Support Forum'' because of bandwidth.
Is that really how you want the forum to be? If you do, of course I can accept that, but I do feel that it is unnecessarily restrictive in that it hinders people learning more skills in relation to your platform thereby making it more popular.
But if you insist that people can't use the forum as a resource to work with coding issues, especially given how hard Ninja is to work with for those new to it, as I said before:
so be it!
For some reason it has taken me a while to figure out that you shouldn't think of the Ninja Forum as a place to work on coding problems.
NinjaTrader_Josh
02-09-2009, 11:48 AM
cclsys,
You copied code to our system indicator. It worked. If it didn't work we could assist because we know what variables and how things work in the system indicator. You try and copy it to another person's code. It doesn't work. I do not have the bandwidth to be opening everyone's code and analyzing it to figure out why it doesn't work for you. If it doesn't work there could be a whole host of reasons as to why it didn't work, all of which stem from the author's modifications. I do not know what the author modified and as such am not qualified to answer your questions. You need to contact the original author. You need to outline what you are trying to achieve and ask the author as to where in their code is the most appropriate place to insert such changes. NT support staff cannot evaluate these situations for you.
When I say we do not have the bandwidth it means support staff cannot assist you in trying to comprehend another member's code. By no means does this mean other forum members cannot assist you.
cclsys,
If you copy your alert code from your first post, and insert it after line 112, it should work OK. That places your new code immediately after the tick count is performed.
cclsys
02-09-2009, 12:22 PM
MJT. Thanks for yr reply and msg.
That's exactly where I have it and it doesn't work, hence why I am mystified.
Here is the section with my insert:
// calculate the tick count value
double tickCount = ShowPercent ? CountDown ? (int)((1 - Bars.PercentComplete) * 100) : (int)(Bars.PercentComplete * 100) : CountDown ? Bars.Period.Value - Bars.TickCount : Bars.TickCount;
/// Generates an alert
/// if (tickCount <= 5)
/// {Alert("TickBarAlert", NinjaTrader.Cbi.Priority.High, "Tick Bar End", "Alert1.wav", 2, Color.Black, Color.Yellow;)}
// draw the text
I included down to the last line 'draw the text' above so you can see where mine ends.
Now it looks to me like 'tickCount' is the variable/double so if you say 'if tickCount < 5, alert etc.' it should work. But for some reason it doesn't. It is looking for a ) and a 'statement' in line 114; I had put it all on one line so moved it back to how it is above:
I also note that if I make it all into one line or move the last bracket down one line to line up with the first one that there are different error messages even though the code is the same. Tricky lingo eh?!
NinjaTrader_Josh
02-09-2009, 12:46 PM
/// if (tickCount <= 5)
/// {Alert("TickBarAlert", NinjaTrader.Cbi.Priority.High, "Tick Bar End", "Alert1.wav", 2, Color.Black, Color.Yellow;)}
You have the lines commented out.
cclsys
02-09-2009, 12:55 PM
Josh wrote:
"When I say we do not have the bandwidth it means support staff cannot assist you in trying to comprehend another member's code. By no means does this mean other forum members cannot assist you."
OK, but from your initial replies it appeared to me that you were also saying:
'you are at the wrong place; this is not a place to work with coding issues'.
Now I understand that Ninja staff cannot get involved with coding they have not written themselves but that other people on the forum are welcome to share ideas and coding problems even if you cannot get involved because of company policy.
I think part of the reason this is so hard for me to understand is the same problem I have with these little coding issues (I am never going to try anything complicated like writing a real system or anything, not in this language which is beyond me!) in that I learned system coding on Tradestation and it has taken me a while to realise how totally different Ninja script environment is and that any little phrase you use is far more dependent on many of the other routines and Wizards all over the place elsewhere in the code rather than having more standalone linquistic procedures. This is not a criticism. It's just hard for someone 'raised' in a totally different environment to understand the nature of the problem.
For example, you would think it would not be hard to code in a simple paintbar that changes color when it is an inside bar. Took me forever yesterday, whereas in Tradestation I could write that out in 15 seconds tops and be done with it. I never did figure out how to make it so that I can get the color to change in the panel, I have to do it in the code only.
In this case, because I recently bought a strategy that I might use as an auto-trading platform on Ninja, that strategy when applied prints out blurb on the bottom right of the screen which is where I had the TickCount indicator. I had added an alert for manual trading and found it very helpful. So when the new addition came out with the ability to move the location of the text (very helpful in my case with the strategy blurb problem) I was just trying to get the alert to work with the new version as well. As usual, what I thought was a simple thing has taken many hours, thus far without success. It's not a big deal since really the only reason I like this is a) for manual trading and b) so that I don't have to change the templates or select different panels etc. when I switch workspaces, strategy-trading versus manual trading etc. A small convenience. And should be a simple affair.
But it isn't. And I guess that's how it goes when you don't know a programming language and support is not allowed. Learning is almost non-existent. The good news for me is that once I get this done, I will once again vanish from Ninja script for a while since the learning curve is so abysmal - at least in my case!
All best Josh, Ash.
cclsys
02-09-2009, 03:08 PM
Josh wrote:
"You have the lines commented out."
I am pretty dim, but when I try to compile I take out the /// marks. The reaso they are there is because it won't compile with those lines in so I have taken them out but post them here that way to show the code as is.
Which doesn't work.
And which you are not allowed to help with for reasons of company policy.
cclsys,
I cannot see any reason why it won't work.
I have pasted in your code from 1st post and it works fine, so probably you have accidentally removed (or added) something else along the way. One thing is for sure, the indicator only does what the code tells it to.
Of no great importance, but you don't need the curly braces either side of the Alert(.....) method. They don't cause any problem either.
I have renamed it TickConter2a in case you want to import it and compare.
There is one other change made, that had nothing to do with the Alert() - I had to rename DisplayLocation to DisplayLocationA as we can't have the name twice in different indicators.
cclsys
02-10-2009, 05:42 AM
MJT, well I cannot see what happened that it now DOES work, but I am grateful to you for changing it.
Next time I try something like this I will first:
work on a copy of the original instead of the original so that then:
I can go back to the original to double-check when things don't work right.
I still don't understand what happened, though, since when I hashed out my 3 little lines it worked fine, but when I tried to insert them it didn't.
Anyway, thanks a lot! Now I have both a sound and also I can move the text away from the strategy blurb that comes up along the bottom when running a strategy.
Mindset
07-23-2009, 09:21 AM
cclsys
I understand your frustration with attempts at getting "support".
NT is a relatively young company with limited staff resources and as it matures I think you will find it is the community members that do most of the assisting with code issues - leaving support for the bigger issues.
As a relative newbie myself I also find it very frustrating that even after reading books about C#, revising the msdn site,etc there are just adaptations to Ninja Script that you can't learn without being shown. A full reference bible would be a start!
The F1 help is really quite basic.
Hopefully some of this will be sorted in v7.
mktucker
07-27-2011, 02:10 PM
I just installed this tick alert and it seems to be working but how do I change when it alerts. It seems to be alerting when the count is to 0 and I would like to be alerted when it is at lets say 200 ticks left. I went in and changed it to 200 but it still rings at 0. COuld you help me with this?
if (tickCount<=200)
{ Alert("TickBarAlert", NinjaTrader.Cbi.Priority.High, "Tick Bar End", "Alert1.wav", 5, Color.Black, Color.Yellow);
}
Thanks
cclsys
07-28-2011, 07:15 AM
I put it into NT7 and it works as soon as the threshold is met. (I was using 50). And then a couple of times before the next bar forms at which point it is silent again. So I have no idea why it isn't working for you.
Frankly, I don't like the feature but if using large tick bars which take several minutes, I guess it's pretty handy. To be more universal, might be better to configure it to sound once when there is x% of the bar remaining. Anyway, sorry I can't help.
dawntrader
09-01-2011, 08:03 PM
I'd like a tick countdown that is shown right next to the price bar and MOVES with the price (to add an element of visualization on where price is at). On a tick chart, the counter would count down, but on any other chart, like a range/minute, the counter would just simply count up to whatever.
If on a tick chart, say a 377, the counter would start at 377, and count down until the new bar is formed. This would be visible right NEXT to the current price bar and MOVE with the price adjustment.
Is there anything like this? Not like the internal indicator which just sits on the bottom of the price panel and offers no visible clue as to the movement of the price while showing the TICKS REMAINING.
Thank you.
NinjaTrader_RyanM
09-01-2011, 08:35 PM
Hi dawntrader,
Welcome to the NinjaTrader forums. I'm not aware of an indicator that works exactly like this.You may consider explaining your requirements to one of our 3rd party NinjaScript consultants, who can be hired to custom code this.
http://www.ninjatrader.com/partners#NinjaScript-Consultants
dawntrader,
TickCounter2 does what you decribed on a tick chart. It will not work on any other bar type. It was created in the days of Ninja 6.5, but I have just downloaded it into version 7 and it appears to work OK. Download here:'
http://www.ninjatrader.com/support/forum/local_links.php?action=ratelink&linkid=170&catid=1&lpage=15
To get the counter to follow the price, you have to select "float with price". Also make sure there is enough space to the right for the text to show.