Sendit
Sendit
osCount = 0; end;
if(obCount = 2) then sell short tomorrow at open; if(marketPosition = –1) then begin
end; if(myRsiVal < overSold and myRsiVal[1] > overSold) then begin
osCount = osCount + 1;
obCount = 0; end;
Version 1.00 initial testing of my idea
Version 1.01 added RSI retracement component Version 1.02 added
profit objective mechanism Version 1.03 changed the over bought/sold parameter
This trading signal is designed to buy when the RSI has double dipped into the oversold territory and sells
when the RSI has doubly risen into overbought territory. Once a position is initiated an initial money
myRsiVal = RSI(close,rsiLength); if(myRsiVal > overBought and myRsiVal[1] < overBought) then begin
obCount = obCount + 1; osCount = 0; {Reset the OS counter since we are OB}
end; if(myRsiVal < overSold and myRsiVal[1] > overSold) then begin
osCount = osCount + 1;
if(obCount = 2) then Sell Short tomorrow at open; {We have entered OB twice} if(osCount = 2) then Buy
tomorrow at open; {We have entered OS twice}
Daryl Guppy's two articles, "Something Darvas, Something New" in this issue and "Darvas-Style Trading" in the May 2005
S&C, describe how Darvas boxes are drawn and also describes three methods for using the boxes: the classic, modern, and
breakout methods.
http://traders.com/documentation/feedbk_docs/2005/06/traderstips/traderstips.html#wealth
FIGURE 1: TRADESTATION, DARVAS TECHNIQUE. Here is an example of drawing Darvas boxes in TradeStation.
To demonstrate how these methods might be implemented in an EasyLanguage strategy, we have written a strategy called
"Darvas by Guppy." To begin, create a daily chart of the symbol of your choice. Then insert the "Darvas by Guppy" strategy into
the chart.
To apply the classic style, set the periods input to 200. Ensure that the inputs ExitNextDay, GhostBoxExit, and BreakOutEntry
are set to false for this style. The input VolumeEntry should be set to true.
To apply the modern Darvas style, a period length of either 100 or 200 may be used. ExitNextDay and GhostBoxExit should both
be set to true for this style. VolumeEntry should be false.
Finally, to apply the breakout Darvas style, set BreakoutEntry, ExitNextDay, and GhostBoxExit to true. VolumeEntry should be
set to false.
This code may be downloaded from the TradeStation Support Center, which is accessible from TradeStation.com.
inputs:
Periods( 100 ),
ExitNextDay( false ),
GhostBoxExit( false ),
BreakoutEntry (false ),
VolumeEntry( false ),
VolumeAvgLen( 10 ),
VolumeFactor( 1.5 ) ;
variables:
BarsSinceDH( 0 ),
BarsSinceDL( 0 ),
CriticalLow( 0 ),
TempD_Low( 0 ),
SearchForLow ( false ),
D_Low( 0 ),
D_High( 0 ),
BottomLineNum( 0 ),
TopLineNum( 0 ),
LeftSideNum( 0 ),
RightSideNum( 0 ),
CriticalHigh( 0 ),
TempD_High( 0 ),
DHighLowDiff( 0 ),
MyStop( 0 ),
MyTrigger( 0 ),
DownTrend( 0 ) ;
if CurrentBar > Periods then
begin
BarsSinceDH = BarsSinceDH + 1 ;
BarsSinceDL = BarsSinceDL + 1 ;
if Low[3] <= CriticalLow[4] and
Low[3] <= Low[2] and
Low[3] <= Low[1] and
Low[3] < Low
then
begin
TempD_Low = Low[3] ;
BarsSinceDL = 3 ;
end ;
if SearchForLow and BarsSinceDL < 6 and
BarsSinceDL <= BarsSinceDH then
begin
D_Low = Low[BarsSinceDL] ;
D_High = TempD_High ;
SearchForLow = false ;
BottomLineNum = TL_New( Date[BarsSinceDH],
Time[BarsSinceDH], D_Low, Date[3], Time[3],
D_Low ) ;
TopLineNum = TL_New( Date[BarsSinceDH],
Time[BarsSinceDH], D_High, Date[3], Time[3],
D_High ) ;
LeftSideNum = TL_New( Date[BarsSinceDH],
Time[BarsSinceDH], D_High, Date[BarsSinceDH],
Time[BarsSinceDH], D_Low ) ;
RightSideNum = TL_New( Date[3], Time[3], D_High,
Date[3], Time[3], D_Low ) ;
end ;
if High[3] >= CriticalHigh[4]
and High[3] >= High[2]
and High[3] >= High[1]
and High[3] > High
then
begin
BarsSinceDH = 3 ;
TempD_High = High[3] ;
SearchForLow = true ;
end ;
CriticalHigh = Highest( High, Periods ) ;
CriticalLow = Lowest( Low, BarsSinceDH ) ;
end ;
DHighLowDiff = D_High - D_Low ;
if GhostBoxExit and DHighLowDiff > 0 and Close >
D_High + DHighLowDiff then
begin
MyStop = ( IntPortion( ( Close - D_Low ) /
DHighLowdiff ) - 1 ) * DHighLowDiff + D_Low ;
MyTrigger = MyStop + DHighLowDiff ;
end
else
begin
MyStop = D_Low ;
MyTrigger = D_High ;
end ;
if Close crosses under D_Low then
DownTrend = 0
else if BreakoutEntry and Close crosses over D_High then
DownTrend = 1
else if BreakoutEntry and DownTrend = 1 and
BarsSinceDL = 3 then
DownTrend = 2 ;
if ( BreakoutEntry and DownTrend = 2 ) or
BreakoutEntry = false then
begin
if VolumeEntry then
begin
if Close crosses over MyTrigger and Volume >
Average( Volume, VolumeAvgLen ) * VolumeFactor
then
Buy next bar market ;
end
else if Close < MyTrigger then
Buy next bar MyTrigger stop ;
if ExitNextDay then
begin
if Low[1] >= MyStop and Low < MyStop then
Sell next bar at market ;
end
else
Sell next bar at MyStop stop ;
end ;
--Mark Mills
TradeStation Securities, Inc.
A subsidiary of TradeStation Group, Inc.
www.TradeStationWorld.com