Announcement

Collapse
No announcement yet.

Stochastics Divergent condition with trailer

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

  • Stochastics Divergent condition with trailer

    Hello

    I am working on developing an EFS that will identify a divergence condition, and once the condition is met, will monitor certain conditions until it changes:

    In my code I am comparing the 1 minute and 2 minute Stochastics; When 1min and 2min have both been pointing UP, and the 2min turns down while the 1min is still up, this is my divergent condition; Then it will draw a purple colour on the chart;

    var continueDown
    var continueUP
    var conditionAdv = (continueDown,continueUP);

    if(((stochK(14,3,3,inv(1), -1) > stochD(14,3,3, inv(1), -1)) &&
    (stochK(14,3,3,inv(2), -1) > stochD(14,3,3, inv(2), -1)) &&
    (stochK(14,3,3,inv(1)) > stochD(14,3,3, inv(1))) &&
    (stochK(14,3,3,inv(2)) < stochD(14,3,3, inv(2)))) &&
    (conditionAdv == continueDown) ){
    drawShapeRelative(0,BottomRow1,Shape.SQUARE,null,C olor.RGB(101,0,169),Shape.CENTER|Shape.PRESET,"DOW N " + getCurrentBarCount());
    }

    Once I have achieved my divergent condition, I want to be able to monitor only the 2min timeframe, as long as the 2min timeframe remains pointing down, I want the output color to remain purple.
    If the 2min timeframe changes from down to up, at this point I want the output to change to blue.

    else if((conditionAdv == continueDown) && (stochK(14,3,3,inv(2)) < stochD(14,3,3, inv(2)))) {
    drawShapeRelative(0,BottomRow1,Shape.SQUARE,null,C olor.RGB(101,0,169),Shape.CENTER|Shape.PRESET,"DOW N " + getCurrentBarCount());
    } else if((conditionAdv == continueDown) && (stochK(14,3,3,inv(2)) > stochD(14,3,3, inv(2)))) {
    drawShapeRelative(0,BottomRow1,Shape.SQUARE,null,C olor.RGB(70,100,160),Shape.CENTER|Shape.PRESET,"DO WN " + getCurrentBarCount());
    }

    I have tried to setup a var to hold and remember the divergent condition, and once it has been met will remember this, but have not been able to make this work successfully.

    Any tips or suggestions would be appreciate.

  • #2
    Hello hama123, I'm going to have to assume that there's more to your code, because you don't show any value assignments to your variables, as such they are just undefined and don't do anything in the code that you have above...it just sees undefined == undefined and since that's true, it just ignores your variables and proceeds to the rest of the "if" statements. To understand what I was looking at, I used a 1 minute chart with stochastics on it and then programed your code as a sub-chart with a 2 minute stochastics so that I could verify the results. I didn't spend much time verifying whether the code is catching all of the signals, but each of the signals that I seen conformed to your request. If you have any questions, feel free to ask. I will paste it here as well as upload it as an attachment since sometimes things don't seem to paste too well here.

    var bDivergent = null; // Global boolean variable to hold divergent condition

    function preMain(){
    setPriceStudy(false);
    setStudyTitle("Stochastic Divergence");
    setCursorLabelName("%K_2",0);
    setPlotType(PLOTTYPE_LINE,0);
    setDefaultBarFgColor(Color.RGB(0,148,255), 0);
    setCursorLabelName("%D_2",1);
    setPlotType(PLOTTYPE_LINE,1);
    setDefaultBarFgColor(Color.RGB(255,106,0), 1);
    }

    function main(){
    if(getBarState() == BARSTATE_ALLBARS){
    var xStochK = null;
    var xStochD = null;
    }
    xStochK = stochK(14,3,3,inv(2));
    xStochD = stochD(14,3,3,inv(2));
    if(((stochK(14,3,3,inv(1), -1) > stochD(14,3,3, inv(1), -1)) &&
    (stochK(14,3,3,inv(2), -1) > stochD(14,3,3, inv(2), -1)) &&
    (stochK(14,3,3,inv(1)) > stochD(14,3,3, inv(1))) &&
    (stochK(14,3,3,inv(2)) < stochD(14,3,3, inv(2))))){
    bDivergent = true;
    drawShapeRelative(0,BottomRow1,Shape.SQUARE,null,C olor.RGB(101,0,169),Shape.CENTER|Shape.PRESET,"DOW N" + getCurrentBarCount());
    }else if(bDivergent && (stochK(14,3,3,inv(2)) < stochD(14,3,3, inv(2)))){
    drawShapeRelative(0,BottomRow1,Shape.SQUARE,null,C olor.RGB(101,0,169),Shape.CENTER|Shape.PRESET,"DOW N" + getCurrentBarCount());
    }else if(stochK(14,3,3,inv(2)) > stochD(14,3,3, inv(2))){
    bDivergent = false;
    drawShapeRelative(0,BottomRow1,Shape.SQUARE,null,C olor.RGB(70,100,160),Shape.CENTER|Shape.PRESET,"DO WN" + getCurrentBarCount());
    }
    return [xStochK, xStochD];
    }
    Attached Files

    Comment


    • #3
      Hello LetUsLearn,

      Thank you so much for your reply. I have had an opportunity to work with the information you have provided and made some changes. I have modified your efs to track both up and down divergence, however I have encountered a problem when I string both up and down scenarios with "else if", the output only gives me the up based output, when I separate the up section and the down section, I also only get the up output.

      Can you suggest a way I can have the efs assess both up and down scenarios and provide output for whatever condition occurs ?

      var DNDivergent = null; // Global boolean variable to hold divergent condition
      var UPDivergent = null;

      function preMain(){
      setPriceStudy(false);
      setStudyTitle("Stoch Divergence 2Min");
      setCursorLabelName("%K_2",0);
      setPlotType(PLOTTYPE_LINE,0);
      setDefaultBarFgColor(Color.RGB(0,148,255), 0);
      setCursorLabelName("%D_2",1);
      setPlotType(PLOTTYPE_LINE,1);
      setDefaultBarFgColor(Color.RGB(255,106,0), 1);
      }

      function main(){
      if(getBarState() == BARSTATE_ALLBARS){
      var xStochK = null;
      var xStochD = null;
      }
      xStochK = stochK(14,3,3,inv(2));
      xStochD = stochD(14,3,3,inv(2));
      if(((stochK(14,3,3,inv(1), -1) > stochD(14,3,3, inv(1), -1)) &&
      (stochK(14,3,3,inv(2), -1) > stochD(14,3,3, inv(2), -1)) &&
      (stochK(14,3,3,inv(1)) > stochD(14,3,3, inv(1))) &&
      (stochK(14,3,3,inv(2)) < stochD(14,3,3, inv(2))))){
      DNDivergent = true;
      drawShapeRelative(0,BottomRow1,Shape.SQUARE,null,C olor.RGB(101,0,169),Shape.CENTER|Shape.PRESET,"DOW N" + getCurrentBarCount());
      }else if(DNDivergent && (stochK(14,3,3,inv(2)) < stochD(14,3,3, inv(2)))){
      drawShapeRelative(0,BottomRow1,Shape.SQUARE,null,C olor.RGB(101,0,169),Shape.CENTER|Shape.PRESET,"DOW N" + getCurrentBarCount());
      }else if(stochK(14,3,3,inv(2)) > stochD(14,3,3, inv(2))){
      DNDivergent = false;
      drawShapeRelative(0,BottomRow1,Shape.SQUARE,null,C olor.RGB(13,13,13),Shape.CENTER|Shape.PRESET,"DOWN " + getCurrentBarCount());

      }

      if(((stochK(14,3,3,inv(1), -1) < stochD(14,3,3, inv(1), -1)) &&
      (stochK(14,3,3,inv(2), -1) < stochD(14,3,3, inv(2), -1)) &&
      (stochK(14,3,3,inv(1)) < stochD(14,3,3, inv(1))) &&
      (stochK(14,3,3,inv(2)) > stochD(14,3,3, inv(2))))){
      UPDivergent = true;
      drawShapeRelative(0,BottomRow1,Shape.SQUARE,null,C olor.RGB(255,255,0),Shape.CENTER|Shape.PRESET,"DOW N" + getCurrentBarCount());
      }else if(UPDivergent && (stochK(14,3,3,inv(2)) > stochD(14,3,3, inv(2)))){
      drawShapeRelative(0,BottomRow1,Shape.SQUARE,null,C olor.RGB(255,255,0),Shape.CENTER|Shape.PRESET,"DOW N" + getCurrentBarCount());
      }else if(stochK(14,3,3,inv(2)) < stochD(14,3,3, inv(2))){
      UPDivergent = false;
      drawShapeRelative(0,BottomRow1,Shape.SQUARE,null,C olor.RGB(13,13,13),Shape.CENTER|Shape.PRESET,"DOWN " + getCurrentBarCount());

      }



      // return [xStochK, xStochD];
      }

      Comment


      • #4
        Hello hama123,
        The issue that you’re having is that you have given the up and down shapes the same name ("DOWN" + getCurrentBarCount()), so the down shapes are being overwritten by the up shapes. Specifically, the last drawShapeRelative statement just above the return statement is overwriting your purple with the default background color of the chart (RGB(13,13,13)). If you comment that one line out, you’ll see both the yellow and purple shapes on the chart.
        When I wrote the original code, I loaded it into a chart and checked several places that had the purple shapes and verified that they met the conditions that you asked for, however when I looked at this again as per your request, I noticed that while new data was streaming in that the program was not behaving correctly, so I made some changes to it, but I won’t know until next week when I let it run with new data streaming in as to whether these changes fixed the streaming data issue.
        Tonight I made 2 versions of the program in notepad for you, one is a sub-chart with parameters for the upper and lower band, and the other you could load into the main chart as a price study if you preferred. In both versions, when there isn’t any divergence, I have the shape colored blue as in your original program…there’s no need to color it the same color as the chart’s background color, if you don’t want it to have a color when there’s no divergence, then just delete or comment out the 2 ‘ifs’ that color the shape blue. Note where I put those 2 ‘ifs’, being that they are the first to color the shape and they have the same names as the code below it, when one of the divergent conditions occur, they get overwritten with yellow or purple...enjoy!


        var fpArray = []; // Parameters in main to add bands
        var bUpDivergent = null; // Global boolean saves up divergent condition
        var bDnDivergent = null; // Global boolean saves down divergent condition
        var bPurple = null; // Global boolean to track purple shape...needed for streaming
        var bYellow = null; // Global boolean to track yellow shape...needed for streaming

        function preMain(){
        setPriceStudy(false);
        setStudyTitle("Stochastic Divergence");
        setCursorLabelName("%K_2",0);
        setPlotType(PLOTTYPE_LINE,0);
        setDefaultBarFgColor(Color.RGB(0,148,255), 0);
        setCursorLabelName("%D_2",1);
        setPlotType(PLOTTYPE_LINE,1);
        setDefaultBarFgColor(Color.RGB(255,106,0), 1);

        var x = 0;
        fpArray[x] = new FunctionParameter("UpperBand", FunctionParameter.INTEGER);
        with(fpArray[x++]){
        setUpperLimit(100);
        setDefault(80);
        }
        fpArray[x] = new FunctionParameter("LowerBand", FunctionParameter.INTEGER);
        with(fpArray[x++]){
        setLowerLimit(0);
        setDefault(20);
        }
        fpArray[x] = new FunctionParameter("AddBands", FunctionParameter.BOOLEAN);
        with(fpArray[x++]){
        setDefault(false);
        }
        }

        function main(UpperBand, LowerBand, AddBands){
        if(getBarState() == BARSTATE_ALLBARS){
        if(AddBands){
        addBand(UpperBand, PS_DASH, 1, Color.RGB(192,0,0));
        addBand(LowerBand, PS_DASH, 1, Color.RGB(0,192,0));
        }
        }
        if(getBarState() == BARSTATE_NEWBAR){
        if(bUpDivergent) bYellow = true;
        else bYellow = false;
        if(bDnDivergent) bPurple = true;
        else bPurple = false;
        }
        if(bYellow && stochK(14,3,3,inv(2)) > stochD(14,3,3, inv(2))) bUpDivergent = true;
        if(bPurple && stochK(14,3,3,inv(2)) < stochD(14,3,3, inv(2))) bDnDivergent = true;

        if(!bUpDivergent)
        drawShapeRelative(0,BottomRow1,Shape.SQUARE,null,C olor.RGB(70,100,160),Shape.CENTER|Shape.PRESET,"UP " + getCurrentBarCount());
        if(!bDnDivergent)
        drawShapeRelative(0,BottomRow1,Shape.SQUARE,null,C olor.RGB(70,100,160),Shape.CENTER|Shape.PRESET,"Do wn" + getCurrentBarCount());

        if(stochK(14,3,3,inv(1), -1) > stochD(14,3,3, inv(1), -1) &&
        stochK(14,3,3,inv(2), -1) > stochD(14,3,3, inv(2), -1) &&
        stochK(14,3,3,inv(1)) > stochD(14,3,3, inv(1)) &&
        stochK(14,3,3,inv(2)) < stochD(14,3,3, inv(2))){
        bDnDivergent = true;
        drawShapeRelative(0,BottomRow1,Shape.SQUARE,null,C olor.RGB(101,0,169),Shape.CENTER|Shape.PRESET,"DOW N" + getCurrentBarCount());
        }else if(bDnDivergent && stochK(14,3,3,inv(2)) < stochD(14,3,3, inv(2))){
        drawShapeRelative(0,BottomRow1,Shape.SQUARE,null,C olor.RGB(101,0,169),Shape.CENTER|Shape.PRESET,"DOW N" + getCurrentBarCount());
        }else if(stochK(14,3,3,inv(2)) > stochD(14,3,3, inv(2))) bDnDivergent = false;

        if(stochK(14,3,3,inv(1), -1) < stochD(14,3,3, inv(1), -1) &&
        stochK(14,3,3,inv(2), -1) < stochD(14,3,3, inv(2), -1) &&
        stochK(14,3,3,inv(1)) < stochD(14,3,3, inv(1)) &&
        stochK(14,3,3,inv(2)) > stochD(14,3,3, inv(2))){
        bUpDivergent = true;
        drawShapeRelative(0,BottomRow1,Shape.SQUARE,null,C olor.RGB(255,255,0),Shape.CENTER|Shape.PRESET,"UP" + getCurrentBarCount());
        }else if(bUpDivergent && stochK(14,3,3,inv(2)) > stochD(14,3,3, inv(2))){
        drawShapeRelative(0,BottomRow1,Shape.SQUARE,null,C olor.RGB(255,255,0),Shape.CENTER|Shape.PRESET,"UP" + getCurrentBarCount());
        }else if(stochK(14,3,3,inv(2)) < stochD(14,3,3, inv(2))) bUpDivergent = false;

        return [stochK(14,3,3,inv(2)), stochD(14,3,3,inv(2))];
        }

        Attached Files

        Comment


        • #5
          Hello LetUsLearn,

          Thank you so much for the help you have provided. I have been working with your efs and it works great in a fixed 1min time interval. I have found that price is changing so quickly that structuring the efs within 1min intervals is too long and definitely affects the timing of the output. When I try to run the efs in a 30second window, I get output structured to start at the end or beginning of the next minute, as it should be.
          I have modified the efs so that it retrieves the data using getSeries command as opposed to using e.g. stochK(14,3,3).
          Now I have run into a different issue, when using stochK(14,3,3, inv(1), -1) I can use the -1 parameter to compare the previous min data with the current minute data, to create the divergent condition. If I use getSeries to access data, I cannot use the -1 parameter.

          I have tried to structure the divergent condition into 2 parts
          -1- part 1;
          if ((x_stochasticK < x_stochasticD) && (x_stochK_X < x_stochD_X)) ConditionforUp = true;

          -2- part 2;
          if ((x_stochasticK < x_stochasticD) && (x_stochK_X < x_stochD_X))
          ConditionforUp = true;
          if((ConditionforUp) && (x_stochasticK < x_stochasticD) && (x_stochK_X > x_stochD_X) ) {
          bDnDivergent = true;
          ConditionnormUp = false;
          drawShapeRelative(0,BottomRow1,Shape.SQUARE,null,C olor.RGB(50,0,169),Shape.CENTER|Shape.PRESET,"DOWN " + getCurrentBarCount());
          } else if(bDnDivergent && x_stochK_X > x_stochD_X){
          drawShapeRelative(0,BottomRow1,Shape.SQUARE,null,C olor.RGB(101,0,169),Shape.CENTER|Shape.PRESET,"DOW N" + getCurrentBarCount());
          } else if(x_stochK_X < x_stochD_X) bDnDivergent = false;

          The output seems to ignore part 1; and assumes ConditionforUP is true and will execute the next if statement creating the wrong output.

          Any suggestions would be appreciated.

          var fpArray = []; // Parameters in main to add bands
          var bUpDivergent = null; // Global boolean saves up divergent condition
          var bDnDivergent = null; // Global boolean saves down divergent condition
          var bPurple = null; // Global boolean to track purple shape...needed for streaming
          var bYellow = null; // Global boolean to track yellow shape...needed for streaming
          var ConditionforUp = null;
          var ConditionforDn = null;

          function preMain(){
          setPriceStudy(false);
          setStudyTitle("Stochastic Divergence");
          setCursorLabelName("%K_2",0);
          setPlotType(PLOTTYPE_LINE,0);
          setDefaultBarFgColor(Color.RGB(0,148,255), 0);
          setCursorLabelName("%D_2",1);
          setPlotType(PLOTTYPE_LINE,1);
          setDefaultBarFgColor(Color.RGB(255,106,0), 1);

          var x = 0;
          fpArray[x] = new FunctionParameter("UpperBand", FunctionParameter.INTEGER);
          with(fpArray[x++]){
          setUpperLimit(100);
          setDefault(80);
          }
          fpArray[x] = new FunctionParameter("LowerBand", FunctionParameter.INTEGER);
          with(fpArray[x++]){
          setLowerLimit(0);
          setDefault(20);
          }
          fpArray[x] = new FunctionParameter("AddBands", FunctionParameter.BOOLEAN);
          with(fpArray[x++]){
          setDefault(false);
          }
          }

          var bInit = false;
          var x_stochasticK = null;
          var x_stochasticD = null;
          var x_stochK_X = null;
          var x_stockD_X = null;


          function main(UpperBand, LowerBand, AddBands){
          if(getBarState() == BARSTATE_ALLBARS){
          if(AddBands){
          addBand(UpperBand, PS_DASH, 1, Color.RGB(192,0,0));
          addBand(LowerBand, PS_DASH, 1, Color.RGB(0,192,0));
          }
          }
          if(getBarState() == BARSTATE_NEWBAR){
          if(bUpDivergent) bYellow = true;
          else bYellow = false;
          if(bDnDivergent) bPurple = true;
          else bPurple = false;
          }

          if(bInit == false){

          x_stochasticK = getSeries(AGet.stochastic(Length,KParam,DParam,STO CHASTIC_K,inv(1)));
          x_stochasticD = getSeries(AGet.stochastic(Length,KParam,DParam,STO CHASTIC_D,inv(1)));
          x_stochK_X = getSeries(AGet.stochastic(Length,KParam,DParam,STO CHASTIC_K,inv(2)));
          x_stochD_X = getSeries(AGet.stochastic(Length,KParam,DParam,STO CHASTIC_D,inv(2)));
          x_stochasticFB = AGet.stochastic(Length,KParam,DParam,STOCHASTIC_FA LSEBAR,inv(2));

          };

          if(bYellow && x_stochK_X > x_stochD_X) bUpDivergent = true;
          if(bPurple && x_stochK_X < x_stochD_X) bDnDivergent = true;

          if ((x_stochasticK < x_stochasticD) && (x_stochK_X < x_stochD_X)) ConditionforUp = true;

          if(!bUpDivergent)
          drawShapeRelative(0,BottomRow1,Shape.SQUARE,null,C olor.RGB(70,100,160),Shape.CENTER|Shape.PRESET,"UP " + getCurrentBarCount());
          if(!bDnDivergent)
          drawShapeRelative(0,BottomRow1,Shape.SQUARE,null,C olor.RGB(70,100,160),Shape.CENTER|Shape.PRESET,"Do wn" + getCurrentBarCount());

          if ((x_stochasticK < x_stochasticD) && (x_stochK_X < x_stochD_X))
          ConditionforUp = true;
          if((ConditionforUp) && (x_stochasticK < x_stochasticD) && (x_stochK_X > x_stochD_X) ) {
          bDnDivergent = true;
          ConditionnormUp = false;
          drawShapeRelative(0,BottomRow1,Shape.SQUARE,null,C olor.RGB(50,0,169),Shape.CENTER|Shape.PRESET,"DOWN " + getCurrentBarCount());
          } else if(bDnDivergent && x_stochK_X > x_stochD_X){
          drawShapeRelative(0,BottomRow1,Shape.SQUARE,null,C olor.RGB(101,0,169),Shape.CENTER|Shape.PRESET,"DOW N" + getCurrentBarCount());
          } else if(x_stochK_X < x_stochD_X) bDnDivergent = false;

          /*
          if(stochK(14,3,3,inv(1), -1) > stochD(14,3,3, inv(1), -1) &&
          stochK(14,3,3,inv(2), -1) > stochD(14,3,3, inv(2), -1) && x_stochasticK) > x_stochasticD) && x_stochK_X) < x_stochD_X){
          bDnDivergent = true;
          drawShapeRelative(0,BottomRow1,Shape.SQUARE,null,C olor.RGB(101,0,169),Shape.CENTER|Shape.PRESET,"DOW N" + getCurrentBarCount());
          } else if(bDnDivergent && x_stochK_X) < x_stochD_X){
          drawShapeRelative(0,BottomRow1,Shape.SQUARE,null,C olor.RGB(101,0,169),Shape.CENTER|Shape.PRESET,"DOW N" + getCurrentBarCount());
          } else if(x_stochK_X) > x_stochD_X) bDnDivergent = false;

          if(stochK(14,3,3,inv(1), -1) < stochD(14,3,3, inv(1), -1) && stochK(14,3,3,inv(2), -1) < stochD(14,3,3, inv(2), -1) &&
          x_stochasticK) < x_stochasticD) && x_stochK_X) > x_stochD_X){
          bUpDivergent = true;
          drawShapeRelative(0,BottomRow1,Shape.SQUARE,null,C olor.RGB(255,255,0),Shape.CENTER|Shape.PRESET,"UP" + getCurrentBarCount());
          } else if(bUpDivergent && x_stochK_X > x_stochD_X){
          drawShapeRelative(0,BottomRow1,Shape.SQUARE,null,C olor.RGB(255,255,0),Shape.CENTER|Shape.PRESET,"UP" + getCurrentBarCount());
          } else if(sx_stochK_X < x_stochD_X) bUpDivergent = false;
          */

          return [stochK(14,3,3,inv(2)), stochD(14,3,3,inv(2))];
          }

          Comment


          • #6

            Hello hama123,
            I haven’t paid for the advance GET entitlement, so I can’t run the code that you wrote, nonetheless there are some things that that I’d like to point out. In the code that you put on the forum, there are several things that I don’t understand and other things that I think you need that are missing.

            To use AGet, I think that you need to add the entitlement to it in preMain:
            addEntitlement("AGST", "Not entitled for Advanced GET Studies");

            In your bInit statement, you never set bInit to true, so your series objects are continually being recreated.

            In your usage of the series objects, you are using various comparison operators (<, >) to compare 2 series objects. Series objects contain the values of a variable for all of the bars on a chart. So you can’t use “x_stochK_X < x_stochD_X” to compare those 2 values, instead you have to use x_stochK_X.getvalue(0) < x_stochD_X.getvalue(0) to compare the current zero index bar for these variables, and since you’re using them in more than one place, I’d suggest that you add some new variables such as “var n_stochK_X = null” that you declare in a BARSTATE_ALLBARS or bInit statement, and then set n_stochK_X = x_stochK_X.getvalue(0) elsewhere in main to access the current bar’s value of K.

            For some reason, above the “if(!bUpDivergent)” statement, you have:
            if ((x_stochasticK < x_stochasticD) && (x_stochK_X < x_stochD_X)) ConditionforUp = true;
            and below the “if(!bDnDivergent)” statement you have the exact same thing???

            As to how ConditionforUp ever gets assigned to true, I guess that I don’t know, but considering what I’ve written above, I would think that it would still be null. I would expect the code to draw a blue bar on the chart and to do nothing else...I hope that this helps!

            Comment


            • #7
              Thank you so much for your assistence,

              I have taken all of your suggestions and implemented them into the efs, it helps but am still struggling with how to establish the initial condition, where Condition = ConditionforUp is assigned true. Any thoughts on why;
              if ((x_stochasticK < x_stochasticD) && (x_stochK_X < x_stochD_X)) ConditionforUp = true;
              doesn't work when I get to the if statement that utilizes the var ConditionfoUp ?
              Still working with various other concepts, but with no success. Is it possible to input the results from previous timeframes into a table, and compare current period result with data within the table ?

              Thanks again for any suggestions or feedback

              Comment


              • #8
                Hello hama123,
                I just noticed in your code from your reply on 02-06-2020, 01:46 PM that you never set
                ConditionforUp to false, instead where you mean to set ConditionforUp = false you have
                ConditionnormUp = false
                , so once
                ConditionforUp
                = true it never changes. I also notice that you have
                var ConditionforDn = null as a global variable that you don't use...maybe you have other plans for it? I think that most programmers capitalize the first letter in multiple-word variable names for the ease of reading it, I think that it would have made it easier for you to find your mistake if you had
                ConditionForUp and ConditionNormUp in your code.
                ConditionNormUp
                isn't declared or used anyplace else in your code. Let me know if this helps you...good luck!

                Comment


                • #9
                  One other thing that I forgot to mention, when you have a situation where you're sure some variable isn't getting the proper assignment, put that variable in the "Find and Replace" search box so as to see everywhere that it gets assigned a value, if you would have done this you would have seen that it only gets assigned to true due to an error where you typed the wrong variable name.

                  Comment

                  Working...
                  X