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 |

In Channel Since NH Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
thnkbigr
Posted : Monday, August 3, 2009 6:34:12 PM
Platinum Customer Platinum Customer

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

Let me know if I did this right.

I want more than 75% of the closing prices from the last 63 day high to be inbetween the Upper and Lower Keltner Channels.

I created a rule price below upper channel and another price above the lower channel. Then I combined these two rules into one combo rule.

Finally I created the indicator below by dragging the combo rule and copying the rest from the rule you wrote earlier today (I adjusted few things). This should plot the % of closing prices that was inbetween the upper and lower channel since last 63 day high.

'# AFA = condition.ComboCondition
Static Count(2) As Single
If isFirstBar Then
 Count(0) = Single.NaN
 Count(1) = Single.NaN
Else If CurrentIndex >= 63 AndAlso _
 Price.High > Price.MaxHigh(62, 1) Then
 Count(0) = 0
 Count(1) = 0
End If
If AFA.Value = True Then Count(0) += 1
Count(1) += 1
Plot = 100 * (Count(0) / Count(1))

Please tell me if I am missing anything?
thnkbigr
Posted : Monday, August 3, 2009 11:36:35 PM
Platinum Customer Platinum Customer

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

If the above is correct lets meke one adjusment please.

Raher than plotting the % in CH since last 63 day high to the present, I like to change it so that it plots the % in CH from last 63 day high to the day that price reached its lowest level since that high.

For example if price brakes out of its downtrend today but the the day that it hit its lowest level since last 63 day high was 5 days ago I don't want the last 5 days to effect the % in CH.

I tried to do this but no matter what I do it doesnt come out correct.

Thanks   
Bruce_L
Posted : Tuesday, August 4, 2009 5:09:42 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Assuming we use the CloseHigh technique given in Low Since 63, you might want to try the following RealCode Indicator:

'# AFA = condition.ComboCondition
Static Count(2) As Single
Static HighClose As Single
Static Valid As Boolean
If isFirstBar Then
    Count(0) = Single.NaN
    Count(1) = Single.NaN
    Count(2) = Single.NaN
    HighClose = Single.NaN
    Valid = False
Else If CurrentIndex >= 63 AndAlso _
    Price.High > Price.MaxHigh(62, 1) Then
    Count(0) = 0
    Count(1) = 0
    Count(2) = 0
    HighClose = Price.Last
    Valid = True
End If
If Valid = True Then
    Count(2) += 1
    If Count(2) = 1 Then
        If AFA.Value = True Then
            Count(0) += 1
        End If
        Count(1) += 1
    Else If Price.Low = System.Math.Min(HighClose, Price.MinLow(Count(2) - 1)) Then
        Count(0) = 0
        For i As Integer = 0 To Count(2) - 1
            If AFA.Value(i) = True Then
                Count(0) += 1
            End If
        Next
        Count(1) = Count(2)
    End If
    Plot = 100 * Count(0) / Count(1)
Else
    Plot = Single.NaN
End If

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Tuesday, August 4, 2009 5:37:50 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
Aren't we just looking at the % Closing prices within the upper and lower channel? Or are you incorporating the High and Low of the days too?
thnkbigr
Posted : Tuesday, August 4, 2009 5:40:51 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
Oh I think I see what you are doing. You are not counting the close of the day that price made a 63 day high as one of the days.

is that what you mean by the CloseHigh technique?
thnkbigr
Posted : Tuesday, August 4, 2009 7:41:43 PM
Platinum Customer Platinum Customer

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

This seems accurate and it is counting the day of the NH. I rathr not since the correction has yet to start. Correction starts the day after the last 63 day high.

I just just confused what the CloseHigh technique has anything to do with this?
Bruce_L
Posted : Wednesday, August 5, 2009 11:42:51 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
If you are going to measure the number of times somethiing is True between the most recent 63-Period New High to the lowest Low since that New High, you need to know both when that New High occurred and when the lowest Low since then occurred.

