Pivot Points (High & Low): How does Wealth Lab Evaluate?
Author: rmpwealth
Creation Date: 12/9/2009 3:56 PM
profile picture

rmpwealth

#1
ATP has two indicators -- Pivot Point High and Pivot Point Low -- that are not included in WLP's standard indicators; however, I understand that I can create these indicators in WLP by cutting/pasting code from the WL\Help\Program Guide.

My question is: If I do so, how will that code evaluate the Pivot Points when backtesting trades -- will the program move forward in time evaluating each day at a time in sequence or will it simply pick "historical" Pivot Points? For example: Suppose my strategy is to Buy as soon as a new PP Low appears, and Sell as soon as a new PP High appears, disregarding future lower lows and higher highs. The day that a new PP High/Low first appears will not be the final PP High/Low for that cycle because prices on subsequent days may be higher/lower. When viewing PP data in ATP, all PPs prior to the current PPs are the FINAL points of each cycle; but obviously such data would not be available to be used in "real time".

If Wealth-Builder's PP program program evaluates only those same FINAL historical PP High/Lows, the backtest result will be outstanding, but would not be attainable in actuality. However, if the program evaluates and/or calculates the PP's on a daily basis chronologically, and if it can execute its hypothetical backtest trades the FIRST TIME a new PP High/Low signal appears, it would closely resemble my real-time scenario. How does Wealth-Builder's Pivot Point code evaluate its data? Does it make its evaluations chronologically, or does it simply evaluate the overall High/Low data (i.e. -- @Max/Min for each 10 day period)?
profile picture

Cone

#2
When backtesting, you create and test indicators that are known to be valid as of the current "bar", as if you were seeing it in realtime. Any other way is peeking. As you've said yourself, Pivot Points are peeking indicators, so you can't use them in a trading Strategy except to act on them once they have been finalized on some bars later.
profile picture

rmpwealth

#3
Hi, Cone; thanks for responding.

I have a lot to learn regarding proper terminology <G>

From your post, I understand the following:

1. "... test indicators that are known to be valid as of the current "bar"...." I interpet this to mean that in general the program does in fact iterate along a timeline in chronological order, interpeting each day's data in order (and not "peek" into the future unless told to). Correct?

2. "... Pivot Points are peeking indicators..." I interpet this to mean that PP calculations DO look forward as well as backward (this is consistent with the ATP definition of PPs). Correct? Therefore, WB probably cannot accurately backtest a PP trading strategy.

Question: If PPs "peek" forward, how does ATP calculate the values of the "current" PPs that seem to appear in real time? Does ATP somehow ignore future values, and if so, how? Or is the PP value that appears as "current" really just a calculation of the Max/Min of the most recent 10 periods data (or 5 periods, or whatever)? If the latter, then that particular calculation would not be an accurate calculation of a PP, would it? However, I don't think this is what ATP is doing, because I tried to duplicate ATP's numbers manually using various "previous #-period Max/Min", and was not able to get the same values that ATP showed. Do you know how ATP calculates its "current" PPs? It could be that the method ATP uses to calculate is "current" PPs is not calculating PPs per se, but it may have value anyway as an indicator.
profile picture

Cone

#4
1. It does if you program it properly to do it that way. You can peek if you want to.

2.
QUOTE:
Therefore, WB probably cannot accurately backtest a PP trading strategy.
Nonsense. It's up to you to program the Strategy. If you do it properly then it will be accurate. The same pivot point can be given a different value as of the current bar, just like any other indicator.

I don't know how ATP calculates Pivot Points, but if someone can give me an accurate definition that I can use to program them, then we'll take care of this once and for all.
profile picture

Cone

#5
My memory is shot, but I knew we talked about ATP Pivot Points before: click here.

After reading that definition again, there's no useful way to trigger trades on new highs or lows and expect a reversal - until the reversal has already occurred. In that sense, the Peak.Series and Trough.Series (and PeakBar, TroughBar) indicators are more useful since these actually tell you where the peaks and trough reversals occurred in the past (as of the current bar) based on the reversal percentage or points you specify.
profile picture

ss161

