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 |

Eliminating Flash Crash From Real Code Indicator Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
Royal
Posted : Monday, January 23, 2012 10:04:57 AM
Platinum Customer Platinum Customer

Joined: 10/7/2004
Posts: 127
Bruce, Can you provide a solution to eliminating the flash crash from the indicator below? Its really screwing up my scans since several of the ETFs are in a downtrend per this one data point. '|****************************************************************** '|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com '|*** Copy and paste this header and code into StockFinder ********* '|*** Indicator: Market Key '|****************************************************************** '# ATRperiod = UserInput.Single = 14 '# Cumulative Static TR As Single Static ATR As Single Static termRatio As Single static Weight As Single Static sumWeight As Single Static NR As Single Static NRe As Single Static UT(1) As Single Static DT(1) As Single If isFirstBar Then TR = Price.High - Price.Low termRatio = (ATRperiod - 1) / ATRperiod ATR = TR sumWeight = termRatio + 1 Weight = 1 / sumWeight NR = 0 NRe = 0 UT(0) = 0 DT(0) = 0 Else TR = (Price.High - Price.Low + _ Math.Abs(Price.High - Price.Last(1)) + _ Math.Abs(Price.Last(1) - Price.Low)) / 2 ATR = ATR * (1 - Weight) + Weight * TR sumWeight = sumWeight * termRatio + 1 Weight = 1 / sumWeight End If UT(1) = UT(0) DT(1) = DT(0) If Price.Last > 30 If Price.High > UT(1) Then NRe = Price.High - 2 * ATR DT(0) = NRe - ATR NR = Price.High UT(0) = Price.High End If If Price.Low < DT(1) Then NR = DT(0) + 2 * ATR UT(0) = NR + ATR NRe = Price.Low DT(0) = Price.Low End If Else If Price.Last >= 10 Then If Price.High > UT(1) Then NRe = Price.High - 2 DT(0) = NRe - ATR NR = Price.High UT(0) = Price.High End If If Price.Low < DT(1) Then NR = DT(0) + 2 * ATR UT(0) = NR + ATR NRe = Price.Low DT(0) = Price.Low End If Else If Price.High > UT(1) Then NRe = Price.High - 2 * ATR DT(0) = NRe - ATR NR = Price.High UT(0) = Price.High End If If Price.low < DT(1) Then NR = DT(0) + 2 * ATR UT(0) = NR + ATR NRe = Price.low DT(0) = Price.low End If End If OpenValue = DT(0) HighValue = UT(0) LowValue = NR Plot = NRe Thanks Bruce! Royal.
Royal
Posted : Monday, January 23, 2012 10:33:37 AM
Platinum Customer Platinum Customer

Joined: 10/7/2004
Posts: 127
Bruce, that copy and paste looks like a nightmare. All I wanted to know is if I could eliminate May 6th (flash crash) from my charts or from this indicator. I wouldn't mind editing the programs data to change the low for this date = the close (since most positions came back right away. Is that a possibility? If not then I'd just like to know how to remove it from the Real Code Indicator I pasted above.
Bruce_L
Posted : Monday, January 23, 2012 11:10:51 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
There isn't a way to edit the data, but it is possible to adjust the RealCode Indicator to not calculate or plot on 5/6/2010 on a Daily Chart:

'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:Livermore Market Key
'|******************************************************************
'# ATRperiod = UserInput.Single = 14
'# Cumulative
Static FlashCrash As Date = #5/6/2010 4:00 PM#
Static TR As Single
Static ATR As Single
Static termRatio As Single
static Weight As Single
Static sumWeight As Single
Static NR As Single
Static NRe As Single
Static UT(1) As Single
Static DT(1) As Single
If Price.DateValue = FlashCrash Then
    If isFirstBar Then
        TR = Price.High(-1) - Price.Low(-1)
        termRatio = (ATRperiod - 1) / ATRperiod
        ATR = TR
        sumWeight = 1
        Weight = 1 / sumWeight
        NR = 0
        NRe = 0
        UT(0) = 0
        DT(0) = 0
    End If
    OpenValue = Single.NaN
    HighValue = Single.NaN
    LowValue = Single.NaN
    Plot = Single.NaN
