Download software Tutorial videos
Subscription & data-feed pricing Class schedule


New account application Trading resources
Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.
Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

AD on Intraday Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
thnkbigr
Posted : Friday, November 18, 2011 1:45:40 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
Bruce,

I know this needs to be done in V5

I need to calculate the indicator below on 1 Minute time frame but plot it on a daily time frame. It would be nice if I can change the time frame that it is being calculated on to 2, 5 minutes or etc...

So this will add up all of the minute accumulations - all of the minute distributions and plot the total at the end of every day on a daily chart

'# AAV = condition.AAV
'# DAV = condition.DAV
'# AYV = condition.AYV
'# DYV = condition.DYV
Dim AD As Single = 0
Dim DI As Single = 0
If AAV.Value = True Then
 AD += ((Price.Close - Price.Close(1)))
End If
If AYV.Value = True Then
 AD += ((Price.Close - Price.Close(1)))
End If
If DAV.Value = True Then
 DI += ((Price.Close - Price.Close(1)))
End If
If DYV.Value = True Then
 DI += ((Price.Close - Price.Close(1)))
End If
If (AD - DI) > 0 OrElse _
 (AD - DI) < 0 Then
 Plot = (AD + DI) / 2
Else
 Plot = 0
End If
Bruce_L
Posted : Friday, November 18, 2011 2:11:45 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You would need to make AAV, DAV AYV and DYV in a 1-Minute Time Frame first. As I do not know what they represent, I do not know if it would be easier to create them using Block Diagrams with a Time Frame input (which could possibly be done in SF4) or if they need to be created in RealCode.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Monday, November 21, 2011 1:26:18 AM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207

Here are the rules

How would you adjust this so that it's calculating it on a 1 minute time frame while the indicator will plot the total on  a daily.

I feel like we can put the rules in the indicator so we are calculating the whole thing in one indicator rather than dragging the rules in here. Bc the rules are similar to each other AAV & DAV is vs Avg Vol while AYV & DYV vs Yes Vol.

AAV - Acc above avg Vol

'# Cumulative
Static ATR As Single
Static TR As Single
Static sumWeight As Single
Static termRatio As Single = 21 / 22
Static AvgV As Single
If isFirstBar Then
 sumWeight = 1
 TR = Price.High - Price.Low
 AvgV = 0
Else
 TR = System.Math.Max(Price.High, Price.Last(1)) - _
  System.Math.Min(Price.Low, Price.Last(1))
 AvgV += Volume.value / 30
End If
If CurrentIndex >= 31 Then AvgV -= Volume.value(30) / 30
Dim Weight As Single = 1 / sumWeight
ATR = ATR * (1 - Weight) + Weight * TR
sumWeight = sumWeight * termRatio + 1
If Volume.Value > AvgV * 1.01 AndAlso _
Price.Last - Price.Last(1) >= 0.33 * ATR Then Pass

DAV - Dis above avg Vol

'# Cumulative
Static ATR As Single
Static TR As Single
Static sumWeight As Single
Static termRatio As Single = 21 / 22
Static AvgV As Single
If isFirstBar Then
 sumWeight = 1
 TR = Price.High - Price.Low
 AvgV = 0
Else
 TR = System.Math.Max(Price.High, Price.Last(1)) - _
  System.Math.Min(Price.Low, Price.Last(1))
 AvgV += Volume.value / 30
End If
If CurrentIndex >= 31 Then AvgV -= Volume.value(30) / 30
Dim Weight As Single = 1 / sumWeight
ATR = ATR * (1 - Weight) + Weight * TR
sumWeight = sumWeight * termRatio + 1
If Volume.Value > AvgV * 1.01 AndAlso _
Price.Last(1) - Price.Last >= 0.33 * ATR Then Pass

AYV - Acc vs Yesterdays Vol

'# Cumulative
Static ATR As Single
Static TR As Single
Static sumWeight As Single
Static termRatio As Single = 21 / 22
Static AvgV As Single
If isFirstBar Then
 sumWeight = 1
 TR = Price.High - Price.Low
 AvgV = 0
Else
 TR = System.Math.Max(Price.High, Price.Last(1)) - _
  System.Math.Min(Price.Low, Price.Last(1))
 AvgV += Volume.value / 30
End If
If CurrentIndex >= 31 Then AvgV -= Volume.value(30) / 30
Dim Weight As Single = 1 / sumWeight
ATR = ATR * (1 - Weight) + Weight * TR
sumWeight = sumWeight * termRatio + 1
If Volume.Value(1) / AvgV > 0.75 AndAlso _
 Volume.Value > Volume.Value(1) * 1.01 AndAlso _
 Price.Last - Price.Last(1) >= 0.33 * ATR Then Pass

DYV - Dis vs Yesterdays Vol

'# Cumulative
Static ATR As Single
Static TR As Single
Static sumWeight As Single
Static termRatio As Single = 21 / 22
Static AvgV As Single
If isFirstBar Then
 sumWeight = 1
 TR = Price.High - Price.Low
 AvgV = 0
