Pivots and VBA

This is a discussion on Pivots and VBA within the Technical Analysis forums, part of the Methods category; The code below will colour a bar on a bar chart blue or red with regard to pivots points/levels. I ...

Reply
 
LinkBack Thread Tools Search this Thread
Old Oct 22, 2007, 9:56pm   #1
Joined Jun 2006
Pivots and VBA

The code below will colour a bar on a bar chart blue or red with regard to pivots points/levels. I know the standard formula for pivot points but I don't recognise it here.

Could somebody tell me what calculation is being used here so I can transfer the formula for numerical analysis? I've numbered each line for convenience for ease of reference, and made bold what may be the relevant lines.

Thank you,

Grant.


1 '  Parameters
2 'Parameters !!
3 '  PDV parameters
4 Dim LateralBars As Double '5
5 Const Data As Long = 0
6 'PDV parameters !!
7 '  PDV declarations
8 Dim GetSwingHighBarDataOccur As Long 'Long
9 Dim GetSwingHighBarDatatPrice As Price 'Price
10 Dim GetSwingHighBarDataStrength As Long 'Long
11 Dim GetSwingHighBarDataLength As Long 'Long
12 Dim GetSwingLowBarDatanOccur As Long 'Long
13 Dim GetSwingLowBarDatatPrice As Price 'Price
14 Dim GetSwingLowBarDataStrength As Long 'Long
15 Dim GetSwingLowBarDataLength As Long 'Long
16 'PDV declarations !!
17 Option Explicit
18 Public APP As DrwUserApp
19 Implements Study
20 Public Sub Study_OnInitCalculate()
21 With APP
22 '  PDV initializations
23 GetSwingHighBarDataOccur = 1
24 GetSwingHighBarDatatPrice = PriceHigh
25 GetSwingHighBarDataStrength = 5
26 GetSwingHighBarDataLength = 50
27 GetSwingLowBarDatanOccur = 1
28 GetSwingLowBarDatatPrice = PriceLow
29 GetSwingLowBarDataStrength = 2
30 GetSwingLowBarDataLength = 50
31 .StartBar = 0
32 'PDV initializations !!
33 End With
34 End Sub
35 Public Sub Study_OnCalculateBar(ByVal Bar As Long)
36 With APP
37 '  PDV code
38 GetSwingHighBarDataLength = LateralBars * 15
39 GetSwingLowBarDataLength = LateralBars * 15
grantx is offline   Reply With Quote
Old Oct 23, 2007, 7:57am   #2
 
A Dashing Blade's Avatar
Joined Jul 2004
Then "Implements" keyword in line 19 + the "_OnInitCalculate" and "_OnCalculateBar" (20 & 35) type nomencalature would indicate that this code comes from a class module.

Therefore "PriceHigh" and "PriceLow" (24 & 28) are, presumably Sub procedures of the "APP" class dimmed in line 18.

I assume you've made a reference to the DrwUserApp class somehow ie gone (in VBA) Tools . . . References?

If you F2, and so a search for "PriceHigh" and "PriceLow" (the little drop down to the right of the binocular icon) do you see them?
A Dashing Blade is offline   Reply With Quote
Old Oct 23, 2007, 4:01pm   #3
Joined Jun 2006
grantx started this thread DB,

Thank you for the reply. I do see "PriceHigh" and "PriceLow" as described (this was the only part I understood).

If it helps, attached is the full (?) code.

I didnt write this code; its part of my quote feed/system. All Im looking for is the underlying formula and parameters.


Thanks, again.

Grant.
Attached Files
File Type: doc Pivot Show vba.doc (36.5 KB, 236 views)
grantx is offline   Reply With Quote
Old Oct 24, 2007, 4:43pm   #4
 
7 Posts
Joined Oct 2007
Hello Grantx



The study paints the bar placed in the (n) position where n is the position where there is a pivot high or low, to calculate this position we use two functions:

(for pivot high).GetSwingHighBar(Data, GetSwingHighBarDataOccur, GetSwingHighBarDatatPrice, GetSwingHighBarDataStrength, GetSwingHighBarDataLength)

(for pivot low).GetSwingLowBar(Data, GetSwingLowBarDatanOccur, GetSwingLowBarDatatPrice, GetSwingLowBarDataStrength, GetSwingLowBarDataLength)
Where
(I would rather put the code this way)
'  PDV initializations
GetSwingHighBarDataOccur = 1 (indicates the closer (n=1) pivot high
GetSwingHighBarDatatPrice = PriceHigh (indicates that the pivot is calculated upon the bar high)
GetSwingHighBarDataStrength = = LateralBars (indicates that a pivot is a pivot if its the higher prices = LateralBars bars to the left and to the right)
GetSwingHighBarDataLength = LateralBars * 15
(number of bars to be taken in to account to find the pivot from the current position)
GetSwingLowBarDatanOccur = 1 (indicates the closer (n=1) pivot low
GetSwingLowBarDatatPrice = PriceLow (indicates that the pivot is calculated upon the bar low)

GetSwingLowBarDataStrength = LateralBars (indicates that a pivot is a pivot if its the lower prices LateralBars bars to the left and to the right)
GetSwingLowBarDataLength = LateralBars * 15
(number of bars to be taken in to account to find the pivot from the current position)

Remember it has nothing to do with the stnadard pivot point calculation.

Hope it helps.

Mikel
JOSEBA is offline Software vendor   Reply With Quote
Old Oct 31, 2007, 6:17pm   #5
Joined Jun 2006
grantx started this thread Mikel,

Is the following correct? A high pivot is the high of a bar 15 bars back from the current if it also the highest high (opposite for the low pivot).

However, I am confused re DataStrength - Lateral bars to the left and right. Left of where, right of where? Are there actually 2 reference points for the highest high, ie the highest high of the 15 bars back from the current, and the preceding 15 bars from this point? So we are actually looking at the perious 30 bars.

Grant.
grantx is offline   Reply With Quote
Old Nov 1, 2007, 9:54am   #6
 
7 Posts
Joined Oct 2007
Hello Grant.

Here is a screenshot .
Lets start at bar 0 (current bar), the study check if 15 (lateral bars) bars ago is the highest high. Lets say it is, ( we will name this point , point A) it is not enough to be considered as a pivot yet.
Now we know point A is the highest high from our current bar to the left.
Now the system check from point A to the left (backwards) and it it is the highest high again, it will be then considered as a pivot.
Same staff for the pivot low.

In general therms lets say the current bar makes the lowest low of the last 15 bars (lateral bars),(we will call it point B) the study will have to wait 15 bars more to check that prices do not make a new low. because it they do point B will not be painted as a pivot low.

Mikel
Attached Thumbnails
grant.gif  
JOSEBA is offline Software vendor   Reply With Quote
Old Nov 1, 2007, 10:07am   #7
 
7 Posts
Joined Oct 2007
Hi Grant.

I forgot an important thing .
We go back to pivot A in the screen shot.
From A backwards you can find a highest high equal to point A.
This is still valid A must be >= to the highest high 15 bars backwards to be considered as pivot
But A must be strictly > to the highest high (lateral bars 15) forwards.


Mikel
JOSEBA is offline Software vendor   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pivots on metatrader wasp Forex 6 Mar 6, 2010 10:34am
VBA help needed grantx Technical Analysis 24 Oct 19, 2007 8:10pm
Pivots and do you use them? kevinmcm Technical Analysis 5 Jun 27, 2006 10:27am
Excel VBA Developer job??? gurm Home Trader 7 Nov 30, 2005 9:29pm
any techies able to help Excel Vba V. III Techies Corner 3 Sep 19, 2003 9:51am

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)