Else
    If isFirstBar Then
        TR = Price.High - Price.Low
        termRatio = (ATRperiod - 1) / ATRperiod
        ATR = TR
        sumWeight = termRatio + 1
        Weight = 1 / sumWeight
        NR = 0
        NRe = 0
        UT(0) = 0
        DT(0) = 0
    Else
        TR = (Price.High - Price.Low + _
            Math.Abs(Price.High - Price.Last(1)) + _
            Math.Abs(Price.Last(1) - Price.Low)) / 2
        ATR = ATR * (1 - Weight) + Weight * TR
        sumWeight = sumWeight * termRatio + 1
        Weight = 1 / sumWeight
    End If
    UT(1) = UT(0)
    DT(1) = DT(0)
    If Price.Last > 30
        If Price.High > UT(1) Then
            NRe = Price.High - 2 * ATR
            DT(0) = NRe - ATR
            NR = Price.High
            UT(0) = Price.High
        End If
        If    Price.Low < DT(1) Then
            NR = DT(0) + 2 * ATR
            UT(0) = NR + ATR
            NRe = Price.Low
            DT(0) = Price.Low
        End If
    Else If Price.Last >= 10 Then
        If Price.High > UT(1) Then
            NRe = Price.High - 2
            DT(0) = NRe - ATR
            NR = Price.High
            UT(0) = Price.High
        End If
        If Price.Low < DT(1) Then
            NR = DT(0) + 2 * ATR
            UT(0) = NR + ATR
            NRe = Price.Low
            DT(0) = Price.Low
        End If
    Else
        If Price.High > UT(1) Then
            NRe = Price.High - 2 * ATR
            DT(0) = NRe - ATR
            NR = Price.High
            UT(0) = Price.High
        End If
        If Price.Low < DT(1) Then
            NR = DT(0) + 2 * ATR
            UT(0) = NR + ATR
            NRe = Price.Low
            DT(0) = Price.Low
        End If
    End If
    OpenValue = DT(0)
    HighValue = UT(0)
    LowValue = NR
    Plot = NRe
End If

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Royal
Posted : Tuesday, January 24, 2012 7:42:04 AM
Platinum Customer Platinum Customer

Joined: 10/7/2004
Posts: 127
Bruce, i typically only use this indicator on the weekly timeframe setting, is there a way to eliminate it from that data as well? I would be okay with eliminating the entire week if need be. If this is not possible then id like to edit the realcode to only calculate based off of the highest and lowest closes instead on the intaday highs and lows. Thanks a ton for everything that you do.Royal
Bruce_L
Posted : Tuesday, January 24, 2012 9:10:21 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Just change:

Static FlashCrash As Date = #5/6/2010 4:00 PM#

To:

Static FlashCrash As Date = #5/7/2010 4:00 PM#

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Royal
Posted : Tuesday, January 24, 2012 11:53:01 AM
Platinum Customer Platinum Customer

Joined: 10/7/2004
Posts: 127
How do I incorporate this code with the original indicator code?When i load that on a chart I just get one line as opposed to 4 lines with the original one. (NRe, NR, UT, DT).
Bruce_L
Posted : Tuesday, January 24, 2012 12:01:28 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Edit the original indicator and replace the RealCode with the new RealCode. Then save it with a different name if you want both indicators.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Royal
Posted : Tuesday, January 24, 2012 12:16:48 PM
Platinum Customer Platinum Customer

Joined: 10/7/2004
Posts: 127
Im not sure what I'm supposed to replace.
Bruce_L
Posted : Tuesday, January 24, 2012 12:21:03 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

From the indicator where you copied the RealCode initially.

Right-click on the NRe indicator and select Edit RealCode. Then replace the old Static FlashCrash As Date line with the new Static FlashCrash As Date line.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Royal
Posted : Friday, September 4, 2015 12:36:57 PM
Platinum Customer Platinum Customer