In Low Since 63, we used two different techniques for identifying when the lowest Low since the New High occurred. The first technique was simply to skip the date of the New High (since we don't know if the Low of that day happened before or after the High). This involved simply starting the Count on the day after the New High instead of on the Day of the New High. We can easily do so for this as well:

'# AFA = condition.ComboCondition
Static Count(2) As Single
Static Valid As Boolean
If isFirstBar Then
    Count(0) = Single.NaN
    Count(1) = Single.NaN
    Count(2) = Single.NaN
    Valid = False
Else If CurrentIndex >= 63 AndAlso _
    Price.High(1) > Price.MaxHigh(62, 2) Then
    Count(0) = 0
    Count(1) = 0
    Count(2) = 0
    Valid = True
End If
If Valid = True Then
    Count(2) += 1
    If Price.Low = Price.MinLow(Count(2)) Then
        Count(0) = 0
        For i As Integer = 0 To Count(2) - 1
            If AFA.Value(i) = True Then
                Count(0) += 1
            End If
        Next
        Count(1) = Count(2)
    End If
    Plot = 100 * Count(0) / Count(1)
Else
    Plot = Single.NaN
End If

The second technique presented used a variable called HighClose to keep track of the Close on the Bar where the New High was identified since we know that Price fell from the New High by at least as much as the difference between the New High and the Close of that Bar.

I used this technique in my original response to be consistent with the RealCode presented in your Monday, August 03, 2009 6:34:12 PM ET post (which does include the Bar of the New High in its calculations). When doing so, you need to know if the Close of the Bar of the New High is lower than any more recent Lows to know if you should count any additional days in the calculations (because if they aren't lower, then the largest correction was actually on the day of the New High and only one Bar should be tested).

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Wednesday, August 12, 2009 1:05:59 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
Seems correct but confirm it please.

Thanks

'# AFA = condition.ComboCondition
Static Count(2) As Single
Static Valid As Boolean
If isFirstBar Then
 Count(0) = Single.NaN
 Count(1) = Single.NaN
 Count(2) = Single.NaN
 Valid = False
Else If CurrentIndex >= 63 AndAlso _
 Price.Low(1) < Price.MinLow(62, 2) Then
 Count(0) = 0
 Count(1) = 0
 Count(2) = 0
 Valid = True
End If
If Valid = True Then
 Count(2) += 1
 If Price.High = Price.MaxHigh(Count(2)) Then
  Count(0) = 0
  For i As Integer = 0 To Count(2) - 1
   If AFA.Value(i) = True Then
    Count(0) += 1
   End If
  Next
  Count(1) = Count(2)
 End If
 Plot = 100 * Count(0) / Count(1)
Else
 Plot = Single.NaN
End If
Bruce_L
Posted : Wednesday, August 12, 2009 1:14:34 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
It appears to be correct to me.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Wednesday, August 12, 2009 1:56:00 PM
Platinum Customer Platinum Customer

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

Bruce,

 

I finally had a chance to watch Julia’s webinar on R-Squared and Standard Deviation with Lin Reg channels and that has inspired me to try to do something I originally wanted to do but I though it will never be possible, but with SF and the power of realcode who knows what is or is not possible so it’s worth asking.

 

I just shared a chart under In Channel. As you can see I currently use a Band around a 22 day Lin Reg Slop with a 1 ATR above and below it. I use this in the retracement part of the Wave strategy. I look for more than 80% of closes to be within the bands since the 63 day high and a cross up through the upper band is the start of the next wave up.


There are few problems with this. First is the 22 day time frame on the Lin Reg Slop. The retracement could very well be shorter or much longer than 22 days and this is true no matter what time frame I use. The 2nd issue I have with this is that since this is plotting the slop of the Lin Reg and it keeps curving as the slop of the 22 day Lin Reg changes, the breakout sometimes comes late since Lin Reg has gradually turned back up with price or sometimes you don’t even get a Breakout.

 

Lastly, bring up WMG please. Stock hit a high on 6/1/2009 and started retracing and it broke out on 6/26/2009, but you only had 33% of the closes within the bands and that is because it took some time for the 22 day Lin Reg Slop to turn back down. Instead if you plot a Lin Reg Channel with a 1 Standard Deviation from the high of 6/1 to the lowest low hit since 6/1 which was on 6/24 you can see that 100% of the closes were within the upper and lower channels.

 

I think all of these issues can be solved with a Lin Reg Channel. To avoid the time frame problem is it possible for us to plot a Lin Reg Ch from the day of the last 63 day high to the day that price hit the lowest level since that high. So if the 63 day high was 30 days ago and the low since then was 3 days ago it will plot a Lin Reg from the high to the low and it will be a 27 day Lin Reg, or if the high was 40 days ago and the low was today it will be a 40 day Lin Reg that starts from the high 40 days ago to today. And we plot an extension that of course plots downward in the same angle.

 

The channels above and below it we can use ATR or Standard Deviation it makes no difference to me at all.

 

And since the extensions will continue plotting in the same slop downward and they are not curving as the slop of the 22 day Lin Reg that I am using now changes 1) you will always get a breakout the moment stock resumes its uptrend and 2) breakout comes in most cases a lot earlier and much closer to the stop price which changes the risk to reward ratio to my favor drastically.

 