Else
 TR = System.Math.Max(Price.High, Price.Last(1)) - _
  System.Math.Min(Price.Low, Price.Last(1))
 AvgV += Volume.value / 30
End If
If CurrentIndex >= 31 Then AvgV -= Volume.value(30) / 30
Dim Weight As Single = 1 / sumWeight
ATR = ATR * (1 - Weight) + Weight * TR
sumWeight = sumWeight * termRatio + 1
If Volume.Value(1) / AvgV > 0.75 AndAlso _
Volume.Value > Volume.Value(1) * 1.01 AndAlso _
Price.Last(1) - Price.Last >= 0.33 * ATR Then Pass
 

Bruce_L
Posted : Monday, November 21, 2011 10:26:13 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Does the indicator reset at the start of each day?

When comparing to average volume, do you want to compare to th average volume over a specific number of bars, to the average volume up until that point of the day for so many days, to the average volume for that particular bar of the day over so many days or something else entirely?

When comparing to previous volume, do you want to compare to the previous bar, the volume up until that point in the day for yesterday, that particluar bar of the day for yesterday or something else entirely?

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Friday, November 25, 2011 11:11:21 AM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
No we don't need to reset at the start of each day.

Assuming we want to measure the AD over the last 10 days this will break those 10 days into 1 minute bars and look at the last 3900 minutes which is the num of minutes in 10 days and measure the AD.

To the average volume over a specific number of bars - just like how we do it on a daily time frame - The daily is set to 30 days lets just keep at 30 minutes for now. I'll change that if I need to 

When comparing to previous volume, compare to the previous bar which is comparing this minutes volume vs 1 min ago. 

On ATR the daily time frame is looking at the last 22 days we will calculate it for 22 minutes in here. 

Thanks for everything

Bruce_L
Posted : Monday, November 28, 2011 11:45:28 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
I'm not sure if the following does what you want or not. You would need to replace everything below the Inherits line in the Class tab of a RealCode Indicator with the following:


    Sub New
        AutoLoop = False
        '# Cumulative
    End Sub
    Public Overrides Function Plot() As System.Single
        Dim sumWeight As Single = 1
        Dim termRatio As Single = 21 / 22
        Dim TR As Single = Price.Bar.HighValue(0) - Price.Bar.LowValue(0)
        Dim ATR As Single = TR
        sumWeight = sumWeight * termRatio + 1
        Dim SumV As Single = Volume.Line.Value(0)
        Dim AD As Single = 0
        Dim DI As Single = 0
        If Price.Bar.Count > 1 Then
            For i As Integer = 1 To System.Math.Min(29, Price.Bar.Count - 1)
                TR = System.Math.Max(Price.Bar.HighValue(i), _
                    Price.Bar.Value(i - 1)) - _
                    System.Math.Min(Price.Bar.LowValue(i), _
                    Price.Bar.Value(i - 1))
                Dim Weight As Single = 1 / sumWeight
                ATR = ATR * (1 - Weight) + Weight * TR
                sumWeight = sumWeight * termRatio + 1
                SumV += Volume.Line.Value(i)
                If Price.Bar.Value(i) - Price.Bar.Value(i - 1) >= .33 * ATR Then
                    If Volume.Line.Value(i) > 1.01 * SumV / (i + 1) Then
                        AD += Price.Bar.Value(i) - Price.Bar.Value(i - 1)
                    End If
                    If Volume.Line.Value(i - 1) / (SumV / (i + 1)) > .75 AndAlso _
                        Volume.Line.Value(i) > Volume.Line.Value(i - 1) * 1.01 Then
                        AD += Price.Bar.Value(i) - Price.Bar.Value(i - 1)
                    End If
                End If
                If Price.Bar.Value(i - 1) - Price.Bar.Value(i) >= .33 * ATR Then
                    If Volume.Line.Value(i) > 1.01 * SumV / (i + 1) Then
                        DI += Price.Bar.Value(i) - Price.Bar.Value(i - 1)
                    End If
                    If Volume.Line.Value(i - 1) / (SumV / (i + 1)) > .75 AndAlso _
                        Volume.Line.Value(i) > Volume.Line.Value(i - 1) * 1.01 Then
                        DI += Price.Bar.Value(i) - Price.Bar.Value(i - 1)
                    End If
                End If
                If Price.Bar.DateValue(i).Hour = 16 Then
                    If AD <> DI Then
                        AddToOutput(Price.Bar.DateValue(i), (AD + DI) / 2)
                    Else
                        AddToOutput(Price.Bar.DateValue(i), 0)
                    End If
                End If
            Next
            If Price.Bar.Count > 30 Then
                For i As Integer = 30 To Price.Bar.Count - 1
                    TR = System.Math.Max(Price.Bar.HighValue(i), _
                        Price.Bar.Value(i - 1)) - _
                        System.Math.Min(Price.Bar.LowValue(i), _
                        Price.Bar.Value(i - 1))
                    Dim Weight As Single = 1 / sumWeight
                    ATR = ATR * (1 - Weight) + Weight * TR
                    sumWeight = sumWeight * termRatio + 1
                    SumV += Volume.Line.Value(i) - Volume.Line.Value(i - 30)
                    If Price.Bar.Value(i) - Price.Bar.Value(i - 1) >= .33 * ATR Then
                        If Volume.Line.Value(i) > 1.01 * SumV / 30 Then
                            AD += Price.Bar.Value(i) - Price.Bar.Value(i - 1)
                        End If
                        If Volume.Line.Value(i - 1) / (SumV / 30) > .75 AndAlso _
                            Volume.Line.Value(i) > Volume.Line.Value(i - 1) * 1.01 Then
                            AD += Price.Bar.Value(i) - Price.Bar.Value(i - 1)
                        End If
                    End If
                    If Price.Bar.Value(i - 1) - Price.Bar.Value(i) >= .33 * ATR Then
                        If Volume.Line.Value(i) > 1.01 * SumV / 30 Then
                            DI += Price.Bar.Value(i) - Price.Bar.Value(i - 1)
                        End If
                        If Volume.Line.Value(i - 1) / (SumV / 30) > .75 AndAlso _
                            Volume.Line.Value(i) > Volume.Line.Value(i - 1) * 1.01 Then
                            DI += Price.Bar.Value(i) - Price.Bar.Value(i - 1)
                        End If
                    End If
                    If Price.Bar.DateValue(i).Hour = 16 Then
                        If AD <> DI Then
                            AddToOutput(Price.Bar.DateValue(i), (AD + DI) / 2)
                        Else
                            AddToOutput(Price.Bar.DateValue(i), 0)
                        End If
                    End If
                Next
            End If
        End If
    End Function
