Hello Folks,
I'm new to eSignal having recently come over from TradeStation as eSignal is a superior product for pairs trading. I have a couple codes from TS that work VERY well. The first is a simple little code that I made for an Open Order Only strategy. It is very effective in giving you a bit of a lead when trying to fade the open gap. The second paints divergence on the chart using pivot points. The best thing about it is that unlike the other divergence alerts to include the ones I see in the eSignal file share that paint a few bars after the fact, this one paints dots when it begins to occur. Anyway, any help converting this code would be very much appreciated. I will post the results (sooner with help or much later without) in the file share as they are both are VERY good analysis techniques. THANK YOU IN ADVANCE FOR YOUR HELP
Open Order Only technique
____________________________________________
Tick ratio
inputs:
//Price ( upticks / downticks ),
VeryFastLength( 1 ),
Fastlength ( 4 ),
SlowLength( 10 ),
Displace( 0 ) ;
variables:
VeryFastAvg( 0 ),
Fastavg ( 0 ),
SlowAvg( 0 ) ,
TickRatio(0);
if DownTicks <> 0 then
TickRatio = UpTicks / DownTicks;
VeryFastAvg = AverageFC( TickRatio, VeryFastLength ) ;
FastAvg = AverageFC( TickRatio, FastLength ) ;
SlowAvg = AverageFC( TickRatio, SlowLength ) ;
if Displace >= 0 or CurrentBar > AbsValue( Displace ) then
begin
Plot1[Displace]( VeryFastAvg, "VeryFastAvg" ) ;
Plot2[Displace]( FastAvg, "FastAvg" ) ;
Plot3[Displace]( SlowAvg, "SlowAvg" ) ;
Plot4( .5, "zeroline" ) ;
end ;
________________________________________________
Divergence Code
inputs:
CCILength( 14 ) ,
Strength( 5 ),
Length( 90 ) ,
PlotSeries( 1 ) ; // 1 for Plot Series Stream 1, 2 for Plot Series Stream 2
variables:
CCIVal( 0 ) ,
BullDivergence( False ),
BearDivergence( False ),
oSw1Series1( 0 ),
oSw1Series2( 0 ),
oSw2Series1( 0 ),
oSw2Series2( 0 ),
oSw1Series3( 0 ),
oSw1Series4( 0 ),
oSw2Series3( 0 ),
oSw2Series4( 0 ),
oSw1BarSeries1( 0 ) ,
oSw1BarSeries2( 0 ) ,
oSw2BarSeries1( 0 ) ,
oSw2BarSeries2( 0 ) ,
oSw1BarSeries3( 0 ) ,
oSw1BarSeries4( 0 ) ,
oSw2BarSeries3( 0 ) ,
oSw2BarSeries4( 0 ) ,
HiLo( 0 ) , { pass in 1 for BearishDiv (based on SwingHighs), -1 for
BullishDiv (based on SwingLows) }
TL_IDBull( 0 ) ,
TL_IDBear( 0 ) ;
CCIVal = CCI( CCILength ) ;
HiLo = 1 ;
//Most recent Price Pivot High
Value1 = Pivot( High, Length, Strength, Strength, 1, HiLo, oSw1Series1, oSw1BarSeries1 ) ;
//Most recent CCI Pivot High
Value2 = Pivot( CCIVal, Length, Strength, Strength, 1, HiLo, oSw1Series2, oSw1BarSeries2 ) ;
//Second most recent Price Pivot High
Value3 = Pivot( High, Length, Strength, Strength, 2, HiLo, oSw2Series1, oSw2BarSeries1 ) ;
//Second most recent CCI Pivot High
Value4 = Pivot( CCIVal, Length, Strength, Strength, 2, HiLo, oSw2Series2, oSw2BarSeries2 ) ;
HiLo = - 1 ;
//Most recent Price Pivot Low
Value5 = Pivot( Low, Length, Strength, Strength, 1, HiLo, oSw1Series3, oSw1BarSeries3 ) ;
//Most recent CCI Pivot Low
Value6 = Pivot( CCIVal, Length, Strength, Strength, 1, HiLo, oSw1Series4, oSw1BarSeries4 ) ;
//Second most recent Price Pivot Low
Value7 = Pivot( Low, Length, Strength, Strength, 2, HiLo, oSw2Series3, oSw2BarSeries3 ) ;
//Second most recent CCI Pivot Low
Value8 = Pivot( CCIVal, Length, Strength, Strength, 2, HiLo, oSw2Series4, oSw2BarSeries4 ) ;
//Plot divergence zones
if Value1 = 1 { most recent price pivot high found }
and Value2 = 1 { most recent CCI pivot high found } and
( High > oSw1Series1 and CCIVal < oSw1Series2 ) and
AbsValue( oSw1BarSeries1 - oSw1BarSeries2) <= 5 then
if PlotSeries = 1 then
plot1( High )
else
plot1( CCIVal ) ;
if Value5 = 1 { most recent price pivot low found }
and Value6 = 1 { most recent CCI pivot low found } and
( Low < oSw1Series3 and CCIVal > oSw1Series4 ) and
AbsValue( oSw1BarSeries3 - oSw1BarSeries4) <= 5 then
if PlotSeries = 1 then
plot2( Low )
else
plot2( CCIVal ) ;
if Value3 = 1 { pivot found; this automatically implies that Value1 also 1 }
and Value4 = 1 { pivot found; this automatically implies that Value2 also 1 } and
( oSw1Series1 > oSw2Series1 and oSw1Series2 < oSw2Series2 ) and
AbsValue( oSw2BarSeries1 - oSw2BarSeries2) <= 5 then
BearDivergence = True
else
BearDivergence = False ;
if Value7 = 1 { pivot found; this automatically implies that Value5 also 1 }
and Value8 = 1 { pivot found; this automatically implies that Value6 also 1 } and
( oSw1Series3 < oSw2Series3 and oSw1Series4 > oSw2Series4 ) and
AbsValue( oSw2BarSeries3 - oSw2BarSeries4) <= 5 then
BullDivergence = True
else
BullDivergence = False ;
if BearDivergence and BearDivergence[1] = False then
if PlotSeries = 1 then
begin
TL_IDBear = TL_New( Date[oSw2BarSeries1], Time[oSw2BarSeries1], oSw2Series1, Date[oSw1BarSeries1], Time[oSw1BarSeries1], oSw1Series1 ) ;
TL_SetColor(TL_IDBear, Red ) ;
TL_SetSize(TL_IDBear, 2 ) ;
end
else
begin
TL_IDBear = TL_New( Date[oSw2BarSeries2], Time[oSw2BarSeries2], oSw2Series2, Date[oSw1BarSeries2], Time[oSw1BarSeries2], oSw1Series2 ) ;
TL_SetColor(TL_IDBear, Red ) ;
TL_SetSize(TL_IDBear, 2 ) ;
end ;
if BullDivergence and BullDivergence[1] = False then
if PlotSeries = 1 then
begin
TL_IDBull = TL_New( Date[oSw2BarSeries3], Time[oSw2BarSeries3], oSw2Series3, Date[oSw1BarSeries3], Time[oSw1BarSeries3], oSw1Series3 ) ;
TL_SetColor(TL_IDBull, Cyan ) ;
TL_SetSize(TL_IDBull, 2 ) ;
end
else
begin
TL_IDBull = TL_New( Date[oSw2BarSeries4], Time[oSw2BarSeries4], oSw2Series4, Date[oSw1BarSeries4], Time[oSw1BarSeries4], oSw1Series4 ) ;
TL_SetColor(TL_IDBull, Cyan ) ;
TL_SetSize(TL_IDBull, 2 ) ;
end ;
if PlotSeries = 2 then
Plot3( CCIVal, "CCIVal" ) ;
I'm new to eSignal having recently come over from TradeStation as eSignal is a superior product for pairs trading. I have a couple codes from TS that work VERY well. The first is a simple little code that I made for an Open Order Only strategy. It is very effective in giving you a bit of a lead when trying to fade the open gap. The second paints divergence on the chart using pivot points. The best thing about it is that unlike the other divergence alerts to include the ones I see in the eSignal file share that paint a few bars after the fact, this one paints dots when it begins to occur. Anyway, any help converting this code would be very much appreciated. I will post the results (sooner with help or much later without) in the file share as they are both are VERY good analysis techniques. THANK YOU IN ADVANCE FOR YOUR HELP
Open Order Only technique
____________________________________________
Tick ratio
inputs:
//Price ( upticks / downticks ),
VeryFastLength( 1 ),
Fastlength ( 4 ),
SlowLength( 10 ),
Displace( 0 ) ;
variables:
VeryFastAvg( 0 ),
Fastavg ( 0 ),
SlowAvg( 0 ) ,
TickRatio(0);
if DownTicks <> 0 then
TickRatio = UpTicks / DownTicks;
VeryFastAvg = AverageFC( TickRatio, VeryFastLength ) ;
FastAvg = AverageFC( TickRatio, FastLength ) ;
SlowAvg = AverageFC( TickRatio, SlowLength ) ;
if Displace >= 0 or CurrentBar > AbsValue( Displace ) then
begin
Plot1[Displace]( VeryFastAvg, "VeryFastAvg" ) ;
Plot2[Displace]( FastAvg, "FastAvg" ) ;
Plot3[Displace]( SlowAvg, "SlowAvg" ) ;
Plot4( .5, "zeroline" ) ;
end ;
________________________________________________
Divergence Code
inputs:
CCILength( 14 ) ,
Strength( 5 ),
Length( 90 ) ,
PlotSeries( 1 ) ; // 1 for Plot Series Stream 1, 2 for Plot Series Stream 2
variables:
CCIVal( 0 ) ,
BullDivergence( False ),
BearDivergence( False ),
oSw1Series1( 0 ),
oSw1Series2( 0 ),
oSw2Series1( 0 ),
oSw2Series2( 0 ),
oSw1Series3( 0 ),
oSw1Series4( 0 ),
oSw2Series3( 0 ),
oSw2Series4( 0 ),
oSw1BarSeries1( 0 ) ,
oSw1BarSeries2( 0 ) ,
oSw2BarSeries1( 0 ) ,
oSw2BarSeries2( 0 ) ,
oSw1BarSeries3( 0 ) ,
oSw1BarSeries4( 0 ) ,
oSw2BarSeries3( 0 ) ,
oSw2BarSeries4( 0 ) ,
HiLo( 0 ) , { pass in 1 for BearishDiv (based on SwingHighs), -1 for
BullishDiv (based on SwingLows) }
TL_IDBull( 0 ) ,
TL_IDBear( 0 ) ;
CCIVal = CCI( CCILength ) ;
HiLo = 1 ;
//Most recent Price Pivot High
Value1 = Pivot( High, Length, Strength, Strength, 1, HiLo, oSw1Series1, oSw1BarSeries1 ) ;
//Most recent CCI Pivot High
Value2 = Pivot( CCIVal, Length, Strength, Strength, 1, HiLo, oSw1Series2, oSw1BarSeries2 ) ;
//Second most recent Price Pivot High
Value3 = Pivot( High, Length, Strength, Strength, 2, HiLo, oSw2Series1, oSw2BarSeries1 ) ;
//Second most recent CCI Pivot High
Value4 = Pivot( CCIVal, Length, Strength, Strength, 2, HiLo, oSw2Series2, oSw2BarSeries2 ) ;
HiLo = - 1 ;
//Most recent Price Pivot Low
Value5 = Pivot( Low, Length, Strength, Strength, 1, HiLo, oSw1Series3, oSw1BarSeries3 ) ;
//Most recent CCI Pivot Low
Value6 = Pivot( CCIVal, Length, Strength, Strength, 1, HiLo, oSw1Series4, oSw1BarSeries4 ) ;
//Second most recent Price Pivot Low
Value7 = Pivot( Low, Length, Strength, Strength, 2, HiLo, oSw2Series3, oSw2BarSeries3 ) ;
//Second most recent CCI Pivot Low
Value8 = Pivot( CCIVal, Length, Strength, Strength, 2, HiLo, oSw2Series4, oSw2BarSeries4 ) ;
//Plot divergence zones
if Value1 = 1 { most recent price pivot high found }
and Value2 = 1 { most recent CCI pivot high found } and
( High > oSw1Series1 and CCIVal < oSw1Series2 ) and
AbsValue( oSw1BarSeries1 - oSw1BarSeries2) <= 5 then
if PlotSeries = 1 then
plot1( High )
else
plot1( CCIVal ) ;
if Value5 = 1 { most recent price pivot low found }
and Value6 = 1 { most recent CCI pivot low found } and
( Low < oSw1Series3 and CCIVal > oSw1Series4 ) and
AbsValue( oSw1BarSeries3 - oSw1BarSeries4) <= 5 then
if PlotSeries = 1 then
plot2( Low )
else
plot2( CCIVal ) ;
if Value3 = 1 { pivot found; this automatically implies that Value1 also 1 }
and Value4 = 1 { pivot found; this automatically implies that Value2 also 1 } and
( oSw1Series1 > oSw2Series1 and oSw1Series2 < oSw2Series2 ) and
AbsValue( oSw2BarSeries1 - oSw2BarSeries2) <= 5 then
BearDivergence = True
else
BearDivergence = False ;
if Value7 = 1 { pivot found; this automatically implies that Value5 also 1 }
and Value8 = 1 { pivot found; this automatically implies that Value6 also 1 } and
( oSw1Series3 < oSw2Series3 and oSw1Series4 > oSw2Series4 ) and
AbsValue( oSw2BarSeries3 - oSw2BarSeries4) <= 5 then
BullDivergence = True
else
BullDivergence = False ;
if BearDivergence and BearDivergence[1] = False then
if PlotSeries = 1 then
begin
TL_IDBear = TL_New( Date[oSw2BarSeries1], Time[oSw2BarSeries1], oSw2Series1, Date[oSw1BarSeries1], Time[oSw1BarSeries1], oSw1Series1 ) ;
TL_SetColor(TL_IDBear, Red ) ;
TL_SetSize(TL_IDBear, 2 ) ;
end
else
begin
TL_IDBear = TL_New( Date[oSw2BarSeries2], Time[oSw2BarSeries2], oSw2Series2, Date[oSw1BarSeries2], Time[oSw1BarSeries2], oSw1Series2 ) ;
TL_SetColor(TL_IDBear, Red ) ;
TL_SetSize(TL_IDBear, 2 ) ;
end ;
if BullDivergence and BullDivergence[1] = False then
if PlotSeries = 1 then
begin
TL_IDBull = TL_New( Date[oSw2BarSeries3], Time[oSw2BarSeries3], oSw2Series3, Date[oSw1BarSeries3], Time[oSw1BarSeries3], oSw1Series3 ) ;
TL_SetColor(TL_IDBull, Cyan ) ;
TL_SetSize(TL_IDBull, 2 ) ;
end
else
begin
TL_IDBull = TL_New( Date[oSw2BarSeries4], Time[oSw2BarSeries4], oSw2Series4, Date[oSw1BarSeries4], Time[oSw1BarSeries4], oSw1Series4 ) ;
TL_SetColor(TL_IDBull, Cyan ) ;
TL_SetSize(TL_IDBull, 2 ) ;
end ;
if PlotSeries = 2 then
Plot3( CCIVal, "CCIVal" ) ;