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 |

Parabolic SAR using ATR Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
thnkbigr
Posted : Monday, August 27, 2007 11:27:23 PM
Platinum Customer Platinum Customer

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

Is this possible in Blocls. This is pretty much the parabolic SAR but it uses ATR to adjust the stop price.

To BUY: When price crosses and closes above 3* the Average True
Range(14) + the Lowest Close reached in the last Short trade.

To SELL: When price crosses and closes below 3* the Average True
Range(14) - the Highest Close reached in the last Long trade

Thanks
Bruce_L
Posted : Tuesday, August 28, 2007 8:56:00 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
It's not clear from your question if you are looking for an indicator like Parabolic SAR or a Stop. Examples of both are provided in the following topics:

Volatility Stop
ATR Stop
Blocks Trailing ATR-based stop

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Tuesday, August 28, 2007 1:13:16 PM
Platinum Customer Platinum Customer

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

From what I read on your 3 attachments above the Blocks Trailing ATR-based stop is what I am looking for but I rather use closing prices only rather than High and Low.

In your explanation you mentioned (The Trailing Stop is based on the High minus the Average True Range with a Width Multiplier). Which High are you talking about. Is it the highest price reached since you are in the long trade? Or a High reached over a certain # of days ago? I am looking for the highest Close reached since I entered the long trade and on the Short side I want the trailing stop to be based on the lowest closing price reached since I entered the short trade + the ATR with a width multiplier.

Thanks

Rob
Bruce_L
Posted : Tuesday, August 28, 2007 1:24:18 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Please download the attached .scond files to:

\My Documents\Blocks Files\Tool Parts\Strategy Conditions

Once downloaded, you should be able to select Add Condition | My Computer when adding a Strategy Condition to access them.

You can use QuickEdit to change the settings or view the Block Diagram.

Attachments:
thnkbigr25145long.scond - 6 KB, downloaded 481 time(s).
thnkbigr25145short.scond - 6 KB, downloaded 464 time(s).



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Tuesday, August 28, 2007 2:05:06 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
Bruce I don't have Strategy Conditions folder I have Backscan Conditions is that the same thing?
Bruce_L
Posted : Tuesday, August 28, 2007 2:08:53 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You can place them in the Backscan Conditions folder, but Blocks will normally default to the Strategy Conditions folder when you attempt to load a Strategy Condition (meaning you would have to navigate to the appropriate folder).

I would suggest making the Strategy Conditions folder. You can either do this manually or by saving a Strategy Condition from within Blocks. You can do this by right-clicking on existing Strategy Condition in a Strategy and selecting Save As.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Tuesday, August 28, 2007 2:20:14 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
ok that's done.

Now let say I want to back test this on nasdaq what do I do?

This is going to be my 1st backtest in Blocks so I don't know what I am doing yet.

also can i plot this as an indicator on the price chart?
Bruce_L
Posted : Tuesday, August 28, 2007 2:42:24 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Trade Stop Conditions can only be used as Exit Conditions. You would need to have an Entry Condition of some sort to run a Strategy.

You can add Conditions to your Strategy by selecting the green plus to the right of Buy, Sell, Sell Short or Cover Short.

Once you have constructed a Strategy, you can test it on the Active Watchlist by selecting Test Strategy for Entire Watchlist (the green funnel between Strategy and Performance). The Performance Tab will then display the results of the Test.

These are not indicators. They are Trade Stop Conditions. Since they rely on having an Entry for calculation, I do not know of a straightforward way to convert them for use as an indicator. The first topic referenced in my Tuesday, August 28, 2007 8:56:00 AM ET post does have an example of a reversal type indicator that is similar to the Trade Stop, but does not rely on an Entry.

The Strategy Trades Plot that is part of the Personal Chartist Workspace in the Web Library will display the entries and exits for the Active Symbol based on the Strategy.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Tuesday, August 28, 2007 3:10:51 PM
Platinum Customer Platinum Customer

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

The Entries are the opposite:

If I am long and I get stopped out at let say 2*ATR14-Highest closing price reached while I was long I go short as well and when I cover my short, that's when I get stopped out at 2*ATR14+Lowest closing price reached while I was short I go long as well.

This is the same concept as SAR but instead of using multiplier of 0.2 and inreasing it everytime price hits a new high it uses ATR to adjust the Stop and Reversal point.

so when you get stopped out of your long you go short as well and when you get stopped out of your short you go long too.

