Suggestions?
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Alerts on COBC=false
Collapse
X
-
Hello cachevery,
I have created a sample indicator for you using the parts of the snippets you have provided along with some of the other posts in this thread.
Rather than using the PlaySound I have used Alert. The reason for this is because Alert already includes a timer method that allows you to specify the frequency at which you will be alerted. Using this will require less logic to get it to do what you want.
As i said i want both COBC =tru/false to behave equally.But when i set COBC = false itt`s firing alrets every second.I wnan the alers to go off intra-bar and on the bar close,depending on what i need.
In order to make COBC behave equally but also not alert you on every bar I have chosen to Alert()
You do not need the alert window open for Alert to work.
Please let me know if I may be of further assistance.Attached FilesJesseNinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_Jesse View PostHello cachevery,
I have created a sample indicator for you using the parts of the snippets you have provided along with some of the other posts in this thread.
Rather than using the PlaySound I have used Alert. The reason for this is because Alert already includes a timer method that allows you to specify the frequency at which you will be alerted. Using this will require less logic to get it to do what you want.
To make the code behave equally I have used a function because the logic is the same if COBC = true or false.
In order to make COBC behave equally but also not alert you on every bar I have chosen to Alert()
You do not need the alert window open for Alert to work.
Please let me know if I may be of further assistance.
Hi Jess,what do i do with it?Should i put the original indicator alongside with the sample you`ve provided?
Comment
-
Hello cachevery,
I just included the indicator for you to import into your NinjaTrader to take a look at how I have laid the code out in an indicator. to Import it you would use the File -> Utilities -> Import Ninjascript tool from the NinjaTrader control center window.
If you would like you can put your code inside the sections of the indicator I had attached and give it a try. You could also use the code I had attached inside your own indicator filling in your code where you need it to be.
It is simply a reference on how I had interpreted what you were asking for.
Please let me know if I may be of further assistance.JesseNinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_Jesse View PostHello cachevery,
I just included the indicator for you to import into your NinjaTrader to take a look at how I have laid the code out in an indicator. to Import it you would use the File -> Utilities -> Import Ninjascript tool from the NinjaTrader control center window.
If you would like you can put your code inside the sections of the indicator I had attached and give it a try. You could also use the code I had attached inside your own indicator filling in your code where you need it to be.
It is simply a reference on how I had interpreted what you were asking for.
Please let me know if I may be of further assistance.
I tried tu put it inside,but i get constant errors.I have a complicated code.Probably it`s more then just re-arm function or something to it.
Comment
-
Hello cachevery,
Yes if you are just copying your whole code into the code I provided you will most likely get errors.
I would recommend just using what I had provided as a reference on a possible way you could accomplish what you are trying to do.
I had recommended the Alert() method as it has a timeout so you don’t have the sound go off every bar but rather every so many seconds. You could set this to a high value if you only want to be alerted once.
The rest of the code was just a reference on how to check the conditions and apply logic surrounding how you had specified you wanted to be alerted.
Please let me know if I may be of further assistance.JesseNinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_Jesse View PostHello cachevery,
Yes if you are just copying your whole code into the code I provided you will most likely get errors.
I would recommend just using what I had provided as a reference on a possible way you could accomplish what you are trying to do.
I had recommended the Alert() method as it has a timeout so you don’t have the sound go off every bar but rather every so many seconds. You could set this to a high value if you only want to be alerted once.
The rest of the code was just a reference on how to check the conditions and apply logic surrounding how you had specified you wanted to be alerted.
Please let me know if I may be of further assistance.
if (soundAlert != "") {
Alert ("SoundAlert", NinjaTrader.Cbi.Priority.High, WhereWasThisCalledFrom, soundAlert, alertTimeout, Color.Black, Color.Yellow);
Comment
-
Hello cachevery,
You are correct, if you copied that directly into your code that would not work. This is because I used 2 variables that are in the indicator I had attached.
Please note this is what you copied
Code:Alert ("SoundAlert", NinjaTrader.Cbi.Priority.High, [B]WhereWasThisCalledFrom[/B], soundAlert, [B]alertTimeout[/B], Color.Black, Color.Yellow);
The first: WhereWasThisCalledFrom This is a string value that would be the text in the alert window, you can replace this with a blank string if you are not going to use the alert window.
The second alertTimeout This needs to be a integer value, 10 would equal 10 seconds for the timeout.
The completed code for Alert would be as follows
Code:Alert ("SoundAlert", NinjaTrader.Cbi.Priority.High, "", soundAlert, 5, Color.Black, Color.Yellow);
I would recommend taking a look in the help guide on any of the items you are unsure on because most everything has a working generic code example you can copy directly into your script.JesseNinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_Jesse View PostHello cachevery,
You are correct, if you copied that directly into your code that would not work. This is because I used 2 variables that are in the indicator I had attached.
Please note this is what you copied
Code:Alert ("SoundAlert", NinjaTrader.Cbi.Priority.High, [B]WhereWasThisCalledFrom[/B], soundAlert, [B]alertTimeout[/B], Color.Black, Color.Yellow);
The first: WhereWasThisCalledFrom This is a string value that would be the text in the alert window, you can replace this with a blank string if you are not going to use the alert window.
The second alertTimeout This needs to be a integer value, 10 would equal 10 seconds for the timeout.
The completed code for Alert would be as follows
Code:Alert ("SoundAlert", NinjaTrader.Cbi.Priority.High, "", soundAlert, 5, Color.Black, Color.Yellow);
I would recommend taking a look in the help guide on any of the items you are unsure on because most everything has a working generic code example you can copy directly into your script.
Comment
-
Hello cachevery,
I am not sure where you are running into an issue using the previous code.
If it is silent this could be a couple of things,
If COBC is set to true then you would need to wait for the bar to close then if your conditions are met it would be called.
If COBC is false then it should happen as your conditions are met.
Also because you are specifying a different sound file than the example has please make sure it is the correct format and make sure the name is exactly the same in the code as it is on the file. If this is the case please refer to this line of the documentation
soundLocation
File name of .wav file to play. Provide either the absolute file path or just the name if the file is located in C:\Program Files\NinjaTrader Installation Folder\sounds folder
When you run it, it will wait for the bar to close (COBC = true) it will alert you once then wait 10 seconds then alert you again.
This is the example from the help guide. This uses the default Alert1.wav that comes with ninjatrader, Alerts using sound every 10 seconds.
Code:Alert("myAlert", NinjaTrader.Cbi.Priority.High, "Reached threshold", "Alert1.wav", 10, Color.Black, Color.Yellow);
JesseNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by mattbsea, Today, 05:44 PM
|
0 responses
2 views
0 likes
|
Last Post
by mattbsea
Today, 05:44 PM
|
||
Started by RideMe, 04-07-2024, 04:54 PM
|
6 responses
31 views
0 likes
|
Last Post
by RideMe
Today, 05:31 PM
|
||
Started by tkaboris, Today, 05:13 PM
|
0 responses
2 views
0 likes
|
Last Post
by tkaboris
Today, 05:13 PM
|
||
Started by GussJ, 03-04-2020, 03:11 PM
|
16 responses
3,282 views
0 likes
|
Last Post
by Leafcutter
Today, 04:14 PM
|
||
Started by WHICKED, Today, 12:45 PM
|
2 responses
20 views
0 likes
|
Last Post
by WHICKED
Today, 03:36 PM
|
Comment