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 |

PCF for Percent Drawdown Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
traderlady
Posted : Monday, September 9, 2013 6:53:07 PM
Registered User
Joined: 10/7/2004
Posts: 1,178

Please provide a PCF that calculates the maximum percent drawdown from the Maximum Close to the Minimum Close with the most recent 63-day period.

Bruce_L
Posted : Tuesday, September 10, 2013 9:48:32 AM


Worden Trainer

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

An Indicator Formula which just uses the maximum close and minimum close over the most recent 63-bars would be:

100 * (MINC63 / MAXC63 - 1)

An Indicator Formula which checks for the maximum drawdown since the most recent time the closing price was at its maximum over the most recent 63-bars would be:

100 * ((ABS(C = MAXC63) * C + ABS(C < MAXC63) * (ABS(C1 = MAXC63) * C + ABS(C1 < MAXC63) * (ABS(C2 = MAXC63) * MINC2 + ABS(C2 < MAXC63) * (ABS(C3 = MAXC63) * MINC3 + ABS(C3 < MAXC63) * (ABS(C4 = MAXC63) * MINC4 + ABS(C4 < MAXC63) * (ABS(C5 = MAXC63) * MINC5 + ABS(C5 < MAXC63) * (ABS(C6 = MAXC63) * MINC6 + ABS(C6 < MAXC63) * (ABS(C7 = MAXC63) * MINC7 + ABS(C7 < MAXC63) * (ABS(C8 = MAXC63) * MINC8 + ABS(C8 < MAXC63) * (ABS(C9 = MAXC63) * MINC9 + ABS(C9 < MAXC63) * (ABS(C10 = MAXC63) * MINC10 + ABS(C10 < MAXC63) * (ABS(C11 = MAXC63) * MINC11 + ABS(C11 < MAXC63) * (ABS(C12 = MAXC63) * MINC12 + ABS(C12 < MAXC63) * (ABS(C13 = MAXC63) * MINC13 + ABS(C13 < MAXC63) * (ABS(C14 = MAXC63) * MINC14 + ABS(C14 < MAXC63) * (ABS(C15 = MAXC63) * MINC15 + ABS(C15 < MAXC63) * (ABS(C16 = MAXC63) * MINC16 + ABS(C16 < MAXC63) * (ABS(C17 = MAXC63) * MINC17 + ABS(C17 < MAXC63) * (ABS(C18 = MAXC63) * MINC18 + ABS(C18 < MAXC63) * (ABS(C19 = MAXC63) * MINC19 + ABS(C19 < MAXC63) * (ABS(C20 = MAXC63) * MINC20 + ABS(C20 < MAXC63) * (ABS(C21 = MAXC63) * MINC21 + ABS(C21 < MAXC63) * (ABS(C22 = MAXC63) * MINC22 + ABS(C22 < MAXC63) * (ABS(C23 = MAXC63) * MINC23 + ABS(C23 < MAXC63) * (ABS(C24 = MAXC63) * MINC24 + ABS(C24 < MAXC63) * (ABS(C25 = MAXC63) * MINC25 + ABS(C25 < MAXC63) * (ABS(C26 = MAXC63) * MINC26 + ABS(C26 < MAXC63) * (ABS(C27 = MAXC63) * MINC27 + ABS(C27 < MAXC63) * (ABS(C28 = MAXC63) * MINC28 + ABS(C28 < MAXC63) * (ABS(C29 = MAXC63) * MINC29 + ABS(C29 < MAXC63) * (ABS(C30 = MAXC63) * MINC30 + ABS(C30 < MAXC63) * (ABS(C31 = MAXC63) * MINC31 + ABS(C31 < MAXC63) * (ABS(C32 = MAXC63) * MINC32 + ABS(C32 < MAXC63) * (ABS(C33 = MAXC63) * MINC33 + ABS(C33 < MAXC63) * (ABS(C34 = MAXC63) * MINC34 + ABS(C34 < MAXC63) * (ABS(C35 = MAXC63) * MINC35 + ABS(C35 < MAXC63) * (ABS(C36 = MAXC63) * MINC36 + ABS(C36 < MAXC63) * (ABS(C37 = MAXC63) * MINC37 + ABS(C37 < MAXC63) * (ABS(C38 = MAXC63) * MINC38 + ABS(C38 < MAXC63) * (ABS(C39 = MAXC63) * MINC39 + ABS(C39 < MAXC63) * (ABS(C40 = MAXC63) * MINC40 + ABS(C40 < MAXC63) * (ABS(C41 = MAXC63) * MINC41 + ABS(C41 < MAXC63) * (ABS(C42 = MAXC63) * MINC42 + ABS(C42 < MAXC63) * (ABS(C43 = MAXC63) * MINC43 + ABS(C43 < MAXC63) * (ABS(C44 = MAXC63) * MINC44 + ABS(C44 < MAXC63) * (ABS(C45 = MAXC63) * MINC45 + ABS(C45 < MAXC63) * (ABS(C46 = MAXC63) * MINC46 + ABS(C46 < MAXC63) * (ABS(C47 = MAXC63) * MINC47 + ABS(C47 < MAXC63) * (ABS(C48 = MAXC63) * MINC48 + ABS(C48 < MAXC63) * (ABS(C49 = MAXC63) * MINC49 + ABS(C49 < MAXC63) * (ABS(C50 = MAXC63) * MINC50 + ABS(C50 < MAXC63) * (ABS(C51 = MAXC63) * MINC51 + ABS(C51 < MAXC63) * (ABS(C52 = MAXC63) * MINC52 + ABS(C52 < MAXC63) * (ABS(C53 = MAXC63) * MINC53 + ABS(C53 < MAXC63) * (ABS(C54 = MAXC63) * MINC54 + ABS(C54 < MAXC63) * (ABS(C55 = MAXC63) * MINC55 + ABS(C55 < MAXC63) * (ABS(C56 = MAXC63) * MINC56 + ABS(C56 < MAXC63) * (ABS(C57 = MAXC63) * MINC57 + ABS(C57 < MAXC63) * (ABS(C58 = MAXC63) * MINC58 + ABS(C58 < MAXC63) * (ABS(C59 = MAXC63) * MINC59 + ABS(C59 < MAXC63) * (ABS(C60 = MAXC63) * MINC60 + ABS(C60 < MAXC63) * (ABS(C61 = MAXC63) * MINC61 + ABS(C61 < MAXC63) * (ABS(C62 = MAXC63) * MINC62))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) / MAXC63 - 1)

An Indicator Formula for the actual maximum drawdown over the most recent 63-bars would be too long and slow to be practical or post in the forums.

Days Since Last Peak (or other day-counting needs)



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
sturner
Posted : Wednesday, April 30, 2014 9:39:23 AM
Registered User
Joined: 12/31/2004
Posts: 102

Bruce, I found this formula in post above (the max "drawdown" in a rolling 63-bar period) and I wanted to flip it to a RELATIVE drawdown to the sp-500... how may I tweak it to show the relative version?

I searched for something like that and couldn't find one- thanks for your help!

-Sam  

 
Bruce_L
Posted : Wednesday, April 30, 2014 11:02:46 AM


Worden Trainer

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

The Personal Criteria Formula Language does not have syntax for referencing other symbols. This means there really isn't a good way to create a relative drawdown compared to another symbol.

The following topics go over a semi-automated method of including other symbols in a Personal Criteria Formula, but it requires quite a bit of manual work each day (or at each bar when not creating a daily formula).

Indexes in PCF's
RSMA PCFs



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
sturner
Posted : Wednesday, April 30, 2014 11:53:13 AM
Registered User
Joined: 12/31/2004
Posts: 102

What about StockFinder... I have that running too... could I do it in that format? (one reason I added StockFinder was to do more robust calculatons)   

 

Bruce_L
Posted : Wednesday, April 30, 2014 12:08:13 PM


Worden Trainer

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

I don't see any problem with doing this sort of thing in StockFinder. That said, I would probably need further input from you as to how you want to calculate relative drawdown.

Are we just looking at a Relative Strength line and calculating on the relative strength line or do you have something more complex in mind?



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
sturner
Posted : Wednesday, April 30, 2014 12:23:23 PM
Registered User
Joined: 12/31/2004
Posts: 102

same exact thing as above (max dd trailing 63 bars) but only on RS (v sp-500) and not absolute...

sturner
Posted : Wednesday, April 30, 2014 1:50:10 PM
Registered User
Joined: 12/31/2004
Posts: 102

Should I ask the question above in the StockFinder forum?

Bruce_L
Posted : Thursday, May 1, 2014 10:30:58 AM


Worden Trainer

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

Please try the following RealCode Indicator:

'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com 
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:Relative Drawdown
'|******************************************************************
Static Period As Integer = 63
Static SP500 As PriceScripting
Static Max As Single
Static Count As Integer
Static MinSince As Single
Static RS As New List(Of Single)
If isFirstBar Then
	SP500 = PriceData("SP-500") 
	Max = Single.MinValue
	Count = 0
	MinSince = Single.MaxValue
	RS.Clear
End If
RS.Insert(0, Price.Last / SP500.Value)
If RS(0) > Max Then
	Max = RS(0)
	Count = 1
	MinSince = RS(0)
Else If Max = RS(0)
	Count += 1
	MinSince = RS(0)
Else If RS(0) < MinSince Then
	MinSince = RS(0)
End If
If RS.Count > Period Then
	If RS(Period) = Max Then
		Count -= 1
	End If
	RS.RemoveAt(Period)
	If Count = 0 Then
		Max = RS(Period - 1)
		Count = 1
		MinSince = RS(Period - 1)
		For i As Integer = Period - 2 To 0 Step -1
			If RS(i) > Max Then
				Max = RS(i)
				Count = 1
				MinSince = RS(i)
			Else If RS(i) = Max Then
				Count += 1
				MinSince = RS(i)
			Else If RS(i) < MinSince Then
				MinSince = RS(i)
			End If
		Next
	End If
End If
If RS.Count = Period Then
	Plot = 100 * (MinSince / Max - 1)
Else
	Plot = Single.NaN
End If
If isLastBar Then
	RS.Clear
End If

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