End Class

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Monday, November 28, 2011 1:47:53 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
Bruce

Is this V4 or 5?
Bruce_L
Posted : Monday, November 28, 2011 2:01:03 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
I wrote it using SF5, but it should work in version 4 or version 5 (I can't think of anything I would have used which shouldn't work in SF4). As posted, it actually plots once a day with the calculations based on the existing Time Frame of the chart. So if you used a 1-Minute Chart, it would output new values once a day.

You could create a version that didn't use the Time Frame of the chart at all, but we would have to use SF5.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Tuesday, November 29, 2011 1:17:50 AM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207

I need this to calculate on a 1 minute time frame but plot on a daily

I am going to look at this on a daily time frame but the calculations needs to be on a 1 min. 

Take a look at KLIC on a 1 minute for 11/28 - Price closed up for the day but majority of the big volume spiks are red. You can look at SPRD which closed down for the day but it seems majority of the big jumps in price with Vol spike was up.

So I thk measuring the AD on an intraday level but plotting it on a daily will reveal this info.

Also I tried to study your RC 

Are you sure you have the rules correct

I have the rules below to simplify things

If this is true then AD +1

If Volume.Value > AvgV * 1.01 AndAlso _
 Price.Last - Price.Last(1) >= 0.33 * ATR Then Pass

If this is true then DI +1

If Volume.Value > AvgV * 1.01 AndAlso _
 Price.Last(1) - Price.Last >= 0.33 * ATR Then Pass

If this is true then AD +1

If Volume.Value(1) / AvgV > 0.75 AndAlso _
 Volume.Value > Volume.Value(1) * 1.01 AndAlso _
 Price.Last - Price.Last(1) >= 0.33 * ATR Then Pass

If this is true then DI +1

If Volume.Value(1) / AvgV > 0.75 AndAlso _
 Volume.Value > Volume.Value(1) * 1.01 AndAlso _
 Price.Last(1) - Price.Last >= 0.33 * ATR Then Pass

Thx

Bruce_L
Posted : Tuesday, November 29, 2011 9:34:41 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
I'm pretty sure I had a pair of the DI and AD rules reversed. I've tried correcting it above.

On another note, I am not adding 1 when these requirements are met. I am adding Price.Close - Price.Close(1) as was done in your example RealCode.

The RealCode plots daily values. It uses the Time Frame of the Chart to calculate these daily values. So you would need to have a 1-Minute Time Frame selected for the Chart to use 1-Minute data to calculate the indicator.

In thinking about how I was going to use the PriceData method to implement the indicator in StockFinder 5 if that is what you ended up needing, it won't work. The PriceData method does not have a way to reference Volume, it only references Price.

