Using Async Voice Synthesizer Alerts - NinjaTrader Programming | futures io social day trading
futures io futures trading


Using Async Voice Synthesizer Alerts
Updated: Views / Replies:1,641 / 11
Created: by vantojo Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Using Async Voice Synthesizer Alerts

  #1 (permalink)
Elite Member
Neuquen, Argentina
 
Futures Experience: Intermediate
Platform: Ninja
Favorite Futures: CL, TF, 6S, NG, sometimes GC
 
Posts: 195 since Jul 2012
Thanks: 25 given, 39 received

Using Async Voice Synthesizer Alerts

Hello,

I am starting to play around a little with synthetic voice alerts and found that the Speak method is synchronous and locks the execution thread while it is playing the voice. So, the Ninja script and the Ninja Chart Draw basically stop until the voice is played.

Also, in Synchronous mode, when lots of alerts come quickly, they are queued up and all NT tasks seem to lock up, even on a fast multi thread machine, until the voice synthesizer queue is emptied.

It appears that the Async mode solves this problem. Alerts are not queued and are allowed to speak over each other...which for me is better than queueing up 10 audio alerts in a fast market

You can try this out yourself with the following indicator...just alternately comment out the Speak and SpeakAsync lines....and then run it on a fast moving chart, with fast bars, such as say, a 2 range bar, to push lots of alerts quickly.

Here is some code to play with....

 
Code
                            
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Speech.Synthesis;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
#endregion

// NOTE:  Before this will compile successfully, you need to put the following in the References
// C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.Speech.dll
//
// to do this, 
// 1) open an Indicator in the Editor
// 2) right mouse click in the text area
// 3) click References
// 4) click Add
// 5) browse to the location above and add it to the NT References
// 

// this script is set up for Futures...for example
// for CME Gold, Instrument.MasterInstrument = "GC" 
// the substrings break this into "G C" so that each letter is spoken


namespace NinjaTrader.Indicator
{


    public class 
AAVoice Indicator
    
{
        
#region Variables
        
        
private SpeechSynthesizer voice
        
string    Words;
        
        
#endregion

        
protected override void Initialize()
        {
            
Overlay                false;
        }

    
        protected 
override void OnBarUpdate()
        {
            if (
Historical) return;
            
            
Words Instrument.MasterInstrument.Name.Substring(0,1) + 
                    
" " +
                    
Instrument.MasterInstrument.Name.Substring(1,1) + 
                    
" New Bar";
            
//            voice.Speak (Words);
            
voice.SpeakAsync (Words);
            
            Print (
"Speak ==> " Words);
        }

        
    protected 
override void OnStartUp()
        {
            
voice = new SpeechSynthesizer();
        }

        protected 
override void OnTermination()
        {
            
voice.Dispose();
        }


        
#region Properties
        #endregion
    
}



Last edited by sam028; August 8th, 2013 at 02:29 PM. Reason: add [php] tag, the code is then easier to see
Reply With Quote
The following 4 users say Thank You to vantojo for this post:
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
New York, NY
 
Futures Experience: Intermediate
Platform: NinjaTrader8
Broker/Data: Data = Rithmic -- Gives 70 Level II Data
Favorite Futures: 6C (Low Margin,) 6E, CL, GC, ES and Maybe DX for smaller tick value
 
Posts: 813 since May 2011
Thanks: 1,330 given, 531 received



vantojo View Post
Hello,

I am starting to play around a little with synthetic voice alerts and found that the Speak method is synchronous and locks the execution thread while it is playing the voice. So, the Ninja script and the Ninja Chart Draw basically stop until the voice is played.

Also, in Synchronous mode, when lots of alerts come quickly, they are queued up and all NT tasks seem to lock up, even on a fast multi thread machine, until the voice synthesizer queue is emptied.

It appears that the Async mode solves this problem. Alerts are not queued and are allowed to speak over each other...which for me is better than queuing up 10 audio alerts in a fast market

@vantojo, would the standard Ninja Trader indicator "Candle Stick Pattern" be a good candidate for synthesis? I use about 2 - 4 pairs of this indicator, Engulfing pairs, Morning Star/Evening Star and others. They do not signal that often and if you were to use a rearm function of perhaps 55 seconds I would think it should not disrupt processing much.

Any chance you would code this with alert stating "doji" type: Bearish Engulfing 6E 2 minute?

That would be awesome. I already have separate Engulfing indicator but it simply says engulfing. Hopefully you could provide at least a first pass at this?

Reply With Quote
 
  #4 (permalink)
Elite Member
Neuquen, Argentina
 
Futures Experience: Intermediate
Platform: Ninja
Favorite Futures: CL, TF, 6S, NG, sometimes GC
 
Posts: 195 since Jul 2012
Thanks: 25 given, 39 received

Hi,

I'm totally focused at the moment on a development project....perhaps another coder can help you? Integrating the voice is easy, as the code above shows...that is all you need to do.

Good luck!

Reply With Quote
 