#6
fwiw, i created a pivot point function that replicates Fidelity's and optionally does not peak forward.

the function call is a follows:
CODE:
Please log in to see this code.


to create a PivotHigh it would be called as follows:
CODE:
Please log in to see this code.

the first parameter set to true indicates a Pivot High (vs false = a Pivot Low), the 5 refers to how many days from today to look backward and forward (so 11 days/bars in all) and the third paramter, boolean Tradeable, is set to false to have the indicator peak ahead (invalid for trading system purposes) like Fidelity's does. If Tradeable is set to true, then the indicator only looks backwards, and trades could be entered based on the indicator being true or false.

The result of calling the function returns a DataSeries that is set to 0 if it is not a Pivot Low or High or 1 if it is a Pivot Low or High (depending on which result was asked for).


Here's the all the different permutations:
CODE:
Please log in to see this code.


and the code.

CODE:
Please log in to see this code.

profile picture

Cone

#7
Great effort ss161, thanks. Here's a small contribution for the eye candy.

CODE:
Please log in to see this code.
profile picture

ss161

#8
thanks. i've not used System.Text that's pretty cool.
profile picture

rmpwealth

#9
I am not a programmer, so am unable to determine what the above programs do.

The following is what I'd like to do. Can this be done in WB?

OVERVIEW:

I want to use a Pivot Point based concept as a strategy to backtest and trade equities.

NOTE: This strategy will not use the actual formulae for calculating Pivot Point (H/L)s; and because of this, it probably will be confusing to continue to refer to it as a PP Strategy. Therefore, I will refer to the strategy as a "Current" Pivot Point (CPP) Strategy.

DEFINITIONS:

CPP for each bar: The standard (H+L+C)/3.

Calculation of CPP(H) and CPP(L): The algorithm that ATP uses to calculate PP(L)s and PP(H)s in general is to evaluate 11 PPs for each bar -- the 5 most recent backward-looking PPs, plus the current PP, plus the next five forward-looking PPs. If the current PP is the highest of the 11, a PP(H) arrow is plotted; if the current PP is the lowest of the 11, a PP(L) arrow is plotted.

However, since forward-looking components are not available in "real time", the above algorithm cannot be used. When ATP plots its current (i.e. – "real time") PP(H/L)s, it ignores the forward-looking PPs and evaluates only the 5 most recent backward-looking PPs plus the current PP. If the current PP is the highest of those 6 PPs, a current PP(H) arrow is plotted; if the current PP is the lowest of the 6 PPs, a current PP(L) arrow is plotted.

My proposed strategy would be to utilize PPs the way that ATP calculates its "real time" PPs (i.e. – using only the 5 most recent backward-looking PPs plus the current PP, and ignoring the 5 forward-looking PPs). {Comment: Is this what ss161 has done above?}

Vested Position (VP): This is an status evaluation flag, and can be either "Cash" or "Long" (or True/False, etc.)


STRATEGY (Basic):

A Buy Signal would be generated if the VP is "Cash", and if the Current Price passes upwards through a CPP(L) from below. NOTE: When a Buy Signal is generated, the VP flag must be changed to "Long" to prevent the program from continuing to buy the equity on subsequent bars if the Buy criteria continue to be satisfied.

A Sell Signal would be generated if the VP is "Long", and if either (a) the Current Price drops below a User-defined StopLoss percent, or (b) the CurrentPrice drops below a CPP(H) from above. When a Sell Signal is generated, the VP flag must be changed to "Cash".


STRATEGY (Necessary Refinements):

From my manual calculations using this strategy, too many SELL Signals are generated by StopLosses, resulting in trading losses even though Current Prices usually eventually do turn upward. Simply increasing the StopLoss values does not resolve the problem – the problem is that the BUY Signals are generated based upon the first CPP(L), even though the CPP(L) signal curve still may be sloping downward. What is needed is a method to let the CPP(L) curve finish dropping before generating a BUY Signal.

My suggestion is to track and/or plot each bar's CPP(L)s as calculated above for a User-Defined number of most-recent bars, and to not issue a Buy Signal until the Current Price has risen above the lowest of the evaluated series of CPP(L)'s by a User-Defined percentage.