So plotting a Lin Reg from the last 63 day high to the lowest low reached since the high with extensions that extend no longer than 63 bars and the distance of the bands can be by ATR or Standard Deviation.

 

Please let me if this is possible.

 

Many thanks

Bruce_L
Posted : Friday, August 14, 2009 5:01:04 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
It does appear to be possible (and maybe not quite as slow as I originally suspected it would be). Still working on it.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Sunday, August 16, 2009 4:02:56 PM
Platinum Customer Platinum Customer

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

Thanks 

That should make this strategy a lot more accurate?

Bruce_L
Posted : Monday, August 24, 2009 3:23:13 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
I have no idea how it might affect your strategy. You may want to try the following RealCode Indicator:

'# Width = UserInput.Single = 1
Static Count(1) As Single
Static Sum(2) As Single
Static Slope(1) As Single
Static SD(1) As Single
Static EndPoint(1) As Single
Static LowSince As Single
If isFirstBar Then
    Count(0) = Single.NaN
    Count(1) = Single.NaN
    Sum(0) = Single.NaN
    Sum(1) = Single.NaN
    Sum(2) = Single.NaN
    LowSince = Single.NaN
    Slope(1) = Single.NaN
    SD(1) = Single.NaN
    EndPoint(1) = Single.NaN
Else If Price.High > Price.MaxHigh(62, 1) Then
    Count(0) = 1
    Count(1) = 1
    Sum(0) = Price.Last
    Sum(1) = Price.Last ^ 2
    Sum(2) = Price.Last
    LowSince = Price.Last
Else
    Count(0) += 1
    Sum(0) += Price.Last
    Sum(1) += Price.Last ^ 2
    Sum(2) += Count(0) * Price.Last
    LowSince = System.Math.Min(LowSince, Price.Low)
End If
If Count(0) >= 2 Then
    Slope(0) = (Sum(2) - ((Count(0) + 1) / 2 * Sum(0))) / (Count(0) * (Count(0) ^ 2 - 1) / 12)
    SD(0) = Width * (((Sum(1) - Sum(0) ^ 2 / Count(0)) / Count(0)) ^ .5)
    EndPoint(0) = Sum(0) / Count(0) + (Count(0) - 1) * Slope(0) / 2
    If Price.Low = LowSince Then
        Count(1) = 0
        Slope(1) = Slope(0)
        SD(1) = SD(0)
        EndPoint(1) = EndPoint(0)
        For i As Integer = 0 To Count(0) - 1
            If Price.Last(i) <= EndPoint(0) - Slope(0) * i + SD(0) AndAlso _
                Price.Last(i) >= EndPoint(0) - Slope(0) * i - SD(0) Then
                Count(1) += 1
            End If   
        Next
    Else
        EndPoint(1) += Slope(1)
        If Price.Last <= EndPoint(1) + SD(1) AndAlso _
            Price.Last >= EndPoint(1) - SD(1) Then
            Count(1) += 1
        End If   
    End If
Else
    Slope(0) = 0
    SD(0) = 0
    EndPoint(0) = Price.Last
End If
Plot = 100 * Count(1) / Count(0)

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Tuesday, August 25, 2009 2:10:58 AM
Platinum Customer Platinum Customer

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

Is this plotting the % of closes in the Lin Reg Channel using a Standard Deviation of 1?

Bruce_L
Posted : Tuesday, August 25, 2009 7:35:56 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
The Standard Deviation Period used is the number of Bars from the New High to the Lowest Low since the New High. The number of Standard Deviations from the centerline of the Linear Regression Line (same Period) is based on the Width Setting.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Tuesday, August 25, 2009 11:04:52 AM
Platinum Customer Platinum Customer

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

Bruce,

I only have one setting that I can adjust in the indicator edit box and that is width which as you say controls the distance from the center line to the upper and lower channel.