What you could do (and this should work in SF4) is to create Price and Volume indicators using Block Diagrams with adjustable Time Frames. You could then adjust the Price and Volume indicators to use 1-Minute data and Drag and Drop them into the RealCode editor to use them instead of the regular Price and Volume (we've used this technique previously).

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Tuesday, November 29, 2011 12:43:00 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207

Yea my bad we need to do  Price.Close - Price.Close(1) not 1. I was mixing RC in my head.

Ok here is what I thk I need to do pls correct me

Left click 
Create New Block Diagram
Left click - Selected Data From Other Tools - Main Chart.Symbol(Price)
Then changed the time frame to 1 Minute Not Streaming
 
I did the same for Volume

Now what?

Do I drag and drop them in the RC above and change every where you have Price and Volume with the dragged indicators? 

Bruce_L
Posted : Tuesday, November 29, 2011 1:03:09 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You should be able to Open an attached Indicator directly into a running copy of StockFinder (and save it from within StockFinder if desired). You could also copy and paste the Indicator into the \My Documents\StockFinder\(Your Username)\My Indicators\ folder and then load it like you would any other Indicator (for StockFinder 5, use the \My Documents\StockFinder5\(Your Username)\My Indicators\ folder instead).

The indicators need to both be set to a 1-Minute Time Frame. The indicator will not calculate correctly otherwise and would most likely not return any error messages.

You need to replace everything below the Inherits line in the Class tab of a RealCode Indicator with the following (the '# PHwT and '# VBwT lines were created by Dragging and Dropping the indicators into the RealCode Editor, but you shouldn't need to do so if you don't change the names):

    Sub New
        AutoLoop = False
        '# Cumulative
    End Sub
    Public Overrides Function Plot() As System.Single
        '# PHwT = indicator.PriceHistorywTimeFrame
        '# VBwT = indicator.VolumeBarswTimeFrame
        Dim sumWeight As Single = 1
        Dim termRatio As Single = 21 / 22
        Dim TR As Single = PHwT.Bar.HighValue(0) - PHwT.Bar.LowValue(0)
        Dim ATR As Single = TR
        sumWeight = sumWeight * termRatio + 1
        Dim SumV As Single = VBwT.Line.Value(0)
        Dim AD As Single = 0
        Dim DI As Single = 0
        If PHwT.Bar.Count > 1 Then
            For i As Integer = 1 To System.Math.Min(29, PHwT.Bar.Count - 1)
                TR = System.Math.Max(PHwT.Bar.HighValue(i), _
                    PHwT.Bar.Value(i - 1)) - _
                    System.Math.Min(PHwT.Bar.LowValue(i), _
                    PHwT.Bar.Value(i - 1))
                Dim Weight As Single = 1 / sumWeight
                ATR = ATR * (1 - Weight) + Weight * TR
                sumWeight = sumWeight * termRatio + 1
                SumV += VBwT.Line.Value(i)
                If PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1) >= .33 * ATR Then
                    If VBwT.Line.Value(i) > 1.01 * SumV / (i + 1) Then
                        AD += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
                    End If
                    If VBwT.Line.Value(i - 1) / (SumV / (i + 1)) > .75 AndAlso _
                        VBwT.Line.Value(i) > VBwT.Line.Value(i - 1) * 1.01 Then
                        AD += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
                    End If
                End If
                If PHwT.Bar.Value(i - 1) - PHwT.Bar.Value(i) >= .33 * ATR Then
                    If VBwT.Line.Value(i) > 1.01 * SumV / (i + 1) Then
                        DI += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
                    End If
                    If VBwT.Line.Value(i - 1) / (SumV / (i + 1)) > .75 AndAlso _
                        VBwT.Line.Value(i) > VBwT.Line.Value(i - 1) * 1.01 Then
                        DI += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
                    End If
                End If
                If PHwT.Bar.DateValue(i).Hour = 16 Then
                    If AD <> DI Then
                        AddToOutput(PHwT.Bar.DateValue(i), (AD + DI) / 2)
                    Else
                        AddToOutput(PHwT.Bar.DateValue(i), 0)
                    End If
                End If
            Next
            If PHwT.Bar.Count > 30 Then
                For i As Integer = 30 To PHwT.Bar.Count - 1
                    TR = System.Math.Max(PHwT.Bar.HighValue(i), _
                        PHwT.Bar.Value(i - 1)) - _
                        System.Math.Min(PHwT.Bar.LowValue(i), _
                        PHwT.Bar.Value(i - 1))
                    Dim Weight As Single = 1 / sumWeight
                    ATR = ATR * (1 - Weight) + Weight * TR
                    sumWeight = sumWeight * termRatio + 1
                    SumV += VBwT.Line.Value(i) - VBwT.Line.Value(i - 30)
                    If PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1) >= .33 * ATR Then
                        If VBwT.Line.Value(i) > 1.01 * SumV / 30 Then
                            AD += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
                        End If
                        If VBwT.Line.Value(i - 1) / (SumV / 30) > .75 AndAlso _
                            VBwT.Line.Value(i) > VBwT.Line.Value(i - 1) * 1.01 Then
                            AD += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
                        End If
                    End If
                    If PHwT.Bar.Value(i - 1) - PHwT.Bar.Value(i) >= .33 * ATR Then
                        If VBwT.Line.Value(i) > 1.01 * SumV / 30 Then
                            DI += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
                        End If
                        If VBwT.Line.Value(i - 1) / (SumV / 30) > .75 AndAlso _
                            VBwT.Line.Value(i) > VBwT.Line.Value(i - 1) * 1.01 Then
                            DI += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
                        End If
                    End If
                    If PHwT.Bar.DateValue(i).Hour = 16 Then
                        If AD <> DI Then
                            AddToOutput(PHwT.Bar.DateValue(i), (AD + DI) / 2)
                        Else
                            AddToOutput(PHwT.Bar.DateValue(i), 0)
                        End If
                    End If
                Next
            End If
        End If
    End Function
End Class