  #5 (permalink)
Elite Member
New York, NY
 
Futures Experience: Intermediate
Platform: NinjaTrader8
Broker/Data: Data = Rithmic -- Gives 70 Level II Data
Favorite Futures: 6C (Low Margin,) 6E, CL, GC, ES and Maybe DX for smaller tick value
 
Posts: 813 since May 2011
Thanks: 1,330 given, 531 received


vantojo View Post
Hi,

I'm totally focused at the moment on a development project....perhaps another coder can help you? Integrating the voice is easy, as the code above shows...that is all you need to do.

Good luck!

vantojo, Can get it speak, but like Donkey in the movie Shrek, it won't shut up? It keeps repeating the Words instead of just speaking it once:

// voice.Speak (Words);

voice.SpeakAsync (Words);

Print ("Speak ==> " + Words);

//JMont1 End
patternsFound++;
Value.Set(1);
}
#endregion
break;


Any ideas?

Now looking at TrendLineTalkingAlert that has info similar to Tasker_182 logic.


Last edited by jmont1; September 8th, 2013 at 09:22 AM.
Reply With Quote
 
  #6 (permalink)
Elite Member
Cedar Rapids, iowa
 
Futures Experience: Intermediate
Platform: Ninjatrader
Broker/Data: Ninjatrader - Continuum
Favorite Futures: 6E, TF, 6J
 
Tasker_182's Avatar
 
Posts: 626 since Aug 2009
Thanks: 426 given, 1,126 received

You need a conditional statement that allows the voice alert once per bar, assuming you are COBC= false.

"Money is better than poverty, if only for financial reasons." - Woody Allen
Reply With Quote
 
  #7 (permalink)
Elite Member
New York, NY
 
Futures Experience: Intermediate
Platform: NinjaTrader8
Broker/Data: Data = Rithmic -- Gives 70 Level II Data
Favorite Futures: 6C (Low Margin,) 6E, CL, GC, ES and Maybe DX for smaller tick value
 
Posts: 813 since May 2011
Thanks: 1,330 given, 531 received

Quiet Down Boyo


Tasker_182 View Post
You need a conditional statement that allows the voice alert once per bar, assuming you are COBC= false.

@Tasker_182, Yes, I am tryinng to use COBC = false. The same thing happens to the sample text in post #1 if COBC=False is used.

Any idea what type of statement would apply to have that happen? I tried looking at the "Rearm" statement used for Alerts but it does not look like it applies. I was thinking there might be a "Stop" type statement for voice.

Thought about doing words "" but then I think the syntesis would still be active, just quiet, but still procesing.

Any assistance would be apprecited, Tasker or @vantojo.

Reply With Quote
 
  #8 (permalink)
Elite Member
Cedar Rapids, iowa
 
Futures Experience: Intermediate
Platform: Ninjatrader
Broker/Data: Ninjatrader - Continuum
Favorite Futures: 6E, TF, 6J
 
Tasker_182's Avatar
 
Posts: 626 since Aug 2009
Thanks: 426 given, 1,126 received

This isn't easy on my iPhone but basically you want to test if your condition (whatever it is, is true) in order to speak the words. Using the system variable FirstTickOfBar will only be true once per bar. Saidstuff is your bool variable to mean if words have been or could be spoken. Saidstuff is set false at the beginning of each bar

If your condition is true and saidstuff is false then the words are spoken and then saidstuff is set true so that words won't be spoken until the next bar (and your condition is true).

If (your condition is true)
{
If (FirstTickOfBar) saidstuff = false;
If (!saidstuff)
{
(Speak the words you want to say)
saidstuff = true;
}
}

"Money is better than poverty, if only for financial reasons." - Woody Allen

Last edited by Tasker_182; September 7th, 2013 at 06:27 PM. Reason: Corrected FirstTickOfBar spelling
Reply With Quote
The following 2 users say Thank You to Tasker_182 for this post:
 
  #9 (permalink)
Elite Member
Neuquen, Argentina
 
Futures Experience: Intermediate
Platform: Ninja
Favorite Futures: CL, TF, 6S, NG, sometimes GC
 
Posts: 195 since Jul 2012
Thanks: 25 given, 39 received

timer

you can also make a timer....so that it only speaks again after a certain number of seconds

not at my coding computer but psuedo code is this (translate to C#)

datetime lastalert = now



if time difference seconds (now - last_alert ) > 10 // only voice every 10 seconds
{
speak
lastalert = now
}



the Ninja Alert has a built in rearm capability, the voice does not, you have to code it like above

Reply With Quote
The following user says Thank You to vantojo for this post:
 
  #10 (permalink)
Elite Member
Neuquen, Argentina
 
Futures Experience: Intermediate
Platform: Ninja
Favorite Futures: CL, TF, 6S, NG, sometimes GC
 
Posts: 195 since Jul 2012
Thanks: 25 given, 39 received

now


in the example above now would be Time[0]

Reply With Quote

Reply



futures io > > > > > Using Async Voice Synthesizer Alerts

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Email Alerts HarryThompson NinjaTrader Programming 8 December 20th, 2013 01:31 PM
Best Voice Feature to use when talking to someone over internet tracy Tech Support 10 April 3rd, 2013 02:58 AM
Microsoft beats 'Apple iTV' to the punch with voice control kbit Off-Topic 10 December 6th, 2011 10:52 AM
Using Alerts in ToS Jasonh0099 ThinkOrSwim Programming 0 December 11th, 2010 01:44 AM
listen to a calm voice before you take a trade cory Off-Topic 2 June 4th, 2010 01:09 PM


All times are GMT -4. The time now is 03:08 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-11 in 0.14 seconds with 19 queries on phoenix via your IP 54.226.172.30