I just shared a chart under In Channel. Take a look at KLIC please. On 6/1/2009 it hit a 63 day high and the lowest low it hit since was on 7/10/2009. So I drew a Lin Reg Ch from 6/1 to 7/10 with a 1 Standard Deviation and as you can see 100% of the closes are within the channel. I have your indicator in the bottom pane and the value of the indicator is about 35%.

Bruce_L
Posted : Tuesday, August 25, 2009 11:24:27 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
I made a slight modification. Try it again using the altered RealCode.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Tuesday, August 25, 2009 12:06:49 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
WOW you are amazing. Thanks 

I like to use the cross above the upper channel as a breakout signal.

Can I also delete the last section and plot the Lin Reg Ch. But only after 10 days from the high since we don't want to plot it 1 or 2 days after the high. Only plot the Lin Reg if today is 10 days from the last 63 day high.

We might have to allow extentions on this because if the low reached since high was 5 days ago and today price is breaking above the upper ch, the Lin Reg w/o extentions will stop drawing 5 days ago.

Bruce_L
Posted : Tuesday, August 25, 2009 12:21:52 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Um, no, not really (the channels would overlap). You could Plot some sort of Moving Linear Regression Channels however by Plotting some of the variables used for the calculations. You would probably want to use a OHLC Bar Plot Style for the following (or extract the components using a Block Diagram based Indicator). You'll need to use an Arithmetic Scale because the values can drop below zero:

'# Width = UserInput.Single = 1
Static Count(1) As Single
Static Sum(2) As Single
Static Slope(1) As Single
Static SD(1) As Single
Static EndPoint(1) As Single
Static LowSince As Single
If isFirstBar Then
    Count(0) = Single.NaN
    Count(1) = Single.NaN
    Sum(0) = Single.NaN
    Sum(1) = Single.NaN
    Sum(2) = Single.NaN
    LowSince = Single.NaN
    Slope(1) = Single.NaN
    SD(1) = Single.NaN
    EndPoint(1) = Single.NaN
Else If Price.High > Price.MaxHigh(62, 1) Then
    Count(0) = 1
    Count(1) = 1
    Sum(0) = Price.Last
    Sum(1) = Price.Last ^ 2
    Sum(2) = Price.Last
    LowSince = Price.Last
Else
    Count(0) += 1
    Sum(0) += Price.Last
    Sum(1) += Price.Last ^ 2
    Sum(2) += Count(0) * Price.Last
    LowSince = System.Math.Min(LowSince, Price.Low)
End If
If Count(0) >= 2 Then
    Slope(0) = (Sum(2) - ((Count(0) + 1) / 2 * Sum(0))) / (Count(0) * (Count(0) ^ 2 - 1) / 12)
    SD(0) = Width * (((Sum(1) - Sum(0) ^ 2 / Count(0)) / Count(0)) ^ .5)
    EndPoint(0) = Sum(0) / Count(0) + (Count(0) - 1) * Slope(0) / 2
    If Price.Low = LowSince Then
        Count(1) = 0
        Slope(1) = Slope(0)
        SD(1) = SD(0)
        EndPoint(1) = EndPoint(0)
        For i As Integer = 0 To Count(0) - 1
            If Price.Last(i) <= EndPoint(0) - Slope(0) * i + SD(0) AndAlso _
                Price.Last(i) >= EndPoint(0) - Slope(0) * i - SD(0) Then
                Count(1) += 1
            End If  
        Next
    Else
        EndPoint(1) += Slope(1)
        If Price.Last <= EndPoint(1) + SD(1) AndAlso _
            Price.Last >= EndPoint(1) - SD(1) Then
            Count(1) += 1
        End If  
    End If
Else
    Slope(0) = 0
    SD(0) = 0
    EndPoint(0) = Price.Last
    Slope(1) = 0
    SD(1) = 0
    EndPoint(1) = Price.Last
End If
OpenValue = EndPoint(1) - Slope(1)
HighValue = EndPoint(1) + SD(1)
LowValue = EndPoint(1) - SD(1)
Plot = EndPoint(1)

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Tuesday, August 25, 2009 1:10:40 PM
Platinum Customer Platinum Customer

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

This is onlt plotting the Lin Reg no channels above and below it.

I see what the indicator is doing but I am confued on few things.

What you mean by overlaping? Do you mean that the channels will overlap?