Attachments:
Price History w Time Frame.sfInd - 4 KB, downloaded 470 time(s).
Volume Bars w Time Frame.sfInd - 8 KB, downloaded 483 time(s).



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Tuesday, November 29, 2011 1:15:37 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
I did as you described but no plot on the indicator

I saved both Price and Volume indicators and plotted both usisng a 1 minute time frame and they plot fine

then I created a indicator with your RC above but i don't get a plot

I shared a chart under AD Int for youe ref
Bruce_L
Posted : Tuesday, November 29, 2011 1:20:36 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
I made sure it plotted before I posted it. Not only that, but your shared version plots on my computer as well. It only has 12 days of data, but that's because of the 5000-bar limit. Do you have your Number of Intraday Bars setting set high enough to calculate daily bars using 1-Minute data under Settings | Data Manager?

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Tuesday, November 29, 2011 1:34:11 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
that was it

thx

So I can pin the price and volume indicators that are set to 1 min to the side so we are looking at a normal daily chart but this indicator is calculated on a 1 min

I shared the new chart over AD Int for your ref

take a look at SPRD yes while it closed down for the day the indicator gained 

look at KLIC it closed up yesterday but the indicator dropped 

I know you said it plots once a day bc as you can see it doesn't plot anything for today yet. Does that mean it will plot only after 4
Bruce_L
Posted : Tuesday, November 29, 2011 2:07:55 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You should be able to pin the indicators and not have them visible.

The indicator can go up when price goes down for the day and vice versa. It is calculated each minute and then output each day. To see what price and volume action is causing this, you can un-pin the 1-Minute Time Frame and comment two of the lines (or delete them):

                    If PHwT.Bar.DateValue(i).Hour = 16 Then
                        If AD <> DI Then
                            AddToOutput(PHwT.Bar.DateValue(i), (AD + DI) / 2)
                        Else
                            AddToOutput(PHwT.Bar.DateValue(i), 0)
                        End If
                    End If

Would become:

                    'If PHwT.Bar.DateValue(i).Hour = 16 Then
                        If AD <> DI Then
                            AddToOutput(PHwT.Bar.DateValue(i), (AD + DI) / 2)
                        Else
                            AddToOutput(PHwT.Bar.DateValue(i), 0)
                        End If
                    'End If

The RealCode currently outputs data at 4 PM ET. If you want it to output data at eiither 4 PM ET or at the last bar of the data, you could change that same section to the following:

            If PHwT.Bar.DateValue(i).Hour = 16 OrElse _
                i = PHwT.Bar.Count - 1 Then
                If AD <> DI Then
                    AddToOutput(EndOfDay(PHwT.Bar.DateValue(i)), (AD + DI) / 2)
                Else
                    AddToOutput(EndOfDay(PHwT.Bar.DateValue(i)), 0)
                End If
            End If

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Tuesday, November 29, 2011 2:27:32 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
Got it thx

I would love to see history on this indicator

I thk its a great way of revealing AD 

Is there anything I can do to increase my intraday data to see more history in this?
Bruce_L
Posted : Tuesday, November 29, 2011 2:33:19 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You can feed a Length Limit Block into Price and Volume Blocks in the "with Timeframe" indicators (the Length Limit settings for both indicators need to be identical). This should allow you to exceed the 5000 Bar Limit.

That said, the 5000 Bar Limit is there for a reason. It should be strongly noted that this can dramatically affect the performance of StockFinder and slow things down significantly because of the additional memory used and calculations required. If things slow down too much, the first thing you should try is to decrease the Length Limit or avoid using this workaround altogether.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Tuesday, November 29, 2011 2:42:15 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
kk

thanks for everything
thnkbigr
Posted : Sunday, December 4, 2011 6:57:00 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
Bruce,

I have a piece of your RC above pasted below 

We have 4 rules in here 2 for Acc and 2 for Dis 
On both  Acc rules price needs to gain more than 0.33 * ATR while on both Dis rules price needs to lose more than 0.33 * ATR

From what I see below your have If PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1) >= .33 * ATR Then on the
1st and 3rd but not 2nd and 4th.

 If PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1) >= .33 * ATR Then
                    If VBwT.Line.Value(i) > 1.01 * SumV / (i + 1) Then
                        AD += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
                    End If
                    If VBwT.Line.Value(i - 1) / (SumV / (i + 1)) > .75 AndAlso _
                        VBwT.Line.Value(i) > VBwT.Line.Value(i - 1) * 1.01 Then
                        AD += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
                    End If
                End If
                If PHwT.Bar.Value(i - 1) - PHwT.Bar.Value(i) >= .33 * ATR Then
                    If VBwT.Line.Value(i) > 1.01 * SumV / (i + 1) Then
                        DI += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
                    End If
                    If VBwT.Line.Value(i - 1) / (SumV / (i + 1)) > .75 AndAlso _
                        VBwT.Line.Value(i) > VBwT.Line.Value(i - 1) * 1.01 Then
                        DI += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
                    End If
                End If

Shouldn't it be like this

If PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1) >= .33 * ATR Then
   If VBwT.Line.Value(i) > 1.01 * SumV / (i + 1) Then
    AD += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
   End If
   If PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1) >= .33 * ATR AndAlso _
    VBwT.Line.Value(i - 1) / (SumV / (i + 1)) > .75 AndAlso _
    VBwT.Line.Value(i) > VBwT.Line.Value(i - 1) * 1.01 Then
    AD += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
   End If
  End If 
   If PHwT.Bar.Value(i - 1) - PHwT.Bar.Value(i) >= .33 * ATR Then
   If VBwT.Line.Value(i) > 1.01 * SumV / (i + 1) Then
    DI += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
   End If
   If PHwT.Bar.Value(i - 1) - PHwT.Bar.Value(i) >= .33 * ATR AndAlso _
    VBwT.Line.Value(i - 1) / (SumV / (i + 1)) > .75 AndAlso _
    VBwT.Line.Value(i) > VBwT.Line.Value(i - 1) * 1.01 Then
    DI += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1) 
   End If 
jas0501
Posted : Sunday, December 4, 2011 7:52:18 PM
Registered User
Joined: 12/31/2005
Posts: 2,499
QUOTE (thnkbigr)
Bruce,

I have a piece of your RC above pasted below 

We have 4 rules in here 2 for Acc and 2 for Dis 
On both  Acc rules price needs to gain more than 0.33 * ATR while on both Dis rules price needs to lose more than 0.33 * ATR

From what I see below your have If PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1) >= .33 * ATR Then on the
1st and 3rd but not 2nd and 4th.

 If PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1) >= .33 * ATR Then
                    If VBwT.Line.Value(i) > 1.01 * SumV / (i + 1) Then
                        AD += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
                    End If
                    If VBwT.Line.Value(i - 1) / (SumV / (i + 1)) > .75 AndAlso _
                        VBwT.Line.Value(i) > VBwT.Line.Value(i - 1) * 1.01 Then
                        AD += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
                    End If
                End If
                If PHwT.Bar.Value(i - 1) - PHwT.Bar.Value(i) >= .33 * ATR Then
                    If VBwT.Line.Value(i) > 1.01 * SumV / (i + 1) Then
                        DI += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
                    End If
                    If VBwT.Line.Value(i - 1) / (SumV / (i + 1)) > .75 AndAlso _
                        VBwT.Line.Value(i) > VBwT.Line.Value(i - 1) * 1.01 Then
                        DI += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
                    End If
                End If

Shouldn't it be like this

If PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1) >= .33 * ATR Then
   If VBwT.Line.Value(i) > 1.01 * SumV / (i + 1) Then
    AD += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
   End If
   If PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1) >= .33 * ATR AndAlso _
    VBwT.Line.Value(i - 1) / (SumV / (i + 1)) > .75 AndAlso _
    VBwT.Line.Value(i) > VBwT.Line.Value(i - 1) * 1.01 Then
    AD += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
   End If
  End If 
   If PHwT.Bar.Value(i - 1) - PHwT.Bar.Value(i) >= .33 * ATR Then
   If VBwT.Line.Value(i) > 1.01 * SumV / (i + 1) Then
    DI += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
   End If
   If PHwT.Bar.Value(i - 1) - PHwT.Bar.Value(i) >= .33 * ATR AndAlso _
    VBwT.Line.Value(i - 1) / (SumV / (i + 1)) > .75 AndAlso _
    VBwT.Line.Value(i) > VBwT.Line.Value(i - 1) * 1.01 Then
    DI += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1) 
   End If 


Bruce's  looks fine to me. Notice the subscripts are (i) and (i-1) for the first part and (i-1) and (i) for the second part.
'
' PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1) >= .33 * ATR
'
If PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1) >= .33 * ATR Then
     If VBwT.Line.Value(i) > 1.01 * SumV / (i + 1) Then
         AD += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
     End If
     If VBwT.Line.Value(i - 1) / (SumV / (i + 1)) > .75 AndAlso _
         VBwT.Line.Value(i) > VBwT.Line.Value(i - 1) * 1.01 Then
         AD += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
     End If
End If
'
'  PHwT.Bar.Value(i - 1) - PHwT.Bar.Value(i) >= .33 * ATR
'
If PHwT.Bar.Value(i - 1) - PHwT.Bar.Value(i) >= .33 * ATR Then
     If VBwT.Line.Value(i) > 1.01 * SumV / (i + 1) Then
         DI += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
     End If
     If VBwT.Line.Value(i - 1) / (SumV / (i + 1)) > .75 AndAlso _
         VBwT.Line.Value(i) > VBwT.Line.Value(i - 1) * 1.01 Then
         DI += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
     End If
End If

thnkbigr
Posted : Sunday, December 4, 2011 7:56:17 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
Get it 

thx
thnkbigr
Posted : Sunday, December 4, 2011 10:20:08 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
If I want to multiply the AD or DI with volume 

Is this what I need to do?

AD += (PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)) *  VBwT.Line.Value(i)
Bruce_L
Posted : Monday, December 5, 2011 8:42:22 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
That should work.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Monday, December 5, 2011 11:36:43 AM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
thx