The same concept would be applied to Sell Signals: Track a series of each bar's CPP(H)s, and not issue a Sell Signal until the Current Price has dropped below the highest evaluated CPP(H) by a User-Defined percentage.

NOTE:

Trades must occur in "real time" as soon as a signal appears; trades cannot wait until end-of-day or next-open. Backward-looking data bars can be end-of-day daily data; but for trades, the Buy/Sell criteria must be continuously evaluated in real-time. If WB doesn't update its data on a continuous basis like ATP does, I don't mind entering the real-time data manually at various times during the day.


Can this strategy be implemented in WB, either by utilizing existing elements or by writing special code or by a combination of both?

profile picture

rmpwealth

#10
Not being a programmer, I am really struggling.

1. I tried to accomplish the above by generating Rules-based strategies using (a) Peak & Trough and (b)PeakBar & TroughBar as suggested above (i.e. -- Buy @ Market when Price was 1% above Trough (or Troughbar); Sell @ Market when Price was 1% below Peak (or PeakBar), but no trades were generated, so I must not have done it correctly.

2. Do ss161's and Cone's above programs do what I am trying to do? If so, how do I install and use them?
profile picture

Eugene

#11
QUOTE:
how do I install and use them?

See WealthScript Programming Guide > How to Run Example Code.
profile picture

Cone

#12
QUOTE:
{Comment: Is this what ss161 has done above?}
It is if you pass true as the boolean parameter Tradeable to the PivotPoint method.

QUOTE:
From my manual calculations using this strategy, too many SELL Signals are generated by StopLosses, resulting in trading losses even though Current Prices usually eventually do turn upward.
This is very typical of strategies that use tight stop losses. Stop losses quite (most?) often have a negative influence on total return.

QUOTE:
Can this strategy be implemented in WB
What's WB? If it's Wealth-Lab, sure, probably. You'll have to overcome 2 challenges, 1) find a programmer willing to do this for you, and, 2) making them understand the requirements. Once that happens, you're probably going to find that the strategy doesn't do well at all, and then you'll want to make more and more refinements. It will be a long process requiring several hours of someone's time.

Are you able to run the code that I posted?
profile picture

rmpwealth

#13
Thanks, Eugene and Cone! Per the Programming Guide, I pasted Cone's code from 12/11/09 into a new Strategy Window, compiled it, and the code appears to work except for one thing -- no trades were generated.

The parameters that I entered in the upper left dialogue box are: Symbol = SPY; Scale = Daily; DataRange = Most Recent 24 Months; PositionSize = RawProfitMode/FixedDollar/10000. The Curve appears to be properly rendered, including what appear to be the expected PPH and PPL red and green arrows in what appear to me to be in essentially the correct locations; however, no trades were generated. Any idea why no trades were generated?
profile picture

Cone

#14
The code only displays the pivot points. If there were a trading strategy programmed, you'd see trading signals (BuyAtMarket, ExitAtMarket, BuyAtLimit, ShortAtStop, etc.) in the code.

Notice that the "strategy" (Execute procedure) is only 3 lines of code. The PP work is done for you in the PivotPoint function. You only need to call a simple method to return a series of 1's and 0's that indicate the bar on which a PP occurs. Using those DataSeries (one for PP High and the other for PP Low) you can write rules around it just as you would with any other indicator.
profile picture

rmpwealth

#15
Thanks for your help; I know it must be frustrating to discuss this w/a newbie/non-programmer.

QUOTE:
Notice that the "strategy" (Execute procedure) is only 3 lines of code.
My compiled code is one long line; not three lines. Does that mean anything?

QUOTE:
Notice that the "strategy" (Execute procedure) is only 3 lines of code. The PP work is done for you in the PivotPoint function. You only need to call a simple method to return a series of 1's and 0's that indicate the bar on which a PP occurs. Using those DataSeries (one for PP High and the other for PP Low) you can write rules around it just as you would with any other indicator.


I don't know how to write code, but I can use Rules. Since you already have created a PivotPoint function, is there a way to save that function as an "Indicator" so that I can create a PPH/PPL strategy using Rules instead of writing Code?
profile picture

Eugene

#16
QUOTE:
My compiled code is one long line; not three lines. Does that mean anything?

It means you're using Internet Explorer that just can't normally copy and paste code from this site as other browsers can (Firefox, Opera, Safari). Take a look here for a workaround >> copy & paste .
profile picture

Cone

#17
QUOTE:
is there a way to save that function as an "Indicator" so that I can create a PPH/PPL strategy using Rules instead of writing Code?
There is, but since you're asking us to do it, it will take time. We can put it out with the Community Indicator update in January.

(Eugene, let me work on this one more and I'll send you the .cs file to incorp. I'm thinking the PivotPoint indicator would be better as a PivotPointBar indicator.
profile picture

rmpwealth

#18
QUOTE:
There is, but since you're asking us to do it, it will take time. We can put it out with the Community Indicator update in January.


Thank you, thank you.

NOTE: A useful enhancement for experimentation, if not too much trouble, would be to include a parameter to specify the number of "lookback" bars when calculating the PPH/PPL (instead of hard-coding the standard 5 "lookback" bars). However, if that's a problem, I'll be happy to take it as is with the 5 "lookback" bars.
profile picture

Eugene

#19
Adding indicator lookback period isn't a problem.
profile picture

Cone

#20
In the method coded above, the lookback is variable. Of course we'll keep it that way for the indicator too.
profile picture

Eugene

#21
Thanks to all who contributed. Indicator added to Community.Indicators 2010.01.
profile picture

rmpwealth

#22
Thanks, guys.

I took it for a quick test drive, attempting to duplicate a strategy that I have been following manually for the past six months, but must have done something wrong. Executing the strategy manually generates trades every week or so; however, applying the strategy in W-L generated only one trade in two years.

Here is what I did. What did I do wrong?

Strategy: Buy when price crosses above PPL by 1% from below ; Sell when price crosses below PPH by 1% from above.

Rules:
Entry: Buy at Market
Condition: Price Croses x% above Indicator
Parameter: Price = Close
Indicator = PivotPointBar
Bars = 5
PPH = Unchecked, to indicate a PPL instead of PPH
Tradeable = Checked
Percent = 1.00

Exit: Sell at Market
Condition: Price Crosses x% below Indicator
Parameter: Price = Close
Indicator = PivotPointBar
Bars = 5
PPH = Checked
Tradeable = Checked
Percent = 1.00

What did I do wrong? I tried reducing both Percents to 0.00, but that generated no trades.
profile picture

rmpwealth

#23
Oops. I just realized that I inadvertedly combined two of my strategies into one in the above.

One strategy is to simply Buy/Sell as soon as a new PPL or PPH appears; there is no "% above/below".

To try this, I repeated the above but set the percent parameters to 0.05 instead of 1.00 for both the Buy and Sell, thinking this would generate trades as soon as a price crossed a new PPL or PPH, but it still did not work; no trades were generated.

I suspect that the problem is that the "Price crosses X% above/below Indicator" rule is the wrong criteria; what I do in real time is to Buy/Sell as soon as a new PPL/PPH appears (regardless of what the current price is). What rules would accomplish this?

The other strategy is to not trade on a PPL or PPH until the daily bar series for each has changed direction by X%. I haven't yet tried to do this with the new PP Indicator. Any suggestions re: what rules to to use to accomplish this?.
profile picture

Cone

#24
Aw crud, I sort of lost track of why we were implementing this for Community.Indicators - so that you could use it in the Strategy Wizard. Unfortunately, only PivotPointBar has been implemented, which probably isn't of any use in the wizard. In my way of thinking, it was the best of both worlds because once you have the bar getting the price is a simple programming matter.

Anyway, not all is lost. You should notice that the "Tradeable" PivotPoint High/Low indicator should be precisely equal to the Highest/Lowest.Series indicator. So, just use Highest/Lowest instead. Understood?
profile picture

rmpwealth

#25
QUOTE:
Anyway, not all is lost. You should notice that the "Tradeable" PivotPoint High/Low indicator should be precisely equal to the Highest/Lowest.Series indicator. So, just use Highest/Lowest instead. Understood?


Sorry, I do not understand.
profile picture

Cone

#26
For Tradeable Pivot Points...

PivotPointHigh = Highest.Series indicator
PivotPointLow = Lowest.Series indicator
profile picture

rmpwealth

#27
I created a strategy using Highest.Series and Lowest.Series as indicators instead of using PivotPointBars as indicators (using the same 5-day lookback for the Highest and Lowest that the PPH & PPL use), and the strategy did execute. However, my understanding of the definitions of Highest and Lowest is that they are NOT the same as Pivot Points. The definition of Highest & Lowest indicates that they are simply the highest and lowest values within a lookback period, which is not how PP's are calculated. Or am I totally missing the concept of what you want me to do?

Or are you suggesting that the High/Low and PP indicators be used in conjuction with each other? If so, how is this done using rules? Although I am not a programmer, but am willing to try to modify existing code if you will tell me exactly how to do so, what to type and where, etc. (it probably would be easier for you to just do it <G>).
profile picture

Cone

#28
QUOTE:
The definition of Highest & Lowest indicates that they are simply the highest and lowest values within a lookback period, which is not how PP's are calculated.
But it is how the "Tradeable" ones are calculated. ATP Pivot Points are not tradeable. The "Tradeable Pivot Points" (the ones that keep moving) are exactly equivalent to the Highest/Lowest indicators.

You've got 2 options for creating a Trading Strategy that doesn't peek using PPs.

1. If you want to use the most-recent Highest/Lowest value over a lookback period immediately, then forget about PPs altogether and use the Highest/Lowest indicators.

2. There is one way to use the non-tradeable ATP Pivot Points for a tradeable strategy: refer to their levels in retrospect. In other words, if the current bar is b and the pivot period is 5, you can reference any pivot point that is known as of b - 5 bars ago only.

Is "2" what you're after?

profile picture

Cone

#29
Here's what 2 would look like:

The plotted blue dots are the pivot point levels delayed by the look-ahead (peeking) bars that were used in determining the Pivot Points in the past. This dotted series can be useful for trading.

Notice, for example, the final PP High on the penultimate bar of the chart. This is not yet recognized as a Tradeable Pivot Point because it can change based on what occurs on the next 3 future bars.
profile picture

ss161

#30
This is from the Fidelity Active Trader Pro indicator reference manual:
QUOTE:
Pivot Point (High and Low)
Description
Pivot Points are used to show the potential reversal in chart patterns. Points are displayed based on a new
high or low resulting from the previous and/or proceeding 5 periods. Points are displayed for the time frame
selected and the periods are defined by the current frequency setting.
Interpretation
• 11 bars are needed to form a pivot point
• The 6th bar of the 11 has a high (or low) price that is greater (or less) than all other 10 bars. This will
plot the pivot point image (red or green arrow) on the tip of each bar.
An example that would cause a High Pivot Point to be displayed:
Bar 1 2 3 4 5 6 7 8 9 10 11
5.02 5.04 5.00 5.04 5.09 5.11 5.04 5.00 5.00 5.01 5.05
In this example, a red arrow would appear at the tip of the 6th bar


Based on this, it seems that both Tradeable and non-Tradeable pivots can both be referenced using Highest or Lowest series depending on which type of pivot is desired.
profile picture

Cone

#31
If that's the case, then I was mistaken about how ATP plots the pivot points. If it actually waits 5 bars to show the PP, then that's exactly what I'm showing in the previous image. The dots indicate when the PP would have been displayed and when you can use the value in a Strategy.

The problem in ATP is that when you look back in your chart, you're fooled into thinking that you would have known precisely when a PP occurred, when in fact you couldn't have know about it until 5 bars later. The "dots" indicator above clears it up.

We'll think about this some more and get the thing implemented for February.
profile picture

rmpwealth

#32
Thanks again for trying to help, Cone.

I don't think Option 2 above is what I'm looking for.

Regarding whether Highest/Lowest indicators are the same as Tradable PPH/PPL indicators, I attempted to check this by performing some manual calculations of Tradable PPH/PPL values with which to compare to results generated by Highest/Lowest indicators. However, in so doing, I discovered that there also may be a flaw in the way that the Tradable PPL and PPH symbols and values presently are being calculated herein.

To illustrate, I have compared the results of the below manually calculated Tradable PPL/PPH symbols and values to those shown on a chart generated by your above post dated 12/11/2009 (which I presume is a graphical representation of SS161's above code for a Tradable Pivot Point indicator, which in turn I presume is the code that has been incorporated into the Community Tradable Pivot Point Indicator).

MANUAL CALCULATIONS:

Daily PP Value = (H + L + C) / 3

Tradable PPL/PPH = Evaluate the 5 most recent previous PP Values plus the current PP Value (ignore the 5 forward looking PP values).

The first appearance of a Tradable PPL symbol and value would occur when a current PP value is lower than the 5 most recent previous PP values. On subsequent dates; if the next consecutive PP value is lower than the preceding, the Tradable PPL symbol would shift to that next consecutive date and that date's PP value would be shown as the Tradable PPL value. This would continue until a next consecutive PP value no longer would be lower than the previous 5 PP values, at which time the preceding Tradable PPL symbol and value would become "locked-in" as the Tradable PPL symbol and value of record. Tradable PPH would be the opposite.

To illustrate, manual calculations of Daily PP's and Tradable PPL's/PPH's for SPY during early December, 2009, using the standard 5 bar lookback period, show the following:

11/30 PP=109.40
12/01 PP=111.23
12/02 PP=111.39
12/03 PP=110.95
12/04 PP=111.14
12/07 PP=110.95
12/08 PP=109.88 Tradable PPL symbol first appears; TPPL value=109.88.
12/09 PP=109.74 New TPPL symbol replaces previous TPPL; new TPPL value=109.74
12/10 PP=110.74 No symbol appears; TPPL "locked" on 12/09 @ value=109.74
12/11 PP=111.03
12/14 PP=109.78
12/15 PP=111.42 Tradable PPH symbol first appears; TPPH value=111.42
12/16 PP=111.64 New TPPH symbol replaces previous TPPH; new TPPH value=111.64
12/17 PP=110.40 No symbol appears; TPPH "locked" on 12/16 @ value=111.64
12/18 PP=109.93

NOTE: As with all indicators, the value of the indicator (in this case, TPPH/TPPL) at a given point in time is not the same value as is value of the Price for that same point in time.

As can be seen, the above manually calculated Tradable PP symbols and values are not consistent with those shown on the above chart.

To sum up, three points/questions:

1. Shouldn't the above chart (i.e. – the one from the 12/11/09 code) be consistent with the above manual calculations? If so, and if it the chart is not consistent, does that chart's code have to be modified?

2.
QUOTE:
The problem in ATP is that when you look back in your chart, you're fooled into thinking that you would have known precisely when a PP occurred, when in fact you couldn't have know about it until 5 bars later. The "dots" indicator above clears it up.


This is true, a TPP isn't known until the sixth bar (i.e. -- the current bar) meets the TPP criteria; and the TPP can continue to change in subsequent bars so long as each subsequent bar meets the TPP criteria. Note in the above chart with the dots, however, that each group of dots appears to have the same value, whereas the values of successive TPP's will change each day (see my above calculations).

3. What is it that I want to do with all this? To start with, I would like to use Wealth-Lab's Rules wizard to build the following simple strategy: BUY as soon as possible after a first Tradable PPL (as calculated per my manual calculations above) appears; SELL as soon as possible after a first Tradable PPH appears. For this simple starter strategy, it is not necessary to address subsequent TPPs in series after the first ones appear (although, as you imply, being able to address the subsequent TPPS would enable further refinements to be made to the strategy).

Thank you again, Cone, for being so patient with a newbie.

profile picture

ss161

#33
QUOTE:

MANUAL CALCULATIONS:

Daily PP Value = (H + L + C) / 3

One part of your post confuses me. I think Fidelity's Pivot Points (based on the reference material posted above) does not use Average Price to calculate pivots, but instead uses Highs and Lows. That may be why you see differences between what you calculate manually and what is displayed by Cone's code.
profile picture

rmpwealth

#34
SS161, you are correct that if we are using different formulae we will get different results.

The standard formula for PPs is (H + L + C) / 3; and although ATP doesn't specify this formula in its Indicator Definitions, this is in fact the formula that ATP uses to calculate its PPs (ex.: Calculated Daily PP for SPY on 12/31/09 = (112.8 + 111.39 + 111.44) / 3 = 111.87; ATP Daily PP shown for SPY on 12/31/09 = 111.87). Also, please see Community Indicators thread "ATP Pivot Point High/Low Indicators", rickraphael post dated 02/01/09, which gives a pretty good description of PPs, including the formula (H + L + C) / 3.

Question regarding the issue of Highest/Lowest.Series:

I have been trying to understand our difference regarding using Highest/Lowest.Series as a substitute for Tradable PPH/PPL indicators, and wonder if there may be confusion resulting from presuming that PP values are the same as Price values – they are not. When a TPPL symbol first appears, it means that the current PP value is lower than any of the five preceding PP values; the current Price at that time may or may not be the lowest Price of the five most recent plus current bars. Also, the date that the lowest Price value appears may or may not be the same date as the TPPL appears. Therefore, trading based upon Highest/Lowest.Series of Prices is not the same as trading based upon TPPH/TPPL indicators.

HOWEVER (and again, I am not a programmer), if when you programmers describe using Highest/Lowest.Series for this application you mean using it to determine the Highest/Lowest TPPvalues (not Price values) to determine trades, then I understand what are getting at (i.e. – using the Lowest.Series of a series of TPPL values to determine when to Buy as opposed to trading when a TPPL first appears), and think this is quite clever -- it would allow a trader to wait until a series of TPPLs finishes dropping and turns back up before executing a Buy based upon TPPLs. In fact, this was going to be a phase two refinement of my TPP Strategy after first getting the basic Strategy to work (i.e. -- simply trade as soon as a first TPPL/TPPH appears).
profile picture

ss161

#35
I disagree with how you are interpreting what ATP is doing. I'm sure you are correct that the value that is displayed when the cursor is hovered over the pivot point arrow is the Typical Price, but I don't think the Typical Price is used at all in the determination of whether or not a Pivot Point has occurred. Of course I could be wrong, but I think I found an example below that illustrates my point.

The ATP chart below has Pivot Points plotted and Typical Price as the line running through the bars. Look at the Pivot Point that occurs at 1:49pm. It is clearly a High higher than the preceding and following 5 bars (an 11 bar high), but yet, the Typical Price is not a high, the bar before is the Typical Price 11 bar high. I think to calculate whether or not a Pivot Point high or low has occurred (at least per ATP), you look at only the High and Lows of the current bar vs the preceding and following 5 bars and if a High occured on the current bar then it is a Pivot Point High, if the Low occured it is a Pivot Point Low.

Why they choose to display the Typical Price? I have no idea. I copied the language from the Indicators pdf file in full above and that was what I based the indicator on when I wrote it (btw, about 6 months ago).

Here is the ATP chart -- and I'm just trying to be helpful, not critical.


profile picture

rmpwealth

#36
QUOTE:
-- and I'm just trying to be helpful, not critical.


No offense taken. I truly appreciate your help.

Let me study this chart and get back. NOTE: The chart on the post is not "live", so I get no data when I hover my mouse. What is the definition of "Typical Price" -- is that the value of the calculated Pivot Point?
profile picture

Cone

#37
"Typical Price" is a term used by other tech analysis apps for the (H + L + C) / 3 series, which is the AveragePriceC indicator in Wealth-Lab.
profile picture

rmpwealth

#38
QUOTE:
"Typical Price" is a term used by other tech analysis apps for the (H + L + C) / 3 series, which is the AveragePriceC indicator in Wealth-Lab.


Interesting. This is the formula I have been using in my manually-calculated strategy, and is the formula I would like to incorporate into a W-L strategy. Whether or not this is the same formula that ATP uses to calculate PivotPoints is irrelevant; this is the formula that has worked for me.

I think we have been complicating things by trying to implement my proposed strategy and at the same time trying to comply with the strict definition of ATP Pivot Points. I first started referring to this strategy as a PP strategy because the strategy evolved from my playing around with ATP's Pivot Points. However, it is not necessary to comply w/ or even use ATP's PPs in order to implement the strategy if there is an easier way to do so.

The strategy is simply this:

1. Calculate a daily value = (H + L + C) /3 {It seems like "AveragePriceC" already does this.}

2. Create an "AveragePriceC"- based Indicator that incorporates the above daily value into essentially the same logic that Cone and ss161 already have written for Pivot Points (i.e. – User specified High vs. Low; number of backward-looking bars; etc.) so that the Indicator can be used with Rules to create a Strategy. NOTE: The Tradable vs. Non-Tradable variable might not be needed because this strategy should never peek; it always should use backward-looking bars only.

3. The Strategy would be as follows: BUY as soon as a Tradable Indicator (Low) first appears; SELL as soon as a Tradable Indicator (High) first appears. It is not necessary to deal with subsequent appearances and/or subsequent values of the Indicator on subsequent days unless you want to, because, at least for this strategy, BUYs/SELLs are to be generated on the first appearance of each High/Low.

NOTE: Please feel free to suggest another name for this strategy (and possibly even start a new thread) so as to no longer be confused by ATP PivotPoint definitions.


profile picture

ss161

#39
rmpwealth, Here's something to take a look at. I believe it implements the system as you described above.

Cone, I added an override to the call to PivotPoint that will optionally take in a DataSeries and if present, use that DataSeries instead of either High or Low. If you'd like, this can be added to the community indicators as well. Since this is part of my own library, I included a stub class below so that it can be used stand-alone right now.

Steve




CODE:
Please log in to see this code.
profile picture

rmpwealth

#40
Thanks, Steve!
profile picture

rmpwealth

#41
I have been playing around with ss161's above code, using SPY, and have been getting some results that differ from my manual calculations. To test the logic of the code, I manually spot checked a few trades that differed from my manual calculations, and could find no error in the logic of the code. Baffling -- then why the differences? Upon delving deeper I discovered that the data used in my manual calculations was downloaded from Yahoo Finance and pasted into a spreadsheet. For Close price, it used the "Adjusted Close" (adjusted for dividends and splits)value, which I usually use for correct continuity when looking backwards. However, I notice that ATPro and apparantly Wealth-Lab (i.e. -- my results using the above code) use unadjusted Close prices. Checking back to the Yahoo prices, I notice that although Yahoo lists Adjusted Close prices, it does not list corresponding Adjusted Open/High/Low prices; therefore, my manual calculations from that data are incorrect due to apples/oranges.

It seems that the next thing for me to do would be to download and paste into my spreadsheets the "unadjusted" Close prices in place of the "Adjusted"; but before I do that I have two questions:

1. Is using "unadjusted" Closing prices standard practice for financial analysis? If so, how does one adjust for dividends & splits to maintain correct continuity?

2. Am I missing something in ATP and W-L that accomodates this? Is there a command in ATP and W-L that converts or recaclulates the Data Set to incorporate dividends and splits; and if so does that command convert all data or just Closing prices?
profile picture

Cone

#42
1. It's a debate: The Effect of Dividends and Distributions on DataSources

2. The Y! Provider correctly and accurately backadjusts for splits and dividends based on the options you select. See User Guide: Data > Data Manager > Create New DataSet > Data Providers > Yahoo! : Working with Dividends
profile picture

ss161

#43
I dividend adjust all the data I use.
profile picture

rmpwealth

#44
ss161's code works fine; unfortunately my strategy does not.

I need to tweak the strategy with various Rules and Conditions, but there is no Rules tab in the view pane with which to do so. Cone, will you please convert this code to an Indicator (with variable lookback periods, etc.) that can be used with the Strategy Wizard to be able to create the strategy using Rules?
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).