Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Market-Specific Sound Alert

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Market-Specific Sound Alert

    Hello

    I'm experimenting with a semi-automated strategy (automated signals but manual trade execution) and I'd like to use a specific sound file (.wav) per market to know on which market a signal occurs, as the strategy is deployed on over 20 markets and I don't have enough space on my screens to display them all.

    I've worked with sound alerts in the past and they're very convenient, but the thing I'm trying to do now is a little more complex as I want to develop a generic code that can be applied to all markets and will then recognise the specific market where a signal occurs and play the market-specific sound file.

    Example:
    A signal occurs in the NQ, I want the strategy to play the "NQ.wav" sound file,
    A signal occurs in the ES, I want the strategy to play the "ES.wav" sound file, etc

    I know how to code market-specific commands using the
    Instrument.MasterInstrument.Name == "ES" function and I also know how to play sound files using the
    PlaySound("ES.wav") command, I just don't know how to combine the two in order to create a generic code that plays market-specific sound alerts in a more efficient way than this:

    if(Instrument.MasterInstrument.Name == "ES")
    PlaySound("ES.wav");

    if(Instrument.MasterInstrument.Name == "NQ")
    PlaySound("NQ.wav");

    etc.

    Any pointers would be much appreciated.

    Thanks
    Last edited by laocoon; 05-17-2013, 01:32 AM.

    #2
    Originally posted by laocoon View Post
    Hello

    I'm experimenting with a semi-automated strategy (automated signals but manual trade execution) and I'd like to use a specific sound file (.wav) per market to know on which market a signal occurs, as the strategy is deployed on over 20 markets and I don't have enough space on my screens to display them all.

    I've worked with sound alerts in the past and they're very convenient, but the thing I'm trying to do now is a little more complex as I want to develop a generic code that can be applied to all markets and will then recognise the specific market where a signal occurs and play the market-specific sound file.

    Example:
    A signal occurs in the NQ, I want the strategy to play the "NQ.wav" sound file,
    A signal occurs in the ES, I want the strategy to play the "ES.wav" sound file, etc

    I know how to code market-specific commands using the
    Instrument.MasterInstrument.Name == "ES" function and I also know how to play sound files using the
    PlaySound("ES.wav") command, I just don't know how to combine the two in order to create a generic code that plays market-specific sound alerts in a more efficient way than this:

    if(Instrument.MasterInstrument.Name == "ES")
    PlaySound("ES.wav");

    if(Instrument.MasterInstrument.Name == "NQ")
    PlaySound("NQ.wav");

    etc.

    Any pointers would be much appreciated.

    Thanks
    Code:
    string strSound = Instrument.MasterInstrument.Name + ".wav";
    PlayAlert(strSound, "Alert4.wav");
     
    private void PlayAlert(string strSoundFile, string strDefaultSound)
    {
     string SoundToPlay = Cbi.Core.InstallDir + "sounds\\" + strSoundFile;
     string DefaultSoundToPlay = Cbi.Core.InstallDir + "sounds\\" + strDefaultSound;
     
     if (System.IO.File.Exists(SoundToPlay)) PlaySound(SoundToPlay);
     else PlaySound(DefaultSoundToPlay);
     
     return;
    }
    Will play Alert4.wav, as a default, if the specified file does not exist.
    Last edited by koganam; 05-20-2013, 07:22 AM. Reason: Modified code to use namespace directly.

    Comment


      #3
      Thanks a lot for your reply Koganam.
      Just to make sure I understand your code snippet correctly:
      The first line of code establishes the link between the market and its specific sound file?
      In other words, it makes sure the code "knows" that if has to play the "ES.wav" sound file if there's a signal in the ES and the "NQ.wav" file for a signal in the NQ?

      Thanks

      Comment


        #4
        Originally posted by laocoon View Post
        Thanks a lot for your reply Koganam.
        Just to make sure I understand your code snippet correctly:
        The first line of code establishes the link between the market and its specific sound file?
        In other words, it makes sure the code "knows" that if has to play the "ES.wav" sound file if there's a signal in the ES and the "NQ.wav" file for a signal in the NQ?

        Thanks
        Pretty much. I thought that that was what you were seeking?
        Last edited by koganam; 05-22-2013, 10:25 AM. Reason: Corrected punctuation.

        Comment


          #5
          That's indeed exactly what I'm seeking, I just wanted to make sure I understand your code correctly as you're using some commands I'm not familiar with.

          Thanks again for your kind help koganam.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by mgco4you, Today, 09:46 PM
          0 responses
          1 view
          0 likes
          Last Post mgco4you  
          Started by Rapine Heihei, Today, 08:19 PM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by Rapine Heihei, Today, 08:25 PM
          0 responses
          6 views
          0 likes
          Last Post Rapine Heihei  
          Started by f.saeidi, Today, 08:01 PM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by Rapine Heihei, Today, 07:51 PM
          0 responses
          8 views
          0 likes
          Last Post Rapine Heihei  
          Working...
          X