to increase the Avg period for Volume and ATR can you show me what to do pls

instead of 30 day for volume I like to increase that to 390 since we have 390 min in a day of trading and same for ATR

If you can just highlight what I need to change and I'll change them bc I am gone play around with these avg's a little
Bruce_L
Posted : Monday, December 5, 2011 12:01:06 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
I think I've replaced every instance 29 or 30 with VolPeriod.

    Sub New
        AutoLoop = False
        '# Cumulative
    End Sub
    Public Overrides Function Plot() As System.Single
        '# PHwT = indicator.PriceHistorywTimeFrame
        '# VBwT = indicator.VolumeBarswTimeFrame
        '# ATRPeriod = UserInput.Single = 390
        '# VolPeriod = UserInput.Integer = 390
        If PHwT.Bar.Count >= System.Math.Max(2, VolPeriod) Then
            Dim sumWeight As Single = 1
            Dim termRatio As Single = (ATRPeriod - 1) / ATRPeriod
            Dim TR As Single = PHwT.Bar.HighValue(0) - PHwT.Bar.LowValue(0)
            Dim ATR As Single = TR
            sumWeight = sumWeight * termRatio + 1
            Dim SumV As Single = VBwT.Line.Value(0)
            Dim AD As Single = 0
            Dim DI As Single = 0
            If PHwT.Bar.Count > 1 Then
                For i As Integer = 1 To System.Math.Min(VolPeriod, PHwT.Bar.Count) - 1
                    TR = System.Math.Max(PHwT.Bar.HighValue(i), _
                        PHwT.Bar.Value(i - 1)) - _
                        System.Math.Min(PHwT.Bar.LowValue(i), _
                        PHwT.Bar.Value(i - 1))
                    Dim Weight As Single = 1 / sumWeight
                    ATR = ATR * (1 - Weight) + Weight * TR
                    sumWeight = sumWeight * termRatio + 1
                    SumV += VBwT.Line.Value(i)
                    If PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1) >= .33 * ATR Then
                        If VBwT.Line.Value(i) > 1.01 * SumV / (i + 1) Then
                            AD += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
                        End If
                        If VBwT.Line.Value(i - 1) / (SumV / (i + 1)) > .75 AndAlso _
                            VBwT.Line.Value(i) > VBwT.Line.Value(i - 1) * 1.01 Then
                            AD += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
                        End If
                    End If
                    If PHwT.Bar.Value(i - 1) - PHwT.Bar.Value(i) >= .33 * ATR Then
                        If VBwT.Line.Value(i) > 1.01 * SumV / (i + 1) Then
                            DI += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
                        End If
                        If VBwT.Line.Value(i - 1) / (SumV / (i + 1)) > .75 AndAlso _
                            VBwT.Line.Value(i) > VBwT.Line.Value(i - 1) * 1.01 Then
                            DI += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
                        End If
                    End If
                    If PHwT.Bar.DateValue(i).Hour = 16 Then
                        If AD <> DI Then
                            AddToOutput(PHwT.Bar.DateValue(i), (AD + DI) / 2)
                        Else
                            AddToOutput(PHwT.Bar.DateValue(i), 0)
                        End If
                    End If
                Next
                If PHwT.Bar.Count > VolPeriod Then
                    For i As Integer = VolPeriod To PHwT.Bar.Count - 1
                        TR = System.Math.Max(PHwT.Bar.HighValue(i), _
                            PHwT.Bar.Value(i - 1)) - _
                            System.Math.Min(PHwT.Bar.LowValue(i), _
                            PHwT.Bar.Value(i - 1))
                        Dim Weight As Single = 1 / sumWeight
                        ATR = ATR * (1 - Weight) + Weight * TR
                        sumWeight = sumWeight * termRatio + 1
                        SumV += VBwT.Line.Value(i) - VBwT.Line.Value(i - VolPeriod)
                        If PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1) >= .33 * ATR Then
                            If VBwT.Line.Value(i) > 1.01 * SumV / VolPeriod Then
                                AD += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
                            End If
                            If VBwT.Line.Value(i - 1) / (SumV / VolPeriod) > .75 AndAlso _
                                VBwT.Line.Value(i) > VBwT.Line.Value(i - 1) * 1.01 Then
                                AD += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
                            End If
                        End If
                        If PHwT.Bar.Value(i - 1) - PHwT.Bar.Value(i) >= .33 * ATR Then
                            If VBwT.Line.Value(i) > 1.01 * SumV / VolPeriod Then
                                DI += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
                            End If
                            If VBwT.Line.Value(i - 1) / (SumV / VolPeriod) > .75 AndAlso _
                                VBwT.Line.Value(i) > VBwT.Line.Value(i - 1) * 1.01 Then
                                DI += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
                            End If
                        End If
                        If PHwT.Bar.DateValue(i).Hour = 16 OrElse _
                            i = PHwT.Bar.Count - 1 Then
                            If AD <> DI Then
                                AddToOutput(EndOfDay(PHwT.Bar.DateValue(i)), (AD + DI) / 2)
                            Else
                                AddToOutput(EndOfDay(PHwT.Bar.DateValue(i)), 0)
                            End If
                        End If
                    Next
                End If
            End If
        End If   
    End Function
