Price Alert

Discussion in 'MetaTrader Indicators' started by Enivid, Apr 27, 2009.

  1. Maverick

    Maverick Master Trader

    323
    2
    59
    I suppose somewhere the code needs to know what #'s 0 - 1 - 2 - 3 - 4 refer to in linestyle ... H'mmm
     
  2. Maverick

    Maverick Master Trader

    323
    2
    59
    Errors only came up with 2 - 1 at the top somewhere and 1 at the bottom ... should have copied them for reference
     
  3. Maverick

    Maverick Master Trader

    323
    2
    59
    Who's a plonker then ... style was already there :(

    Question is what are the options apart from Solid and Dot

    Will have to have a look at someone elses code
     
  4. Maverick

    Maverick Master Trader

    323
    2
    59
    Looks like it's

    Solid
    DashDash
    Dot
    DashDotDash
    DashDotDotDash

    So i am guessing somewhere the above needs identifying with numbers
     
  5. Maverick

    Maverick Master Trader

    323
    2
    59
    [​IMG]

    Needed to get this done so I can go to bed without thinking about it all night

    The only thing I am thinking about is ... Number the lines ... H'mmm
    .
     
  6. Maverick

    Maverick Master Trader

    323
    2
    59
    Want to thank you Hayseed for introducing your signature to me - Makes perfect sense to split up the blocks of code - Helps prevent

     
  7. hayseed

    hayseed Master Trader

    395
    90
    94
    //----

    hey maverick...... quite often the actual errors reported won't be the actual errors..... so it might say your missing a '}' when actually your missing a '=' ..... there are errors where it will list each one individually..... and other times it will list them only by type with no mention of how many of each type...... the more errors you have the more you will become familiar with what it means.....

    you can look in the code you posted for the errors..... there are several places, like below, that need both ';' and '}' ..... maybe 4 other places only need a '}'..... the '{' in the deint section is out of place..... maybe some more..... can't remember.....

    these are the same errors we all make......h

    //----

    Code (MQL4):
       if ((Ask > PriceAbove_1) && (PriceAbove_1 > 0))
        {
           Alert("Price above the alert level 1.");
           PlaySound("ring.wav");
           SendMail("Price for " + Symbol() +  " above the alert level 1 " + Ask, "Price for " + Symbol() +  " reached " + Ask + " level, which is above your alert level of 1 " + PriceAbove_1);
           ObjectDelete("PriceAbove_1");
           PriceAbove_1= 0                             [COLOR=#ff4d4d]//----  missing ;
                                                                 //---- missing }[/COLOR]
     
     
  8. Maverick

    Maverick Master Trader

    323
    2
    59
    Well I decided to go back to the original plan of 5 UP and 5 down :)

    Initially I had 9 errors :(

    [​IMG]

    Luckily they were easy ones :)

    Again thank you Hayseed for your assistance - appreciated
    .
     
  9. Maverick

    Maverick Master Trader

    323
    2
    59
    How could Maverick with a little help choose which wav files to use - I'm thinking choice of two ... Good and Bad ... Beyond me unfortunately but could it be an automatic selection depending on the trade. I wouldn't expect you to do all the work ... just guide me

    If you place a BUY trade the Green lines when hit are Good for you and the Red Bad and vice versa with a SELL trade

    My idea is to find/create a Good wav file for when the trade is in your favour and a BAD wav when the trade is going against you

    When you are doing something else it's a feel good factor to hear money going into the bank :) On the other hand if you hear it going down the toilet :( you had better review the situation asap
    .
     
  10. Maverick

    Maverick Master Trader

    323
    2
    59
    Forget about the previous post 69 which was a good idea at the time ... thought of possible easier solution

    Looking to have the PlaySound choice from a dropdown of available sounds in the Sound folder

    [​IMG]
    Once you have decided upon the overall trend it's not something that you will be changing every five minutes once set

    Been looking at the code from another EA and have come up with

    Code (MQL4):
    extern SoundList Above_5 = s11;

    enum SoundList
    {
        s11=11,        //Above_5.wav
        s10=10,        //Above_4.wav
        s9=9,          //Above_3.wav  etc etc
    };
    Am i on the right tracks and what do i do with ?
    Code (MQL4):
    PlaySound("ring.wav");
    How do i tie it all together
     
  11. hayseed

    hayseed Master Trader

    395
    90
    94
    //------

    hey maverick..... for PlaySound() to work effectively it must be short.... anything longer than 1 second is too long.....h

    //------

    Code (MQL4):

    extern double above1     =                  0.0;
    extern string above1wav  =    "email.wav";   // keep sounds less than 2 seconds long


    extern double below1     =                  0.0;
    extern string below1wav  = "timeout.wav";
    //+------------------------------------------------------------------+
    //| Custom indicator initialization function                         |
    //+------------------------------------------------------------------+
    int init()
      {

    //--- indicator buffers mapping

    //---
       return(0);
      }
    //+------------------------------------------------------------------+
    //| expert deinitialization function                                 |
    //+------------------------------------------------------------------+
    int deinit()
      {
    //----

    //----
       return(0);
      }
    //+------------------------------------------------------------------+
    //|                                                                  |
    //+------------------------------------------------------------------+

    int start()
      {

       if((Ask > above1) && (above1 > 0.0)) {PlaySound(above1wav);}  // keep your sounds short

       if((Ask < below1) && (below1 > 0.0)) {PlaySound(below1wav);}
       
       //-----------  expand to as many lines as needed
       //-----------  be sure to limit the number of times the PlaySound() works otherwise they never stop till untrue


       return(0);
      }

    //------
     
    //-----
     
  12. Maverick

    Maverick Master Trader

    323
    2
    59
    O'oops I was thinking along the lines of something like beep,beep,beep,beep,beep for above5 which I would make up with Audacity

    But then again if I read you right I can determine how may times to play beep

    .
     
  13. Maverick

    Maverick Master Trader

    323
    2
    59
    I have
    Code (MQL4):
    //----
        if ((Ask > PriceAbove_5) && (PriceAbove_5 > 0))
        {
           Alert("Price above the alert level 5.");
           PlaySound("alert.wav");
           SendMail("Price for " + Symbol() +  " above the alert level 3 " + Ask, "Price for " + Symbol() +  " reached " + Ask + " level, which is above your alert level of " + PriceAbove_5);
           ObjectDelete("PriceAbove_5");
           PriceAbove_5 = 0;
        }
    //----
    at the moment ... so am i just replacing
    Code (MQL4):
    PlaySound("alert.wav");
    with
    Code (MQL4):
    if((Ask > above1) && (above1 > 0.0)) {[URL='https://docs.mql4.com/common/PlaySound']PlaySound[/URL](above1wav);}
    and presumably the 0.0 is the number of times it plays

    .
     
  14. Maverick

    Maverick Master Trader

    323
    2
    59
  15. Enivid

    Enivid Administrator Staff Member

    8,761
    310
    114
    It came from the automatic code highlighting engine, which also adds URLs to the relevant function description pages.
     
  16. Maverick

    Maverick Master Trader

    323
    2
    59
    So I need to watch out for it and delete BEFORE posting - never seen it before though
     
  17. Enivid

    Enivid Administrator Staff Member

    8,761
    310
    114
    No, you just need to be careful when editing formatted code quotes and when editing your own code posts. When you insert new code snippets, it should not appear in such a broken manner.
     
  18. Maverick

    Maverick Master Trader

    323
    2
    59
    So what you are saying is to leave well alone
    and not to start removing bits in [brackets]
     
  19. Enivid

    Enivid Administrator Staff Member

    8,761
    310
    114
    When you copy it to MetaEditor? Yes, you should remove it. Otherwise it will give you compilation errors.
     
  20. Maverick

    Maverick Master Trader

    323
    2
    59
    The PriceAlert indicator is evolving into a NEW AudioPriceAlert indicator deserving it's own thread ... here
     

Share This Page