Joined: 10/7/2004
Posts: 127
Bruce, How can I eliminate the low on 8/24/2015 (weekly date 8/28/2015) from the indicator in this thread? I'd like to keep the "flash crash" (5/7/2015) eliminated as well. Below is the code that I'm working with. '|****************************************************************** '|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com '|*** Copy and paste this header and code into StockFinder ********* '|*** Indicator:My Indicator '|*** Example: plot = price.close - price.close(1) '|****************************************************************** '# ATRperiod = UserInput.Single = 14 '# Cumulative Static FlashCrash As Date = #5/7/2010 4:00 PM# Static TR As Single Static ATR As Single Static termRatio As Single static Weight As Single Static sumWeight As Single Static NR As Single Static NRe As Single Static UT(1) As Single Static DT(1) As Single If Price.DateValue = FlashCrash Then If isFirstBar Then TR = Price.High(-1) - Price.Low(-1) termRatio = (ATRperiod - 1) / ATRperiod ATR = TR sumWeight = 1 Weight = 1 / sumWeight NR = 0 NRe = 0 UT(0) = 0 DT(0) = 0 End If OpenValue = Single.NaN HighValue = Single.NaN LowValue = Single.NaN Plot = Single.NaN Else If isFirstBar Then TR = Price.High - Price.Low termRatio = (ATRperiod - 1) / ATRperiod ATR = TR sumWeight = termRatio + 1 Weight = 1 / sumWeight NR = 0 NRe = 0 UT(0) = 0 DT(0) = 0 Else TR = (Price.High - Price.Low + _ Math.Abs(Price.High - Price.Last(1)) + _ Math.Abs(Price.Last(1) - Price.Low)) / 2 ATR = ATR * (1 - Weight) + Weight * TR sumWeight = sumWeight * termRatio + 1 Weight = 1 / sumWeight End If UT(1) = UT(0) DT(1) = DT(0) If Price.Last > 30 If Price.High > UT(1) Then NRe = Price.High - 2 * ATR DT(0) = NRe - ATR NR = Price.High UT(0) = Price.High End If If Price.Low = 10 Then If Price.High > UT(1) Then NRe = Price.High - 2 DT(0) = NRe - ATR NR = Price.High UT(0) = Price.High End If If Price.Low UT(1) Then NRe = Price.High - 2 * ATR DT(0) = NRe - ATR NR = Price.High UT(0) = Price.High End If If Price.Low
Royal
Posted : Friday, September 4, 2015 12:40:18 PM
Platinum Customer Platinum Customer

Joined: 10/7/2004
Posts: 127

Bruce, here is a cleaner copy.  Again, How can I eliminate the low on 8/24/2015 (weekly date 8/28/2015) from the indicator in this thread? I'd like to keep the "flash crash" (5/7/2015) eliminated as well. Below is the code that I'm working with. 

'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com 
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:My Indicator
'|*** Example: plot = price.close - price.close(1)
'|******************************************************************
'# ATRperiod = UserInput.Single = 14
'# Cumulative
Static FlashCrash As Date = #5/7/2010 4:00 PM#
Static TR As Single
Static ATR As Single
Static termRatio As Single
static Weight As Single
Static sumWeight As Single
Static NR As Single 
Static NRe As Single
Static UT(1) As Single 
Static DT(1) As Single
If Price.DateValue = FlashCrash Then
    If isFirstBar Then
        TR = Price.High(-1) - Price.Low(-1)
        termRatio = (ATRperiod - 1) / ATRperiod
        ATR = TR
        sumWeight = 1
        Weight = 1 / sumWeight
        NR = 0
        NRe = 0
        UT(0) = 0
        DT(0) = 0
    End If
    OpenValue = Single.NaN
    HighValue = Single.NaN
    LowValue = Single.NaN
    Plot = Single.NaN
Else
    If isFirstBar Then
        TR = Price.High - Price.Low
        termRatio = (ATRperiod - 1) / ATRperiod
        ATR = TR
        sumWeight = termRatio + 1
        Weight = 1 / sumWeight
        NR = 0
        NRe = 0
        UT(0) = 0
        DT(0) = 0
    Else
        TR = (Price.High - Price.Low + _
            Math.Abs(Price.High - Price.Last(1)) + _
            Math.Abs(Price.Last(1) - Price.Low)) / 2
        ATR = ATR * (1 - Weight) + Weight * TR
        sumWeight = sumWeight * termRatio + 1
        Weight = 1 / sumWeight
    End If
    UT(1) = UT(0)
    DT(1) = DT(0)
    If Price.Last > 30
        If Price.High > UT(1) Then
            NRe = Price.High - 2 * ATR
            DT(0) = NRe - ATR
            NR = Price.High
            UT(0) = Price.High
        End If
        If    Price.Low < DT(1) Then
            NR = DT(0) + 2 * ATR
            UT(0) = NR + ATR
            NRe = Price.Low
            DT(0) = Price.Low
        End If 
    Else If Price.Last >= 10 Then
        If Price.High > UT(1) Then
            NRe = Price.High - 2
            DT(0) = NRe - ATR
            NR = Price.High
            UT(0) = Price.High
        End If
        If Price.Low < DT(1) Then
            NR = DT(0) + 2 * ATR
            UT(0) = NR + ATR
            NRe = Price.Low
            DT(0) = Price.Low
        End If
    Else
        If Price.High > UT(1) Then
            NRe = Price.High - 2 * ATR
            DT(0) = NRe - ATR
            NR = Price.High
            UT(0) = Price.High
        End If
        If Price.Low < DT(1) Then
            NR = DT(0) + 2 * ATR
            UT(0) = NR + ATR
            NRe = Price.Low
            DT(0) = Price.Low
        End If
    End If
    OpenValue = DT(0)
    HighValue = UT(0)
    LowValue = NR
    Plot = NRe