Also what do you mean by (or extract the components using a Block Diagram based Indicator).
Bruce_L
Posted : Tuesday, August 25, 2009 1:24:03 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
QUOTE (thnkbigr)
This is onlt plotting the Lin Reg no channels above and below it.

QUOTE (Bruce_L)
You would probably want to use a OHLC Bar Plot Style for the following...


QUOTE (thnkbigr)
What you mean by overlaping? Do you mean that the channels will overlap?

Imagine drawing a Linear Regression Line with Channels every time Price is at a Low after making a New High between these extremes. The Linear Regression Lines would have different Slopes, different Widths and would overlap each other.

QUOTE (thnkbigr)
Also what do you mean by (or extract the components using a Block Diagram based Indicator).

If you follow the directions given in the post and use an OHLC Bar Plot Style for the Custom Indicator, you will see that it displays more than just a line. If you create a Block Diagram based Indiicator and run the output of the Custom Indicator through a Bar Open, Bar High or Bar Low Block, you can display these values as Lines in the Block Diagram based Indicator instead of using the OHLC Bar Plot style to see all of the values.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Tuesday, August 25, 2009 3:18:15 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
First of all this is pretty accurate.

I am on OHLC plot but it still draws 1 line.

I changed my plot to OHLC and then Add Indicator, Create in RealCode, I deleted everything and then I copied and pasted your realcode above. The indicator plots in a new pane so I drag and drop it in the Price pane, click on Overlay and set the scale to be the same as Price.

Am I doing anything wrong because I still get one line?

 

I did create 3 other indicators running the out put of the Custom Code Block to Bar Low, Bar High and Bar Open and now I get the upper and Lower channels.

 

Is the Upper channel technically plotting a Lin Reg on the Highs and Lower Ch a Lin Reg on the Lows?

Bruce_L
Posted : Tuesday, August 25, 2009 3:28:39 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
QUOTE (thnkbigr)
I am on OHLC plot but it still draws 1 line.

I changed my plot to OHLC and then Add Indicator, Create in RealCode, I deleted everything and then I copied and pasted your realcode above. The indicator plots in a new pane so I drag and drop it in the Price pane, click on Overlay and set the scale to be the same as Price.

Am I doing anything wrong because I still get one line?

You would need to Plot the RealCode Indicator using the OHLC Plot Style, not the Price History.

QUOTE (thnkbigr)
Is the Upper channel technically plotting a Lin Reg on the Highs and Lower Ch a Lin Reg on the Lows?

No, the Upper Channel is the Endpoint of the Linear Regression plus the Standard Deviation of the Close over the Period and the Lower Channel is the Endpoint of the Linear Regression minus the Standard Deviation of the Close over the Period.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Tuesday, August 25, 2009 3:59:58 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
Oh I see but it plotts it like price and you won't be able to see the chart anymore the Block version looks much better. Little slow on my machine but I am looking to buy a new laptop.

Here is the only thing I am confused about. When we are connecting the out put of the Custom Code block to Bar High does that have anything to do with Price or are we just saying plot the Upper Ch at 1 SD above the Lin Reg?

I am trying to understand what you did. I don't clearly understand what the Bar High, Low and open do?

jas0501
Posted : Tuesday, August 25, 2009 4:07:13 PM
Registered User
Joined: 12/31/2005
Posts: 2,499
QUOTE (thnkbigr)
Oh I see but it plotts it like price and you won't be able to see the chart anymore the Block version looks much better. Little slow on my machine but I am looking to buy a new laptop.

Here is the only thing I am confused about. When we are connecting the out put of the Custom Code block to Bar High does that have anything to do with Price or are we just saying plot the Upper Ch at 1 SD above the Lin Reg?

I am trying to understand what you did. I don't clearly understand what the Bar High, Low and open do?


They provide the high, low or open price instead of the default close as the ind.value.
thnkbigr
Posted : Tuesday, August 25, 2009 4:18:02 PM
Platinum Customer Platinum Customer

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

Ok Thanks 

Bruce you are amazing thank you

Bruce_L
Posted : Tuesday, August 25, 2009 4:24:26 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
QUOTE (thnkbigr)
Oh I see but it plotts it like price and you won't be able to see the chart anymore the Block version looks much better.

Yes, it does look much better to extract the Values using Block Diagram based Indicators than to Plot it as a OHLC Bar Chart.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Thursday, August 27, 2009 2:13:57 AM
Platinum Customer Platinum Customer

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

