Jump to content
Medved Trader Forums

Pivot values incorrect in Advanced Mode


Recommended Posts

Hi guys,

I generated an Advanced Paintbar, which is trying to access various Pivot point values  in my Intraday chart, where I added a Pivot Point Daily Indicator.

In C# code, I created variables to represent the various Pivot Points.  As an example,

Var Name: PivotR1

Indicator: Pivot Point (Intraday)

Param: D (Daily)

Value Name: R1

When I access the values of this variable, PivotR1 in this case, the value I get doesn't come close to the R1 value displayed on my intraday chart.   I used the LogFile() print function to display the values in my DBGVIEW.EXE output window at particular time junctures.

My desired result is to obtain various Pivot point values in a given trading day, where these values generated will equate specifically to the those Pivot point values for that trading day, as indicated on my Intraday chart.

Am I assuming something wrong here, or is this a bug????

Link to post
Share on other sites

OK guys, here's the deal:

I loaded Jerry's fix this morning (thanks for the quick turnaround), but values are still quite skewed, so the fix didn't seem to work.

However, I read Mike's first Email last night before I went to bed, which he subsequently overwrote, that told me to use:

SetDaysNeeded(3);   at the top of my main procedure.

That, in fact, worked.  As a matter of fact, it fixed the issue for my entire data set (several months' worth), not just 3 days.  So, with this fix, all Pivot points seem to work fine now.

Given that fix, a corollary issue is that variables I create for both "Today's High" and "Today's Low" are not providing me with values, and are displaying in log as "NaN" (not a number).  For example,

Variable:  PivotTH  (today's high)

Indicator: Horizontal Line (Intraday)

Param: H-High, Value=High

Value Name: Line

"Previous High" and "Previous Low" are calculated and displayed fine.

Link to post
Share on other sites

OK, resolved the "Today's High" and "Today's Low" issue above.  I had the "Show Last Day Only" checkbox flag inadvertently checked.

So, only issue remaining is why the Pivots values are only calculated properly in Advanced Mode when  SetDaysNeeded(x) call is made.

Link to post
Share on other sites
Posted (edited)

Here's a corollary bug that I found today, which makes Pivot point values for the Current Bar unattainable with real-time Paintbars.

In an Advanced Paintbar, I declare variables for pivot points (R4,R3,R2,R1,Pivot,S1,S2,S3,S4).  They are declared as Pivot Point (Intraday), and the period is "Daily".

When I access the variable values in code, during a Paintbar backtest, these values are set correctly.  I verified with LogString().  I use the SetDaysNeeded(x) call noted above, to force these values to correctness.  However, when I run the Paintbar in real-time during trading hours, the current values of all of the aforementioned PivotPoints for the Current Bar return "NaN" (not a #).  I tried commenting out the call to SetDaysNeeded(x) in my code, but this made no difference at all; in real-time these values are still coming back as "NaN".

Thanks in advance for looking into this further.

P.S.  For Horizontal Line values like Today's High, Yesterday's Low, etc., variables of Horizontal Line (intraday) were fine in real-time.  Also, not that I think it should matter, but I was using Instrument @MESU20, with 1 point Range Bars.

P.P.S. I'm running V1.1.9150.8 that Jerry sent me last week.

Edited by Doug Hayman
Link to post
Share on other sites

Similar to above, I'm also getting "NaN" for Current Bar values for Intraday Pivot Points for both Camarilla Pivots and Woodies CCI Pivots as well, during real-time trading. Values during non-real-time backtest do yield values however, similar to behavior noted above.

Quite unrelated (but I'm putting it here), I'm also getting "NaN" for "Woodies ChopZone" and "Woodies Sidewinder" variables for ALL bars.  Advanced Paintbar mode is allowing me to expose variables of these type as Double, but perhaps they shouldn't haven't been exposed as variables???

Again, proving all via LogString() calls.

Link to post
Share on other sites

Hi Mike,

I am running latest Beta version that was put out yesterday, and the notes say that some Pivot issues were addressed.

Just want to confirm with you that this thread's issues have not been addressed yet; the problems noted above still exist.

Thanks,

Doug

Link to post
Share on other sites
46 minutes ago, Mike Medved said:

Doug, when you say you're running it in real time as 1 point Range Bars - you mean you're running it as a paintbar in a chart?

Mike,

I'm running it as a paintbar in a chart, the range bar size is irrelevant.   When I declare variables in the paintbar for any pivot points (R4,R3,R2,R1,Pivot,S1,S2,S3,S4), and attempt to access the values of those variables for the most current bar during Live Trading, those values come up as "NaN".  The value for those variables for any bar prior to the current bar, come back fine with values.  

The simple way to test this is to declare a variable for say Pivot Point S1 (call it PivotS1), and print out its value via LogString(PivotS1.ToString().  Run the paintbar during Live Trading hours (that is, in real-time), and you'll see that the value of PivotS1 will have correct values for all Bars except for the most Current Bar, which is displayed with a value of "NaN".  If you run the Paintbar in a non-real-time scenario, all the Pivot variable values are returned fine, including the most recent bar.  The problem only manifests with the Current Bar during live trading only.

Does that make sense?

Link to post
Share on other sites

OK, I narrowed it down to the lowest common denominator.  MESU20 - using either range bars OR regular candles - the behavior is the same.  Sometimes the value of S1 is displayed correctly, and other times it is displayed as "NaN".   With Range Bars specifically, range bars of size 1 or 2 always yielded "NaN'.  Range bars of size 4 or 8, yielded correct values 50% of the time.  With regular candles, it was always 50/50, regardless of candle durations that I tested.  Here's what sample Debug log session yielded with Range Bar Size 4:

00000033    3.22817302    [32912] MT: 16:05:34.57146 72104: PAINTBAR: PB=PLCSGOXIDL: NaN     
00000034    3.22916627    [32912] MT: 16:05:34.57146 65188: PAINTBAR: PB=CUKLEGXLBX: 3480.83333333333

Here's the paintbar that I used.  Again, the problem only occurs with the Current bar/candle; I don't see this issue with completed bars/candles.

// Var Name: "PivotS1" contains Pivot Points (Intraday)(D).S1


public void MainCalculation()
{   
    // TradingSessionInfo session = GetTradingSessionInfo(Timestamp);
    
LogString(PivotS1.ToString());

}

 

Link to post
Share on other sites

Hate to be the bearer of bad news, but I'm using yesterday's provided bug fix release (1.1.9155.7) today, and problem has resurfaced.   @MESU20 with range bars size 2, using my test Paintbar above.   Current bar/candle value displaying as "NaN" again.   Very weird, as yesterday afternoon this bug fix was working OK.

Could it have anything to do with the timing of Pivot calculation rollover time perhaps?

Link to post
Share on other sites

Sorry to be piling on here, but Daily MT Pivots seem to be differing somewhat from standard Classic Pivots as defined for ES/MES at:

https://www.mypivots.com/dailynotes/symbol/1358/-1/e-mini-sp-500-future-september-2020

Is the MT "Pivot Points" indicator predicated on the Classic formula or something else?

Definition of 'Classic Pivot Points'

The formula used in the calculation of Classic Pivot Points are:

R4 = R3 + RANGE (same as: PP + RANGE * 3)
R3 = R2 + RANGE (same as: PP + RANGE * 2)
R2 = PP + RANGE
R1 = (2 * PP) - LOW
PP = (HIGH + LOW + CLOSE) / 3
S1 = (2 * PP) - HIGH
S2 = PP - RANGE
S3 = S2 - RANGE (same as: PP - RANGE * 2)
S4 = S3 - RANGE (same as: PP - RANGE * 3)

Thanks again.

Edited by Doug Hayman
Link to post
Share on other sites

as far as pivots being different, you have to compare apples to apples - I found that to be the main reason for differences. In MT the pivots are calculated on the data on the chart. So, if your timeframe on the MT chart is different than the timeframe on whatever you are comparing to, the results will be different. Try with both CME GLOBEX and "CME GLOBEX Reg Hours" timeframe.

Link to post
Share on other sites

Jerry,

Thanks for your input on this.  I understand what you are saying.  So, I am comparing MyPivots Classic values (used by the big boys using formula above) versus what's on my chart using the the 2 timeframes you mentioned, plus "24/7"  My charts have all
available data. Here are the differences for today (9/2) for @MESU20, based on 9/1 EOD values:

Pivots  Classic        MT-CME-Globex    MY-CME-Globex-Reg-Hours    MT-24/7
R4       3651.00        3606.07                 3586.87                                      3608.34
R3       3605.25        3590.97                 3574.92                                     3593.88
R2       3559.50        3560.42                3551.46                                      3564.68
R1       3543.25         3544.96               3538.88                                      3550.22
PP       3513.75         3514.44                3515.28                                       3520.81
S1       3497.50         3499.31                3503.26                                      3506.18
S2       3468.00        3469.14                3479.73                                      3476.93
S3       3422.25        3453.33               3467.68                                      3462.79
S4       3376.50        3423.30               3444.03                                      3433.54

"CME-Globex" #'s are close to Classic values, except for R3/R4 and S3/S4.  I know we rarely trade in those ranges, but what would you attribute these differences to?

Also, here's one observation I just made.  I was using MT-CME-Globex for trading all along, and went to chart for all 3 above to obtain values, and I did MT-CME-Globex #'s above first.  After jotting down the other 2, I went back to MT-CME-Globex, and
noticed that several of the #'s above were slightly different.

I observed this, and it looks like that you may be calculating (or adjusting) these Daily Pivots dynamically at some point (maybe after every N bars/candles complete???), because they are changing slightly dynamically.  This could be the reason for the differences (1-2 points in some cases) on R1 and S1 values, for example.

Link to post
Share on other sites

Doug, about the PP values - the easy way to find out what is going on is: put in horizontal lines for daily Prev Close, High, Low, Open. Those will show you what those values are on your chart. Then use those values to calculate the PP values - they should match exactly what MT is showing. Then look which of those values is different in your other formula that gives a different value.

 

Link to post
Share on other sites

Thanks, Mike, good idea.  So I compared OHLC used by MyPivots to the MT OHLC values, and all are the same except for Close for some reason - this could easily be a function of what my IB feed uses as Closing Price vs. the feed that MyPivots uses, and that could easily explain the small discrepancies for R2, R1, PP, S1, and S2, when looking at the CME-Globex values vs. MyPivot values above.  No issues with that.

Still 3 questions though regarding PP values:

1) S3/S4 and R3/R4 values are still way off, between MyPivots vs. MT.  Are you using the Classic calculations for these, as noted above, or something different than that for these high range pivots?

2) Why are MT Daily PP values drifting over time during the trading day, and not remaining static throughout the trading day, as noted in my prior post? 

3) Open issue of "NaN" values rendered for PP variables in Current (non-completed) bar/candle; although sometimes it works, sometimes it doesn't.  I'm at a loss for explaining this "non-determinism" :)

Thanks again for your insight here.  My day-trading strategy makes heavy use of Advanced Paintbar logic and price action around Pivot Point values.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...