End If

Bruce_L
Posted : Friday, September 4, 2015 1:51:04 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

Maybe something like the following?

'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com 
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:My Indicator
'|*** Example: plot = price.close - price.close(1)
'|******************************************************************
'# ATRperiod = UserInput.Single = 14
'# Cumulative
Static FlashCrash(1) As Date
FlashCrash(0) = #5/7/2010 4:00 PM#
FlashCrash(1) = #8/28/2015 4:00 PM#
Static TR As Single
Static ATR As Single
Static termRatio As Single
static Weight As Single
Static sumWeight As Single
Static NR As Single 
Static NRe As Single
Static UT(1) As Single 
Static DT(1) As Single
If Price.DateValue = FlashCrash(0) OrElse _
	Price.DateValue = FlashCrash(1) Then
	If isFirstBar Then
		TR = Price.High(-1) - Price.Low(-1)
		termRatio = (ATRperiod - 1) / ATRperiod
		ATR = TR
		sumWeight = 1
		Weight = 1 / sumWeight
		NR = 0
		NRe = 0
		UT(0) = 0
		DT(0) = 0
	End If
	OpenValue = Single.NaN
	HighValue = Single.NaN
	LowValue = Single.NaN
	Plot = Single.NaN
Else
	If isFirstBar Then
		TR = Price.High - Price.Low
		termRatio = (ATRperiod - 1) / ATRperiod
		ATR = TR
		sumWeight = termRatio + 1
		Weight = 1 / sumWeight
		NR = 0
		NRe = 0
		UT(0) = 0
		DT(0) = 0
	Else
		TR = (Price.High - Price.Low + _
			Math.Abs(Price.High - Price.Last(1)) + _
			Math.Abs(Price.Last(1) - Price.Low)) / 2
		ATR = ATR * (1 - Weight) + Weight * TR
		sumWeight = sumWeight * termRatio + 1
		Weight = 1 / sumWeight
	End If
	UT(1) = UT(0)
	DT(1) = DT(0)
	If Price.Last > 30
		If Price.High > UT(1) Then
			NRe = Price.High - 2 * ATR
			DT(0) = NRe - ATR
			NR = Price.High
			UT(0) = Price.High
		End If
		If    Price.Low < DT(1) Then
			NR = DT(0) + 2 * ATR
			UT(0) = NR + ATR
			NRe = Price.Low
			DT(0) = Price.Low
		End If 
	Else If Price.Last >= 10 Then
		If Price.High > UT(1) Then
			NRe = Price.High - 2
			DT(0) = NRe - ATR
			NR = Price.High
			UT(0) = Price.High
		End If
		If Price.Low < DT(1) Then
			NR = DT(0) + 2 * ATR
			UT(0) = NR + ATR
			NRe = Price.Low
			DT(0) = Price.Low
		End If
	Else
		If Price.High > UT(1) Then
			NRe = Price.High - 2 * ATR
			DT(0) = NRe - ATR
			NR = Price.High
			UT(0) = Price.High
		End If
		If Price.Low < DT(1) Then
			NR = DT(0) + 2 * ATR
			UT(0) = NR + ATR
			NRe = Price.Low
			DT(0) = Price.Low
		End If
	End If
	OpenValue = DT(0)
	HighValue = UT(0)
	LowValue = NR
	Plot = NRe
End If


-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Royal
Posted : Tuesday, September 8, 2015 5:32:29 AM
Platinum Customer Platinum Customer

