Announcement

Collapse
No announcement yet.

offsetSeries question

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

  • offsetSeries question

    Attached is the code using offsetSeries and found null value return at some point. I use tick playfile and 3 minutes bars and return null values after 2 days charts. I am not sure whether it also have the same problem during live session. Here is the result.

    ema34 --- 670.5849210211504
    ema343 --- 670.6638252300194
    ema34 --- 670.6029255342276
    ema343 --- 670.6830352168754
    ema34 --- 670.6313297894145
    ema343 --- null
    ema34 --- 670.6638252300194
    ema343 --- null
    ema34 --- null
    ema343 --- null
    ema34 --- null
    ema343 --- 671.6423865546218
    ema34 --- null
    ema343 --- 671.4913930372148
    ema34 --- 671.7964705882353
    ema343 --- 671.3433134350882
    Attached Files

  • #2
    jchyr
    I am guessing that the symbol you were using in Tick Replay was the mini Russell. If that is not what you were using please indicate what the symbol was and for what period. Anyhow I ran your efs on that symbol over the last 10 days of playback data and could not replicate the issue you are reporting.
    FWIW in looking at the snippet of output you posted it would appear that you are showing a point in the output file in which you either jumped forward with Tick Replay or you reloaded the efs. Either way that output is based on the efs using historical data and not in real time playback else the return from the offset ema would always be null since you are displacing it backwards.
    You may want to try running your test again but first add a getCurrentBarIndex() inside each debugPrint statement so that it will provide more information as to when this issue may be happening. Also clear the Output window before running the test (to clear the Output window right click it and select Clear). If you are still seeing the same problem then you may want to post specific details as to how you are performing your test
    FWIW the following is what I show in the output window when the efs is running in real time (or in Tick Replay)
    Alex

    Comment


    • #3
      Alexis,

      I am using emini Russell. I have the same problem for live data that ema343 and ema34 turn into null value after few seconds later. In fact, I notice the ema34 is not 643.74, it should be around 669 instead.




      ema34 --- null
      ema343 ---null
      ema34 --- null
      ema343 ---null
      ema34 --- null
      ema343 ---null
      ema34 --- null
      ema343 ---null
      ema34 --- null
      ema343 ---null
      ema34 --- null
      ema343 ---null
      ema34 --- null
      ema343 ---null
      ema34 --- null
      ema343 ---643.7466386554622
      ema34 --- null
      ema343 ---643.6982593037216
      ema34 --- null
      ema343 ---643.6469302006518
      ema34 --- 643.7466386554622

      Comment


      • #4
        jchyr
        Are the values you are showing the ones at the top of the formuloaoutput.txt file?
        If that is the case those are the values at the beginning of your chart. If you want to see the current values you need to scroll down to the end of the file.
        Please add the getCurrentBarIndex() to each debugPrint statement as I suggested in my prior reply
        Alex

        Comment


        • #5
          Alexis,

          You show that the output ema343 is null value also. I assume it should be a value near to ema34. In fact, the ema34 should be around 669 instead 640.

          Comment


          • #6
            Here is the most current output. it is at the end of the output


            ema34 --- 669.3958515825967
            ema343 ---669.3971386197966
            ema34 --- 669.3846600635912
            ema343 ---null
            ema34 --- 669.3969652028146
            ema343 ---null
            ema34 --- 669.4085671912252
            ema343 ---null
            ema34 --- 669.4652204945837
            ema343 ---null
            ema34 --- 669.5186364663218
            ema343 ---null
            ema34 --- 669.574714382532
            ema343 ---null
            ema34 --- 669.6161592749587
            ema343 ---null

            Comment


            • #7
              what is getcurrentbarindex() to do with ? Please give me detail to debug this.

              Comment


              • #8
                jchyr

                You show that the output ema343 is null value also.

                Yes of course because that ema is displaced backwards so on the bar currently processed there is no value (see following image with comments)



                I assume it should be a value near to ema34.

                Yes it will be but 3 bars back ie the amount of negative offset you have applied.
                If you want to see in the Output window what the last value is for ema343 you would need to use ema343.getValue(-3) in the debugPrint statement. If instead you return the current value it will always be equal to null.

                what is getcurrentbarindex() to do with ?

                getCurrentBarIndex() will indicate what bar is being referenced in the Output window.
                Below is the code used in the chart.
                Alex

                PHP Code:
                function preMain() {
                    
                setStudyTitle("offset");
                    
                setPriceStudy(true);
                    
                setDefaultBarFgColor(Color.blue,0);
                    
                setDefaultBarFgColor(Color.red,1);
                    
                setDefaultBarThickness(2,0);
                    
                setDefaultBarThickness(2,1);
                    
                setComputeOnClose(); 
                }

                function 
                main() {

                    var 
                ema34 ema(34);
                    var 
                ema343 offsetSeriesema34 ), -);
                 
                    
                debugPrint(getCurrentBarIndex()+" ema34 --- " ema34 "\n");
                    
                debugPrint(getCurrentBarIndex()+" ema343 --- " ema343 "\n");

                    return new Array (
                ema34,ema343);

                Comment


                • #9
                  It works fine in the backtest. I think this is what I try to understand the offsetseries(ema(34),-3) is looking for the future bar. instead look in the pass, should be offsetseries(ema(34),3).

                  If I am wrong, please correct me.

                  Comment


                  • #10
                    jchyr
                    That is correct.
                    Alex

                    Comment

                    Working...
                    X