End Class

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Monday, December 5, 2011 12:15:05 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
You are AMAZING
thnkbigr
Posted : Monday, December 5, 2011 1:27:55 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
Bruce 

I am overlaying this indicator as you know on the price chart on its own scale and I would like to put it on the same scale as price to be able to see the divergences and their magnitude clearly.

Since the value of price and the indicator vary drastically i can't put them on the same scale now.

Here is what I am thinking

The indicator starts at 0 so let say I am plotting the indiactor from 5000 bars ago (This is 5000 minutes) Can we have it start plotting (Adding and subtracting the AD) from the closing value of price 5000 bars ago. This way we can put them on the same scale.

For ex if 5000 minutes ago price closed at 32.50 the indicator will start at 32.50 rather than 0
Bruce_L
Posted : Monday, December 5, 2011 1:35:08 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You could try changing:

            Dim AD As Single = 0
            Dim DI As Single = 0

To:

            Dim AD As Single = PHwT.Bar.Value(0)
            Dim DI As Single = PHwT.Bar.Value(0)

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Monday, December 5, 2011 3:44:46 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207

Bruce,

I just shared a chart under AD Intraday again in v4

take a look at 

AEP 4/4
ABT 9/9
HON
ALL 3/1

There are large spikes in the incators which doesn't seem correct. How can I find out waht's causing this

 

Bruce_L
Posted : Monday, December 5, 2011 4:08:19 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
I don't actually keep SF4 updated. So I can play with it to try and answer your questions, but I can't look at accurate charts. Have you tried looking at the results in a 1-Minute Time Frame as outlined in my Tuesday, November 29, 2011 2:07:55 PM ET post?If you try that and can't tell why there is a spike I'll program it into SF5 to check it out.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Monday, December 5, 2011 8:08:26 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207

I thk I already know whats causing it

take a look at AVP on a 1 min time frame on 11/23/2011 at 1:37 the stock at 1:36 closed at 16.35 and dropped to 0.02 at 1:37 and then back to 16.35 at 1:38

same for ALL, AXP, BA and it happens to be on the same date and time 

NKE on 11/30 at 12:39

These are all data errors that is causing the indicator to spike up or down drastically.

These arejust to name a few there seem to be a lot of them 

How do I get this resolved
 

Bruce_L
Posted : Tuesday, December 6, 2011 8:00:23 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You can report data issues by selecting Help | Report Data Issue from the menus in StockFinder.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Tuesday, December 6, 2011 12:29:37 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
Bruce 

I need to paint the volume bars on the intraday chart red when price closed down

I have added a Limit length block that extended the data to 10000

When I create a rule price closed down and try to paint the volume bars it doesn't work

Howcome
Bruce_L
Posted : Tuesday, December 6, 2011 12:44:44 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Edit a Block Diagram, any Block Diagram. Now click on the All Diagrams tab (off to the right).

Now look for the Block Diagram for your Paint Brush (it probably ends in the word Brush). Now add the Length Limit to the Paint Brush as well (you will probably need to run it into both Price and Volume).

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Tuesday, December 6, 2011 1:07:37 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
kk

I need to change the block diagram that plots the volume with a time frame to Dollar Volume and in the RC above i need to add in that the Dollar Volume for that minute was > 1 million dollars for to count as a Acc or Dis.

In order for me to change the volume block diagram to dollar volume 

I connected the Main Symbol block to prices 
I connected 1 Minute Not Streaming to Prices block
I multiplied prices block by Volume 

if this is correct the dollar volume indicator plots but the AD indicator doesn't
thnkbigr
Posted : Tuesday, December 6, 2011 1:10:36 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
I just shared a chart under DV in v4 with Dollar Volume block diagram indicator i created if you can pick it up
Bruce_L
Posted : Tuesday, December 6, 2011 1:25:39 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
There isn't an AD indicator or Price with Time Frame in your shared chart that I can see.

That said, the indicators being fed into the AD indicator need to have exactly the same number of bars and the bars need to line up exactly with the same dates and times. Your Block Diagram for DV with Time Frame indicator has a Bar Offset Block which is effectively reducing the number of bars being output by 1. In addition, you mentioned a Length Limit of 10000, but the Length Limit in the Block Diagram is set to 100000.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Tuesday, December 6, 2011 2:17:19 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
I removed the bar offset and it worked

So If I need to say DV for that minute was > let just say 1 million dollars, as well as meeting all the other rules is this what I need to add to every section

If VBwT.Line.Value(i) > 1.01 * SumV / VolPeriod AndAlso _
VBwT.Line.Value(i) > 1
Then
AD += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
End If
Bruce_L
Posted : Tuesday, December 6, 2011 2:49:23 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Unless you've adjusted things, I don't think the DV is in millions of dollars. I think you are multiplying Price times Volume with Volume being reported in blocks of 100 shares. So I think DV would be in $100 increments. The default Volume Block Diagram is adjustable however, so you may have changed it.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Users browsing this topic
Guest-1

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.