Joined: 10/7/2004
Posts: 127

Bruce, instead of ignoring the entire week that ended 8/28, can we use the close for that week?  I'd like to capture the volatiity of the week and lower close, just not the erratic trading that generated the flash crash II. 

Bruce_L
Posted : Thursday, September 10, 2015 11:15:40 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

What specifically do you want to do? Just leave out the low and only include the open, high and close in the calculations of the new ATR?



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Royal
Posted : Thursday, September 10, 2015 11:20:56 AM
Platinum Customer Platinum Customer

Joined: 10/7/2004
Posts: 127

Yes, I want to eliminate the long tail from that day by removing the day/weeks low from the atr calc. 

Bruce_L
Posted : Thursday, September 10, 2015 11:27:09 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

Maybe something like the following?

'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com 
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:My Indicator
'|******************************************************************
'# ATRperiod = UserInput.Single = 14
'# Cumulative
Static FlashCrash(1) As Date
FlashCrash(0) = #5/7/2010 4:00 PM#
FlashCrash(1) = #8/28/2015 4:00 PM#
Static TR As Single
Static ATR As Single
Static termRatio As Single
static Weight As Single
Static sumWeight As Single
Static NR As Single 
Static NRe As Single
Static UT(1) As Single 
Static DT(1) As Single
If isFirstBar Then
	TR = Price.High - Price.Low
	termRatio = (ATRperiod - 1) / ATRperiod
	ATR = TR
	sumWeight = termRatio + 1
	Weight = 1 / sumWeight
	NR = 0
	NRe = 0
	UT(0) = 0
	DT(0) = 0
Else If Price.DateValue = FlashCrash(0) OrElse _
	Price.DateValue = FlashCrash(1) Then
	Dim Low As Single = Math.Min(Price.Last, Price.Open)
	TR = (Price.High - Low + _
		Math.Abs(Price.High - Price.Last(1)) + _
		Math.Abs(Price.Last(1) - Low)) / 2
	ATR = ATR * (1 - Weight) + Weight * TR
	sumWeight = sumWeight * termRatio + 1
	Weight = 1 / sumWeight	
Else
	TR = (Price.High - Price.Low + _
		Math.Abs(Price.High - Price.Last(1)) + _
		Math.Abs(Price.Last(1) - Price.Low)) / 2
	ATR = ATR * (1 - Weight) + Weight * TR
	sumWeight = sumWeight * termRatio + 1
	Weight = 1 / sumWeight
End If
UT(1) = UT(0)
DT(1) = DT(0)
If Price.Last > 30
	If Price.High > UT(1) Then
		NRe = Price.High - 2 * ATR
		DT(0) = NRe - ATR
		NR = Price.High
		UT(0) = Price.High
	End If
	If    Price.Low < DT(1) Then
		NR = DT(0) + 2 * ATR
		UT(0) = NR + ATR
		NRe = Price.Low
		DT(0) = Price.Low
	End If 
Else If Price.Last >= 10 Then
	If Price.High > UT(1) Then
		NRe = Price.High - 2
		DT(0) = NRe - ATR
		NR = Price.High
		UT(0) = Price.High
	End If
	If Price.Low < DT(1) Then
		NR = DT(0) + 2 * ATR
		UT(0) = NR + ATR
		NRe = Price.Low
		DT(0) = Price.Low
	End If
Else
	If Price.High > UT(1) Then
		NRe = Price.High - 2 * ATR
		DT(0) = NRe - ATR
		NR = Price.High
		UT(0) = Price.High
	End If
	If Price.Low < DT(1) Then
		NR = DT(0) + 2 * ATR
		UT(0) = NR + ATR
		NRe = Price.Low
		DT(0) = Price.Low
	End If
End If
OpenValue = DT(0)
HighValue = UT(0)
LowValue = NR
Plot = NRe


-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Royal
Posted : Friday, September 11, 2015 2:03:20 PM
Platinum Customer Platinum Customer

Joined: 10/7/2004
Posts: 127

Bruce, the last one that you posted still uses the low from the week of 8/28/15.  Can you check the coding?  I really appreciate your help with this.

 

AJ

Bruce_L
Posted : Friday, September 11, 2015 2:31:59 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

I've only had the calculation of the ATR inside the date check before. I've moved pretty much everything besides the actual output inside of it now. I don't know if it will do what you want or not.

