| |
 |
Key Reversal Pattern
|
 |
|
|
|
Views:
2440 |
| Added: May 30, 2007 |
| |
|
|
|
| This formula has not been rated yet |
| |
| |
email this link
|
| |
| |
| Tags:
TradeStation, system
|
| |
 |
Massimiliano Scorpio's article "Finding Key Reversals" in this issue
includes the EasyLanguage code for a key reversal-based strategy (a trading system)
that also performs some basic statistical analysis to determine how often such
price patterns occur and how often they lead to profitable moves. The strategy
calls a custom function for identifying key reversals, and the EasyLanguage code
for that is also included in the article.
While the ideas presented are sound, there are some issues with the code that
may make it difficult to use as-is, so we are presenting an alternative version
here. The key issues are:
The code will not run on the currently shipping TradeStation 6 platform because
buy and sell statements are now written differently and stops are implemented
internally in the EasyLanguage code instead of via external settings. (Some
of the required changes are made automatically if you import the code from an
ELS file, but if you are typing the code in, you need to make the changes yourself.)
The strategy has a drawback. The count of the number of times the KR is followed
by an upmove is not valid. The way it is written, the count will actually reflect
the number of times the high of the second bar of the two-bar KR was higher
than the high of the first bar of the KR. Instead, it needs to pick up the number
of times the high of the bar after the KR was higher than the high of the second
bar of the KR.
The strategy uses "if LastCalcDate = Date" to determine if it is on
the last bar of the chart. This will not work with intraday charts. It is preferable
to use LastBarOnChart instead.
The exit statement should apply only to the bar after entry. The way it is written,
it will apply to every bar.
If a profitable exit is not made on the bar after entry, there is no reason
to stay in the trade until you are stopped out at a loss. Code has been added
to exit the bar after entry on the close, if you have not already exited at
a profit, and have not been stopped out.
For this application, the code for the KR function can be simplified considerably.
This has been done, and the code (one statement) has been rolled in with the
strategy code.
Several other minor simplifications and improvements were made.
Code:
Type : Strategy, Name : Key Reversal Pattern
Input: StopLossAmount( 250 ) ;
variable: KRPattern( false ) ;
KRPattern = Low < Low[1]
and Close > Close[1]
and Close < High ;
{ You are counting how many times the pattern recurs.
INCREMENT THE COUNT ONE BAR AFTER THE KR IS CONFIRMED. }
if KRPattern[1] then
begin
Value1 = Value1 + 1 ;
{ If there is a key reversal up pattern,
how many times is the following high greater or equal to the last high? }
if High >= High[1] then
Value2 = Value2 + 1 ;
end ;
{ Now send the results to a text file }
if LastBarOnChart then
begin
Print( File( "C:Patt.txt" ), GetSymbolName,
" ", ELDateToString( CurrentDate), " Time: ",
CurrentTime:4:0 ) ;
Print( File( "C:Patt.txt" ),
"Key Reversal Up Pattern" ) ;
if Value1 <> 0 then
begin
Print( File( "C:Patt.txt" ),
"Pattern ", Value1:4:0 ) ;
Print( File( "C:Patt.txt" ), "Total bars ",
BarNumber:4:0, " Observation on total bars ",
Value1 / BarNumber * 100, "%" ) ;
Print( File( "C:Patt.txt" ),
"Next high is greater or equal to prev high ",
Value2:4:0, Value2 / Value1 * 100, "%" ) ;
end ;
end ;
{ If you want to see trading signals include the code below }
if KRPattern then
begin
Buy this bar on Close ;
Sell ( "Target" ) next bar at High limit ;
end ;
SetStopPosition ;
SetStopLoss( StopLossAmount ) ;
if BarsSinceEntry = 1 then
Sell ( "EOD" ) this bar on Close ;
Author: Massimiliano Scorpio
Source: http://www.traders.com
all systems for TradeStation
all systems
|