Announcement

Collapse
No announcement yet.

Code help

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

  • Code help

    I am trying to get an efs to do a " set up and entry" type of trade.

    I have two thirds of it done but can't get the last condition set. I am looking for a set up of when the rsi and stochastic are overbought (eg > 80) or over sold (<20).
    Once these conditions are met I then want an entry of when the macd crosses the zero line - with an audible alarm to let me know!!

    I attach the code that has been developed so far (much help from montenegro) which doesn't work - but I feel its almost there?

    any help much appreciated.

    Russell
    Attached Files

  • #2
    Russell,

    Are these the conditions you were looking for?

    Added two global variables...

    var vOverBoughtFlag = null;
    var vOverSoldFlag = null;

    and then added this to main...

    PHP Code:
    if (vValue 80 && vSlow 80vOverBoughtFlag true;
    if (
    vValue 20 && vSlow 20vOverSoldFlag true;

    if (
    vOverSoldFlag == true && vHist && !Strategy.isLong()) {
        
    Strategy.doLong("Over Sold"Strategy.MARKETStrategy.THISBAR);
        
    vOverSoldFlag false;
        }

    if (
    vOverBoughtFlag == true && vHist && !Strategy.isShort()) {
        
    Strategy.doShort("Over Bought"Strategy.MARKETStrategy.THISBAR);
        
    vOverBoughtFlag false;
        } 
    Regards,
    Jay F.
    Product Manager
    _____________________________________
    Have a suggestion to improve our products?
    Click Support --> Request a Feature in eSignal 11

    Comment


    • #3
      Hmm... that didn't work as I mistyped vSLOW.

      I also changed the way vValue and vSLOW gets their data. It seems to work faster by creating objects for each study used, then retrieving their data with getValue.

      Please see the attached.
      Attached Files
      Regards,
      Jay F.
      Product Manager
      _____________________________________
      Have a suggestion to improve our products?
      Click Support --> Request a Feature in eSignal 11

      Comment


      • #4
        Here's one with Alerts
        Attached Files
        Regards,
        Jay F.
        Product Manager
        _____________________________________
        Have a suggestion to improve our products?
        Click Support --> Request a Feature in eSignal 11

        Comment


        • #5
          Jay

          Thanks - I haven't fully tested it yet but I think it might run into the same problem I have had. Once the ob/os condition is met I want the obvalue to remain true UNTIL the macd condition negates it - make sense?
          Its very rare to have an ob/os and a macd crossing the base line (and thats not what I want to use it for anyway!)

          I must commend your efs skills - I keep seeing these additions and changes to my formulas and wonder why I didn't think of them
          Russ

          Comment


          • #6
            Russell,

            Regarding the OB/OS indicators, once the Stoch and the RSI are above 80 or both below 20, then the vOverBoughtFlag or vOverSoldFlag is set to true. This allows them to rise or fall without affecting the trigger for the MACD cross. Then once the MACD cross happens and a trade occurs, then the OB/OS flag is reset. There is probably some tweaking that will still need to be done like programming in exit strategies, and also possibly tuning the underlying studies (located at the top of the EFS.)

            ~Jay
            Regards,
            Jay F.
            Product Manager
            _____________________________________
            Have a suggestion to improve our products?
            Click Support --> Request a Feature in eSignal 11

            Comment


            • #7
              Jay

              Nothing seems to be happening on the noise front - I have checked that the sound files are there.

              Correction - the on action alerts work but not seemingly the ob/os alerts
              Last edited by Russell; 03-12-2003, 02:56 AM.

              Comment


              • #8
                Russell,

                Did you want an audible alert when the trade was executed, and/or when the OB/OS conditions were met? Currently, it is just in the trade execution.

                ~Jay
                Regards,
                Jay F.
                Product Manager
                _____________________________________
                Have a suggestion to improve our products?
                Click Support --> Request a Feature in eSignal 11

                Comment


                • #9
                  RE: Reply to post 'Code help'

                  I am looking for one alert when the macd crosses the zero line after an ob
                  or os condition has been met. Then I want it to reset itself.
                  Russ

                  -----Original Message-----
                  From: [email protected] [mailto:[email protected]]
                  Sent: 12 March 2003 15:11
                  To: [email protected]
                  Subject: Reply to post 'Code help'


                  Hello Russell,

                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                  Comment


                  • #10
                    In testing the OB/OS flags, it looks as if they are not being hit because the RSI rarely hits above or below 80. In using the replay mode, I was able to check to make sure that alert and sound was working properly.



                    Attached is the current version I tested this on.

                    Also, once the OB/OS flags are set and the MACD crossover occurs, the OB/OS flags are reset automatically.
                    Attached Files
                    Regards,
                    Jay F.
                    Product Manager
                    _____________________________________
                    Have a suggestion to improve our products?
                    Click Support --> Request a Feature in eSignal 11

                    Comment


                    • #11
                      RE: Reply to post 'Code help'

                      Hello Jay

                      I will run it today in real time and see what happens. I still think the
                      problem is that the ob/os flag is reset every time the efs checks a new bar
                      (one minute in my case). You're right its very rare to get rsi > 80 and a
                      crossing macd in the same moment - I would be surprised to see it more than
                      once or twice a day in fact. Am I getting this completely wrong in my
                      assumptions - how does the ob/os flag stay overbought in this efs until
                      cancelled by the crossing macd.
                      A very confused Russell.

                      -----Original Message-----
                      From: [email protected] [mailto:[email protected]]
                      Sent: 12 March 2003 18:42
                      To: [email protected]
                      Subject: Reply to post 'Code help'


                      Hello Russell,

                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                      Comment


                      • #12
                        RE: Reply to post 'Code help'

                        Update

                        I have altered the signal condition to 75 and 25 and the trigger alert box
                        is a gem of a find(so thank you for that!).
                        I still get no sounds at all which is weird and it seems to be missing most
                        signals. No longs at all this morning - and I counted 3, it gave 3 shorts
                        but missed 2.
                        Russ

                        -----Original Message-----
                        From: [email protected] [mailto:[email protected]]
                        Sent: 12 March 2003 18:42
                        To: [email protected]
                        Subject: Reply to post 'Code help'


                        Hello Russell,

                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                        Comment


                        • #13
                          RE: Reply to post 'Code help'

                          Yes - its doing what I thought it was doing. The signal is triggered only
                          when both conditions are met IN THE SAME BAR.
                          Any thoughts on how to correct this?
                          Russ

                          -----Original Message-----
                          From: [email protected] [mailto:[email protected]]
                          Sent: 12 March 2003 18:42
                          To: [email protected]
                          Subject: Reply to post 'Code help'


                          Hello Russell,

                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                          Comment


                          • #14
                            I'm comming in on te middle of this, but are the OB/OS flags being reset because they aren't locally defined globals (ie: defined outside any function)? If so, just make them globals by defining them outside any function including main() or preMain().

                            If they are local globals already - are they being reset in a newbar check (ie:

                            if (getCurrentBarIndex == BARSTATE_NEWBAR){
                            obflag = 0;
                            osflag = 0;
                            }

                            Then remove the 0 resets for the NEWBAR condition.

                            G
                            Garth

                            Comment


                            • #15
                              RE: Reply to post 'Code help'

                              Hi G
                              I am not a java king so forgive me if I go slowly. I don't have a barstate
                              newbar check though and I am currently just waiting for a new signal -
                              should be in the next 10 mins. I propose to try and post the chart with the
                              trigger alert list so that you can see when it fires and when it doesn't.
                              R

                              -----Original Message-----
                              From: [email protected] [mailto:[email protected]]
                              Sent: 13 March 2003 15:37
                              To: [email protected]
                              Subject: Reply to post 'Code help'


                              Hello Russell,

                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                              Comment

                              Working...
                              X