Announcement

Collapse
No announcement yet.

is I don't use setComputeOnClose() accuracy of MA's not consistent...

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

  • is I don't use setComputeOnClose() accuracy of MA's not consistent...

    Hello,

    I've created an oscillator that makes use of a couple of moving averages. I like the fact that (if I rem out setComputeOnClose()) the indicator dynamically reflects the current action synonymous with the current bar on the chart...(aka 'real time').

    In other words as the 5 min bar is forming the oscillator (in turn) reflects that movement dynamically. The problem is, I've noticed that the moving averages don't paint - in the oscillator - accurately, unless I use setComputeOnClose(). I assume what is happening is that the oscillator is recording the price action just prior to the close...not the price action synonymous with the close itself. Thus looking at the chart after the fact, the oscillator (and it's moving averages) are in places not synonymous with the chart.

    Is there any way of ensuring the price action of the close is included in the calculations of the oscillator while still allowing the oscillator to fluctuate 'real time' with the formation of the bar...without using setComputeOnClose()?

    Any help is much appreciated,

    gg

  • #2
    Re: is I don't use setComputeOnClose() accuracy of MA's not consistent...

    gg
    Post the efs and someone may be able to help you
    Alex


    Originally posted by gguindon
    Hello,

    I've created an oscillator that makes use of a couple of moving averages. I like the fact that (if I rem out setComputeOnClose()) the indicator dynamically reflects the current action synonymous with the current bar on the chart...(aka 'real time').

    In other words as the 5 min bar is forming the oscillator (in turn) reflects that movement dynamically. The problem is, I've noticed that the moving averages don't paint - in the oscillator - accurately, unless I use setComputeOnClose(). I assume what is happening is that the oscillator is recording the price action just prior to the close...not the price action synonymous with the close itself. Thus looking at the chart after the fact, the oscillator (and it's moving averages) are in places not synonymous with the chart.

    Is there any way of ensuring the price action of the close is included in the calculations of the oscillator while still allowing the oscillator to fluctuate 'real time' with the formation of the bar...without using setComputeOnClose()?

    Any help is much appreciated,

    gg

    Comment


    • #3
      Here it is...again thanks for the help...

      gg
      Attached Files

      Comment


      • #4
        Hi gguindon,

        This section of code is problematic in that you are setting a length property of the array like it was an array element. Try removing the .length[x] with array brackets and replace with [x].



        PHP Code:
        if (bGatorInitialized == false) {
         
        nGatorStudy1 = new MAStudy(Period10"HL/2"MAStudy.SIMPLE);
         
        nGatorStudy2 = new MAStudy(Period20"HL/2"MAStudy.SIMPLE);
         
        nGatorStudy3 = new MAStudy(Period30"HL/2"MAStudy.SIMPLE);
         
        nGatorStudy4 = new MAStudy(Period40"Close"MAStudy.SIMPLE);
         
        nGatorStudy5 = new MAStudy(Period50"Close"MAStudy.SIMPLE);

         for (
        0aGatorJaws_All.lengthx++) {
         
        aGatorJaws_All.length[x] = 0;
         }
         for (
        0aGatorTeeth_All.lengthx++) {
         
        aGatorTeeth_All.length[x] = 0;
         }
         for (
        0aGatorLips_All.lengthx++) {
         
        aGatorLips_All.length[x] = 0;
         }
         for (
        0aPurpleLine_All.lengthx++) {
         
        aPurpleLine_All.length[x] = 0;
         }
         for (
        0aTurquoiseLine_All.lengthx++) {
         
        aTurquoiseLine_All.length[x] = 0;
         }

        This is where I stopped looking at the code, figured this needed fixed first, hope this helps.


        Originally posted by gguindon
        Here it is...again thanks for the help...

        gg

        Comment


        • #5
          OK - so I've changed the code so that every place in which we should be referencing the array element directly, we are doing so (as opposed to including the length property in that reference)...but the issue still exists.

          If I uncomment setComputeOnClose() the difference between the placement of the ma's in this script compared to the placement of MAs from a script without this edit, is apparent (evidenced most easily on a 1 minute chart for instance).

          Any ideas about how to address this?

          Greatly appreciate your help stevehare2003,

          gg
          Attached Files

          Comment


          • #6
            Actually found another area where length was being referenced inappropriately.

            Fixed (I think) but still discrepancy between simple close MAs when setComputeOnClose() included or not.

            gg
            Attached Files

            Comment


            • #7
              Hi gguindon,

              You are most welcome, This is very complex code that seems to be previously written to work only if run with computeOnClose chosen. This will take a ton of time to troubleshoot properly such that it would work 'live' and not set to computeOnClose.

              I cleaned it up a bit and commented in some areas. The big thing that I saw was that you are populating arrays in a manner that populate the entire array with values from the current developing bar (every tick it cycles main if not computeOnClose), which is entirely different when computeOnClose is chosen.

              While this alone is an explanation for what you are seeing. There are also several other areas where this comes into play as well.

              Hope this helps you straighten things out.
              Attached Files

              Comment

              Working...
              X