thnkbigr
Posted : Tuesday, August 28, 2007 3:53:24 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
Do I just use the same conditions you gave me for getting stopped out on the long side to start my short and the the one to get stopped out of the short on to go long or the way you have to build the blocks for the entry is different?
Bruce_L
Posted : Tuesday, August 28, 2007 6:00:08 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Please start by creating the following Code Block as Bar to Line with 2 Single Parameters (please keep in mind I'm not a programmer):

Volatility Stop:

Replace everything in the Code Block with (Firefox seems to work for copy and paste, IE does not):

<WBIGuid("b30d41c8-ede7-4ef1-b352-369b693703d2"),FriendlyName("Volatility Stop")> _
Public Class Volatility_Stop
inherits BaseDLBtoDLSPeriod2
Public Overrides Sub calculate()
If InputCount > 1
Dim H As Single = InputHigh(1)
Dim L As Single = InputLow(1)
Dim C As Single = InputLast(0)
Dim H1 As Single = InputHigh(0)
Dim L1 As Single = InputLow(0)
Dim C1 As Single = InputLast(0)
Dim TR As Single = H-L
Dim ATR As Double = 0
Dim period As Integer = ParameterValue1
Dim factor As Single = ParameterValue2
Dim extreme As Single
Dim tstop As Single
Dim state As Integer
If C - System.Math.Min(L,L1) < System.Math.Max(H,H1) - C
extreme = C1
tstop = extreme + factor * TR
state = 0
Else
extreme = C1
tstop = extreme - factor * TR
state = 1
End If
AddToOutput(InputDate(0),tstop)
Dim termratio As Double = (period - 1) / period
Dim weight As Double = 1
Dim sumweight As Double = 1
For bar As Integer = 1 To InputCount - 1
H = InputHigh(bar)
L = InputLow(bar)
C = InputLast(bar)
H1 = InputHigh(bar-1)
L1 = InputLow(bar-1)
C1 = InputLast(bar-1)
TR = (H-L+System.Math.Abs(H-C1)+System.Math.Abs(C1-L))/2
ATR = ATR * (1 - weight) + weight * TR
sumweight = sumweight * termratio + 1
weight = 1 / sumweight
If state
If C < tstop
state = 0
extreme = C
tstop = extreme + factor * ATR
End If
Else
If C > tstop
state = 1
extreme = C
tstop = extreme - factor * ATR
End If
End If
AddToOutput(InputDate(bar),tstop)
If state
extreme = System.Math.Max(extreme,C)
tstop = extreme - factor * ATR
Else
extreme = System.Math.Min(extreme,C)
tstop = extreme + factor * ATR
End If
Next
End If
End Sub
End Class

You may wish to review the following for help with creating Custom Code Blocks:

VB.Net (code block) to color down Monday red
VB.net exercise to access Quickedit from your codeblock
Hello World! Writing Code Blocks in Visual Basic .Net

Once you have created the Custom Code Block, you can save the attached .bWorks file to the following folder:

\My Documents\Blocks Files\Workspaces

You can then open the Workspace via your FILE menu (Open Workspace then My Computer).

It is pretty much a direct copy of the Custom Code Block from my Thursday, December 07, 2006 11:11:59 AM ET post in Volatility Stop with the exception that it adds parameters for the ATR Period and Width.

Attachments:
thnkbigr25145.bWorks - 76 KB, downloaded 447 time(s).



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Tuesday, August 28, 2007 9:31:00 PM
Platinum Customer Platinum Customer

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

Thanks a lot. Created a new code block deleted everything and copied the code block above and then I downloaded your attachment but it never gave me an option where to save it. It opened another workspace and then I saved it. I just want to make sure I did everything right.

Now I have the indicator plotted but everytime I change the width the indicator changes but the Buy and Sell signals don't refresh as the indicator does. Howcome?
Bruce_L
Posted : Wednesday, August 29, 2007 8:20:11 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Assuming you are using the thnkbigr25145 Workspace (I'm not sure from your post), there should be both a charted Study and a separate Study. Changing one will not automatically change the other because they are not linked together.

Left-click on the name of the Study on the Chart to use QuickEdit to adjust its settings.

Select Strategy | Conditions and left-click on the Buy and Sell Short Conditions to adjust their settings using QuickEdit.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Wednesday, August 29, 2007 12:01:20 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
I am looking at the thnkbigr25145 Workspace. I figured it out thanks.

I guess I am ready to do a back test on Blocks.

The Buy and Short Sell conditions are there o ready. Do I just use the same condition as Buy for Cover short and the Sell Short one for Sell the Long position or do I have to use the two original formulas you gave me that are stops?

Bruce_L
Posted : Wednesday, August 29, 2007 12:08:44 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You should be able to use the Conditions that are already there. When you Buy, it will automatically Exit a Short position and when you Sell Short, it will automatically Exit a Long position.

Once you have adjusted the Strategy to have the desired settings, you can test it on the Active Watchlist by selecting Test Strategy for Entire Watchlist (the green funnel between Strategy and Performance). The Performance Tab will then display the results of the Test.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Wednesday, August 29, 2007 12:32:02 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
So you mean I don't have to put anything in the Sell and Cover Short tabs?

Is there anyway we can give it range to find the best parameter that worked or I just have to play with it my self?

Is strategy equity line indicator the right one for me to use to see how well the indicator did graphically?

Bruce_L
Posted : Wednesday, August 29, 2007 12:40:02 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You could duplicate the Sell Short Condition as a Sell Condition and duplicate the Buy Condition as a Cover Short Condition, but this is unnecessary in the always either Long or Short type of Strategy you have described. You only need to have Sell and Cover Short Conditions when you have different Exit Conditions than Entry Conditions or if you are not testing both Long and Short Strategies simultaneously.

The Strategy will not automatically test different settings for each of your Conditions. You will need to adjust these manually.

The Strategy Equity Line is the best reflection of how the Strategy would work versus the entire Watchlist being tested. Realize that it is not a backtest in the sense that it does not have any sort of money management. You are either all in and equally invested in every symbol with a position or all out and receiving the Interest Rate when no trades are active. You will probably want to look at all of the settings in the Strategy | Settings Tab to see if they are what you want.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Wednesday, August 29, 2007 2:15:00 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
How doI change the scale on the equity line from LOG to ART and back?
Bruce_L
Posted : Wednesday, August 29, 2007 2:31:53 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Right-click on the Strategy Equity Line and select Scaling Method | (Desired Scaling Method).

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Wednesday, August 29, 2007 2:39:56 PM
Platinum Customer Platinum Customer

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

I have a vertical pointer how do I get a horizantal one and I also like to see the ending value of the equity line in the scale on the right.

For example on the top chart it shows that nasdaq closed at 2500.64 yesterday.
Bruce_L
Posted : Wednesday, August 29, 2007 3:38:03 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
The horizontal line is called a Value Pointer and is added by right-clicking on the Pane and selecting Add Chart Tool | Value Pointer.

The Block Diagram for the Value Pointer will allow you to display the most recent Value on the chart scale by running a Last Value in Series Block into the Pointer Value Block and using Equity Line as an Input.

The Block Diagram for the Value Pointer will also allow you to display the Value for the Date Pointer by using a Value For Date Block instead of a Last Value in Series Block.

I have uploaded a newer version of the Workspace in my Tuesday, August 28, 2007 6:00:08 PM ET post. It now has Equity Lines for both the Watchlist and Symbol with Value Pointers.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Wednesday, August 29, 2007 3:48:38 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
I opend your new one but all charts are blank
Bruce_L
Posted : Wednesday, August 29, 2007 4:00:43 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
I've restarted several times and it's still working on my system. Have you run the Strategy by selecting Test Strategy for Entire WatchList?

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Wednesday, August 29, 2007 4:22:39 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
it's all blank on my end even the price chart is blank.

I downloaded everything again and saved it underthnkbigr25147 and it still is all blank.
Bruce_L
Posted : Wednesday, August 29, 2007 4:58:21 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
What happens when you load Personal Chartist or any of your other Workspaces? Are they all displaying correctly?

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Wednesday, August 29, 2007 6:10:07 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
yea this is the only one the watch list is there it does the back test and shows performance results but none of the graphs work.

can anyone jump on my computer to see what's wrong
thnkbigr
Posted : Wednesday, August 29, 2007 6:39:41 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
Bruce forget it your original one works fine I just don't clearly understand what you mean by these two paragraphs you wrote I am very new to Blocks.

The Block Diagram for the Value Pointer will allow you to display the most recent Value on the chart scale by running a Last Value in Series Block into the Pointer Value Block and using Equity Line as an Input.

The Block Diagram for the Value Pointer will also allow you to display the Value for the Date Pointer by using a Value For Date Block instead of a Last Value in Series Block.
thnkbigr
Posted : Thursday, August 30, 2007 1:09:10 PM
Platinum Customer Platinum Customer

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

I like to make a addition to this indicator. As of now it uses just closing prices to trigger signals but sometimes the price falls or rises significantly the day of the cross and if it closes above or below the Volatility stop it triggers a trade at tom openning price.

I like to add that if the price intraday falls below or rises above the volatility stop bt let say .5% it would trigger a trade and if it closes above or below the stop peice but never reached that .5% mark then it trigger a trade at tom openning price.
Bruce_L
Posted : Thursday, August 30, 2007 5:38:41 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
QUOTE (thnkbigr)
I like to add that if the price intraday falls below or rises above the volatility stop bt let say .5% it would trigger a trade and if it closes above or below the stop peice but never reached that .5% mark then it trigger a trade at tom openning price.

I do not know of a way to do this without a Blocks Mega Minute DVD Pack subscription and I do not show this as active on your account.

Your trades can be set to happen on the Close, Open, High or Low of either the Trigger Bar or Next Bar. With Strategy Trader, this is going to be the a Daily Bar as the shortest Time Frame. You cannot currently switch the which Bar or which Component to use based on a Condition. All Trades happen on whatever you are using as your setting.

With intra-day data you could have the Data to Test set to an intra-day Time Frame and trigger the trade when the price crossed intra-day. While you would still trade on the Close, Open, High or Low of either the Trigger Bar or Next Bar, doing so intra-day would allow you to make the trade intra-day. You could trade on the Open of the intra-day bar when the price first fell above or below the volatility stop by at least .5% instead of waiting for the next days Open.

QUOTE (thnkbigr)
Bruce forget it your original one works fine I just don't clearly understand what you mean by these two paragraphs you wrote I am very new to Blocks.

The easiest way to explain it is probably to just have you take a look at the Block Diagrams for the Value Pointers in some Panes that have already been setup correctly. Please save the attached .pane files to:

My Documents\Blocks Files\Tool Parts\Chart

You can add them to any chart using the ADD STUDY button and then selecting Add Study | My Computer.

You can use QuickEdit to adjust the settings or view the Block Diagrams.

Attachments:
Strategy Equity Line.pane - 5 KB, downloaded 346 time(s).
Symbol Equity Line.pane - 5 KB, downloaded 415 time(s).



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Tuesday, September 4, 2007 3:35:55 PM
Platinum Customer Platinum Customer

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

In about 5 minutes I'll have Blocks Mega Minute as well so please let me how I can execute trades at .5% below the volatility stop rather than waiting for the close?

Thanks
thnkbigr
Posted : Monday, September 10, 2007 10:03:22 AM
Platinum Customer Platinum Customer

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

I don't know if you had a chance to look at this agian. I have the Mega minute now can you please show me what adjustments I need to make to your original formula to trade at a certain % or in this example .5% intraday above or below the Volatility stop rather the close?

thanks
Bruce_L
Posted : Wednesday, September 12, 2007 10:24:11 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
The following Strategy uses the Sync TimeFrames Block and currently requires the Blocks Pre-Release Version (please remember that this version of the software is in beta-testing).

If you have this version, you can download the attached .bscan file to:

\My Documents\Blocks Files\Tool Parts\Strategies

Once there, you can open the Strategy by clicking the Strategy tab, right clicking on Strategy and choosing Open Strategy then My Computer.

You can use QuickEdit to adjust the Strategy Conditions and view their Block Diagrams.

Attachments:
thnkbigr25145mm.bscan - 21 KB, downloaded 444 time(s).



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Wednesday, September 12, 2007 1:13:27 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
What's Blocks pre-release version?
Bruce_L
Posted : Wednesday, September 12, 2007 1:16:53 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
The first link in my Wednesday, September 12, 2007 10:24:11 AM ET response will bring you to the Blocks Pre-Release Version forum. The How to run the Pre-release version of Blocks topic in this forum explains the Pre-Release Version as well as how to install and run it.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Wednesday, September 12, 2007 3:32:54 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
when I run a test it comes with no signals and 0%. I am assuming something is not right?
Bruce_L
Posted : Wednesday, September 12, 2007 3:48:14 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Are you using the Pre-Release Version of Blocks? When I load the Strategy and run it on the Nasdaq 100 Component Stocks I get 476 trades using just 3 Months of data.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Tuesday, September 25, 2007 12:35:34 AM
Platinum Customer Platinum Customer

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

all trades are taking place at the open of the next bar. It doesn't matter which system I use. End of the day data or mega minute it's not doing the tardes intraday like it's suppose to if it breaks the volatility stop by .5%

Do I have to do anything under the settings tab to make it intraday?
Bruce_L
Posted : Tuesday, September 25, 2007 11:08:20 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
The Strategy does not appear to keep its Time Frame when added to an existing Workspace.

- The Strategy Time Frame should be 1 Minute.
- The Strategy Conditions with two Time Frames need the Volatility Time Frame set to 1 Day and the Trading Time Frame set to 1 Minute.
- The Strategy Conditions with one Time Frame need the Override Time Frame set to 1 Day.

I've attached a Workspace where all of this should be done for you. If you want to try it instead of making the changes manually, save the attached .bWorks file to the following folder:

\My Documents\Blocks Files\Workspaces

You can then open the Workspace via your FILE menu (Open Workspace then My Computer).

Attachments:
thnkbigr25145mm.bWorks - 85 KB, downloaded 312 time(s).



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Wednesday, January 9, 2008 4:58:19 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
Bruce the new version that I downloaded to use the indicator above is not valid any more is it?
Bruce_L
Posted : Thursday, January 10, 2008 10:27:00 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You are correct. The active Pre-Release of Blocks is Version 3 and is only available currently by attending a Training Class.

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