Announcement

Collapse
No announcement yet.

formula problems

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

  • formula problems

    i'm having alot of trouble getting the logic down on a study that I'm trying to. if someone could shed any light, I'd much apprecaite it.

    What I need:
    If the open() is above the bollinger.UPPER
    then, If the open() is below 75
    then, sell or place an indicator in that place

    That's it. I went through the docs, and it stated that this is simple stuff, but I'm having some trouble and would appreciate any insight

    Here is the pertinent code that I have so far:

    if (
    open() > vBollinger34.getValue(BollingerStudy.UPPER)
    &&
    vStoch25_3.getValue(StochStudy.SLOW) < 75
    ) onAction1(); // onAction give the sell indicator

  • #2
    stvchz
    Assuming I understood your conditions correctly the attached efs should do what you asked.
    It will plot a red circle on the Open of a bar that opens above a 34 period Upper BB while the Stochastic %D is below 75.
    The efs was written using only the Formula Wizard which can be used to view/edit the formula.
    Alex
    Attached Files

    Comment


    • #3
      thanks very much for your help on this. True, the code that I supplied does do what it's told, so that's a good first step. Everything is working to an extent. The problem though, I think, is the logic behind the code.

      I made a few tweaks to the formula you sent back to suit what I need, but is basically the same to conditions in the if > then statement.

      I've attached a screenshot to kind of give an overview of what I'm trying to achieve
      Attached Files

      Comment


      • #4
        try changinf the if stmt to read

        open() > vBollinger34.getValue(BollingerStudy.UPPER) &&
        vStoch14_1.getValue(StochStudy.SLOW) < 75 &&
        vStoch14_1.getValue(StochStudy.SLOW,-1) > 75

        Comment


        • #5
          thanks for your post. Though I did get one sell signal, that was good, but there should be more. I believe that the Bollinger criteria is the problem but confused transferring logic to code. I've attached a screenshot as well as my current if stmt.

          if (
          open() > vBollinger34.getValue(BollingerStudy.UPPER) &&
          vStoch25_3.getValue(StochStudy.SLOW) < 80 &&
          vStoch25_3.getValue(StochStudy.SLOW, -1) > 80
          )
          Attached Files

          Comment


          • #6
            Re: Reply to post 'formula problems'

            The other trades you noted did not have the open above the upper BB.

            ----- Original Message -----
            From: <[email protected]>
            To: <[email protected]>
            Sent: Saturday, January 24, 2004 3:02 PM
            Subject: Reply to post 'formula problems'


            > Hello dloomis,
            >
            > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            >

            Comment


            • #7
              Dave noted something that is not readily apparent, in order for you to get the sell signal, the way you have your logic is to have both of those conditions occur simultaniously.

              If you have one condition met in one bar and the other in the next, it will not be a sell signal.

              You are going to have to set up your logic such that if one is met, you set a flag such that if the other comes in in the next 1, 2 or 3 bars, a sell signal will be generated.

              Comment


              • #8
                You are going to have to set up your logic such that if one is met, you set a flag such that if the other comes in in the next 1, 2 or 3 bars, a sell signal will be generated.


                thank you for this post. this is what I expected, but am unsure how to match the logic to the code.

                here is what I have:
                if (
                open() > vBollinger34.getValue(BollingerStudy.UPPER) &&

                // If this condition is met, then do this:

                vStoch25_3.getValue(StochStudy.SLOW) < 80 &&
                vStoch25_3.getValue(StochStudy.SLOW, -1) > 80

                // then, give the signal:
                ) onAction1();

                currently, the bollinger and stochastic is getting lumped into the same request.

                Comment


                • #9
                  Here is something that is fairly simple to implement.


                  PHP Code:
                  if (bB1)
                      
                  bB1--;
                  if (
                  bB2)
                      
                  bB2--;
                  if (
                  bS1)
                      
                  bS1--;
                  if (
                  bS2)
                      
                  bS2--;



                  if (
                  open() > vBollinger34.getValue(BollingerStudy.UPPER))
                      
                  bS1 3;

                  if (
                  vStoch25_3.getValue(StochStudy.SLOW) < 80 && vStoch25_3.getValue(StochStudy.SLOW, -1) > 80)
                      
                  bS2 3;

                  if ((
                  bS1) && (bS2))
                   
                  onAction1(); 
                  The if statements that test the bS and bB variables are true if bS or bB are non zero numbers, if they are zero, the check is false, if they are non-zero numbers the check is true (negative numbers are true also).

                  In this example, if our bollinger test is true, I set bS1 equal to 3. A logical check of this is now true. the same is true of the StochStudy test. In each case, these tests will be true for 3 bars.

                  Each subsequent bar these values will be decremented by one if they are non zero. This gives you a 3 bar window.

                  I hope this will help.
                  Last edited by Guest; 01-24-2004, 06:53 PM.

                  Comment

                  Working...
                  X