The the Blocks version of the above when I add in the Bar High, Low if close SF and relaunch it the indicator goes back to its original form. Rather than Bar High being connected to the numeric plot the custom realcode is connected.

Can I anything to save this so it doesn't change.

To my understanding we can not change the block diagram of the realcode indicators can we?
Bruce_L
Posted : Thursday, August 27, 2009 9:58:21 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
I can't reproduce this. When I create a Block Diagram based Indicators that consists entirely of a Bar Open, Bar High or Bar Low Indicator connected between the Numeric Plot Block and the RealCode Indicator (using Link From Another Tool), they seem to survive restarting StockFinder without any problems.

You can't edit the Block Diagram of a RealCode Indicator, but I don't see why you would be doing so. The Block Diagram based Indicators using Bar Open, Bar High or Bar Low are created from scratch, not from editing a RealCode Indicator.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Thursday, August 27, 2009 10:54:55 AM
Platinum Customer Platinum Customer

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

After creating the indicator (Lets call it Auto Lin Reg) in your Tuesday, August 25, 2009 12:21:52 PM post I drag and drop it to price pane same scale.
 
Then I copy and paste the Auto LIn Reg 2 more times and in one block diagram I drag the out put of the RealCode Indicator block to a empty area and let go, the only options I get is Select Block & Connect, Recent and Create Code Block, I don't get LInk Fom Another Tool. 

So far I've been clicking on Select Block and Connect, Bar High and then I connect the Bar high to Numeric Plot. In the other one I do the Bar Low. 

I did this on two machines and the same thing happen they get disconnected after restart of SF.

Did I do anything wrong?

Bruce_L
Posted : Thursday, August 27, 2009 11:00:45 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Don't edit the RealCode Indicator (it is not a Block Diagram based Indicator and the Block Diagram is not editable). You need to create Block Diagram based Indicators that are connected to the RealCode Indicator by left-clicking and dragging on the input to the Bar Open, Bar High or Bar Low Block and selecting Link Data From Another Tool | (your RealCode Indicator).

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Thursday, August 27, 2009 11:28:29 AM
Platinum Customer Platinum Customer

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

Bruce

I might be loosing it but no matter what I do doesn’t work and I was playing with this until 3 in the morning last nigh.

I know I have been using Blocks for 2 years but how do create a Block diagram based indicator that is connected to the real code?

I right clicked on an empty part of the price pane, Create New, Indicator Block Diagram. When the Block diagram comes up I take Bar Chart Price History to Bar High and I still don't get Link From another Tool.

Can you give me the steps please?

Thanks

Bruce_L
Posted : Thursday, August 27, 2009 11:39:08 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
It doesn't have anything at all to do with Price History.

- Right-click on the Chart and select Create New | Indicator Block Diagram.
- Give it a name.
- Set the Plot Type to Numeric.
- Select OK.
- Left-click and Drag on the input to the Numeric Plot Block.
- Select Select Block & Connect | Bar Open, Bar High or Bar Close | OK.
- Left-click and Drag on the input to the Bar Open, Bar High or Bar Close Block.
- Select Link From Another Tool | (your RealCode Indicator).

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Thursday, August 27, 2009 11:53:14 AM
Platinum Customer Platinum Customer

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

I guess this happens when you spend 15 hours behind computers everyday.

Bruce_L
Posted : Thursday, August 27, 2009 11:57:37 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You're welcome.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Thursday, August 27, 2009 12:39:35 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
I reversed it for the shorts it seems correct just check it to see if I left anything out please.

'# Width = UserInput.Single = 1
Static Count(1) As Single
Static Sum(2) As Single
Static Slope(1) As Single
Static SD(1) As Single
Static EndPoint(1) As Single
Static HighSince As Single
If isFirstBar Then
 Count(0) = Single.NaN
 Count(1) = Single.NaN
 Sum(0) = Single.NaN
 Sum(1) = Single.NaN
 Sum(2) = Single.NaN
 HighSince = Single.NaN
 Slope(1) = Single.NaN
 SD(1) = Single.NaN
 EndPoint(1) = Single.NaN
Else If Price.Low < Price.MinLow(62, 1) Then
 Count(0) = 1
 Count(1) = 1
 Sum(0) = Price.Last
 Sum(1) = Price.Last ^ 2
 Sum(2) = Price.Last
 HighSince = Price.Last