'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com 
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:My Indicator
'|*** Example: plot = price.close - price.close(1)
'|******************************************************************
'# ATRperiod = UserInput.Single = 14
'# Cumulative
Static FlashCrash(1) As Date
FlashCrash(0) = #5/7/2010 4:00 PM#
FlashCrash(1) = #8/28/2015 4:00 PM#
Static TR As Single
Static ATR As Single
Static termRatio As Single
static Weight As Single
Static sumWeight As Single
Static NR As Single 
Static NRe As Single
Static UT(1) As Single 
Static DT(1) As Single
If isFirstBar Then
	TR = Price.High - Price.Low
	termRatio = (ATRperiod - 1) / ATRperiod
	ATR = TR
	sumWeight = termRatio + 1
	Weight = 1 / sumWeight
	NR = 0
	NRe = 0
	UT(0) = 0
	DT(0) = 0
Else If Price.DateValue = FlashCrash(0) OrElse _
	Price.DateValue = FlashCrash(1) Then
	Dim Low As Single = Math.Min(Price.Last, Price.Open)
	TR = (Price.High - Low + _
		Math.Abs(Price.High - Price.Last(1)) + _
		Math.Abs(Price.Last(1) - Low)) / 2
	ATR = ATR * (1 - Weight) + Weight * TR
	sumWeight = sumWeight * termRatio + 1
	Weight = 1 / sumWeight
	UT(1) = UT(0)
	DT(1) = DT(0)
	If Price.Last > 30
		If Price.High > UT(1) Then
			NRe = Price.High - 2 * ATR
			DT(0) = NRe - ATR
			NR = Price.High
			UT(0) = Price.High
		End If
		If Low < DT(1) Then
			NR = DT(0) + 2 * ATR
			UT(0) = NR + ATR
			NRe = Low
			DT(0) = Low
		End If 
	Else If Price.Last >= 10 Then
		If Price.High > UT(1) Then
			NRe = Price.High - 2
			DT(0) = NRe - ATR
			NR = Price.High
			UT(0) = Price.High
		End If
		If Low < DT(1) Then
			NR = DT(0) + 2 * ATR
			UT(0) = NR + ATR
			NRe = Low
			DT(0) = Low
		End If
	Else
		If Price.High > UT(1) Then
			NRe = Price.High - 2 * ATR
			DT(0) = NRe - ATR
			NR = Price.High
			UT(0) = Price.High
		End If
		If Low < DT(1) Then
			NR = DT(0) + 2 * ATR
			UT(0) = NR + ATR
			NRe = Low
			DT(0) = Low
		End If
	End If
Else
	TR = (Price.High - Price.Low + _
		Math.Abs(Price.High - Price.Last(1)) + _
		Math.Abs(Price.Last(1) - Price.Low)) / 2
	ATR = ATR * (1 - Weight) + Weight * TR
	sumWeight = sumWeight * termRatio + 1
	Weight = 1 / sumWeight
	UT(1) = UT(0)
	DT(1) = DT(0)
	If Price.Last > 30
		If Price.High > UT(1) Then
			NRe = Price.High - 2 * ATR
			DT(0) = NRe - ATR
			NR = Price.High
			UT(0) = Price.High
		End If
		If Price.Low < DT(1) Then
			NR = DT(0) + 2 * ATR
			UT(0) = NR + ATR
			NRe = Price.Low
			DT(0) = Price.Low
		End If 
	Else If Price.Last >= 10 Then
		If Price.High > UT(1) Then
			NRe = Price.High - 2
			DT(0) = NRe - ATR
			NR = Price.High
			UT(0) = Price.High
		End If
		If Price.Low < DT(1) Then
			NR = DT(0) + 2 * ATR
			UT(0) = NR + ATR
			NRe = Price.Low
			DT(0) = Price.Low
		End If
	Else
		If Price.High > UT(1) Then
			NRe = Price.High - 2 * ATR
			DT(0) = NRe - ATR
			NR = Price.High
			UT(0) = Price.High
		End If
		If Price.Low < DT(1) Then
			NR = DT(0) + 2 * ATR
			UT(0) = NR + ATR
			NRe = Price.Low
			DT(0) = Price.Low
		End If
	End If
End If
OpenValue = DT(0)
HighValue = UT(0)
LowValue = NR
Plot = NRe


-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.