Else
 Count(0) += 1
 Sum(0) += Price.Last
 Sum(1) += Price.Last ^ 2
 Sum(2) += Count(0) * Price.Last
 HighSince = System.Math.Max(HighSince, Price.High)
End If
If Count(0) >= 2 Then
 Slope(0) = (Sum(2) - ((Count(0) + 1) / 2 * Sum(0))) / (Count(0) * (Count(0) ^ 2 - 1) / 12)
 SD(0) = Width * (((Sum(1) - Sum(0) ^ 2 / Count(0)) / Count(0)) ^ .5)
 EndPoint(0) = Sum(0) / Count(0) + (Count(0) - 1) * Slope(0) / 2
 If Price.High = HighSince Then
  Count(1) = 0
  Slope(1) = Slope(0)
  SD(1) = SD(0)
  EndPoint(1) = EndPoint(0)
  For i As Integer = 0 To Count(0) - 1
   If Price.Last(i) <= EndPoint(0) - Slope(0) * i + SD(0) AndAlso _
    Price.Last(i) >= EndPoint(0) - Slope(0) * i - SD(0) Then
    Count(1) += 1
   End If  
  Next
 Else
  EndPoint(1) += Slope(1)
  If Price.Last <= EndPoint(1) + SD(1) AndAlso _
   Price.Last >= EndPoint(1) - SD(1) Then
   Count(1) += 1
  End If  
 End If
Else
 Slope(0) = 0
 SD(0) = 0
 EndPoint(0) = Price.Last
 Slope(1) = 0
 SD(1) = 0
 EndPoint(1) = Price.Last
End If
OpenValue = EndPoint(1) - Slope(1)
HighValue = EndPoint(1) + SD(1)
LowValue = EndPoint(1) - SD(1)
Plot = EndPoint(1)
Bruce_L
Posted : Thursday, August 27, 2009 12:49:41 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
I don't see anything else you would need to change. It seems to work as expected when I try it on my computer.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Friday, September 4, 2009 2:05:06 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
Bruce in your post on Tuesday, August 25, 2009 12:21:52 PM the Auto Lin Reg. 

In order for me to change this so that it will use SD in % do I only need to change the line below which is line 34 in the realcode.

SD(0) = Width * (((Sum(1) - Sum(0) ^ 2 / Count(0)) / Count(0)) ^ .5)

This is currently plotting the channels using the SD in Points to change this to SD in % do I just need to divide this with the SMA of whatever the length of the Lin Reg happens to be?
Bruce_L
Posted : Friday, September 4, 2009 2:10:17 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Either I'm seriously misunderstanding something or you are (maybe we both are). You would seem to need values if you are trying to determine if the something is between the bands or not.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Friday, September 4, 2009 2:57:17 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
No this is not the % in channel.

This is the realcode you  wrote to plot a moving Lin Reg. Then we created two block diagrams with Bar high and Bar low to plot the Upper and Lower channel at let say 2 SD away from the Lin Reg.

Take a look at the chart I just shared under LR. This is plotting the Lin Reg from bottom to top I have the Lin Reg manually drawn as well. Honestly I am stunned how accurate your realcode is.

Take a look at LVS from the Lows of July 8th to present please. You see how the Upper and Lower channel continues to expand and this is because as the stock moves higher the Points that it moves of course gets bigger. But 0.50 cents move when it was at 7 is the same as 1 point move when it is at 14. 

I have the regular SD indicator and the one that plotts in % plotted in the bottom 2 panes with a 41 day period since from 7/8 to today is 41 days. You see how the regular SD is back to almost the highs of May around 2.50 but the one in % is no where near that level. I understand that the one in % has increased from .11 to .22 during this period but it is clearly obvious that the deviation in the recent few weeks is far less than the deviation during the May highs but the regular SD is showing almost the same value. I also drew two trend lines in Aqua on the chart to show that the stock is in a very tight trend since 7/8. 
 
The SD that the Auto Lin Reg indicator is measuring is in dollar amount or points (regular SD). what I was trying to accomplish is normalize the SD by dividing it by the mean of that period (SD in %).

Put it this way in order for me to sell the stock it needs to break below the lower LR channel which you can see is far away from where price is but if we change this to % SD the lines won't expamd like this as price goes higher. This will lower my drawdowns significantly

Thanks

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.