Hi everyone,
I tried to use technical indicators on spread products but ran into some issues.
For example stochastic:
Inputs:
DataSeries1_H( High of data1 ), DataSeries2_H( High of data2 ),
DataSeries1_L( Low of data1 ), DataSeries2_L( Low of data2 ),
DataSeries1_C( Close of data1 ), DataSeries2_C( Close of data2 ),
PriceH = DataSeries1_H - DataSeries2_L ;
PriceL = DataSeries1_L - DataSeries2_H;
PriceC = DataSeries1_C - DataSeries2_C ;
Value1 = Stochastic( PriceH, PriceL, PriceC, StochLength, SmoothingLength1,
SmoothingLength2, SmoothingType, var0, var1, var2, var3 ) ;
---------------------------------------------------
The above code is wrong because it's not the real high/low of a spread product.
The only way I think reasonable is to use tick level data. I am wondering if there is better solution to this. Thank you for your help!
Use Technical Indicators on Spread Products
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Use Technical Indicators on Spread Products
I'm not sure what you mean here: how is the code wrong because it's not the real high/low of your instrument? The code simply calculates on the data put into it (see the inputs listed in your post). So if the code returns not the real high/low, then you'll need to check your data series and data feed against the 'real' values.The above code is wrong because it's not the real high/low of a spread product.
The only way I think reasonable is to use tick level data. I am wondering if there is better solution to this.
Re: Use Technical Indicators on Spread Products
The following is the code. If you are familiar with spread products, you will realize that the calculation of stochastic doesn't make any sense at all. The only way is to use tick level to get the real high low of a spread, but that might create another question: how to use the value to different time frame (1 min, 5 min, etc).
Thanks for your help.
---------------------------------
inputs:
DataSeries1_H( High of data1 ), DataSeries2_H( High of data2 ),
DataSeries1_L( Low of data1 ), DataSeries2_L( Low of data2 ),
DataSeries1_C( Close of data1 ), DataSeries2_C( Close of data2 ),
StochLength( 14 ),
SmoothingLength1( 3 ),
SmoothingLength2( 3 ),
SmoothingType( 1 ),
OverSold( 20 ),
OverBought( 80 ) ;
variables:
PriceH( 0 ),
PriceL( 0),
PriceC( 0 ),
var0( 0 ),
var1( 0 ),
var2( 0 ),
var3( 0 ) ;
PriceH = DataSeries1_H - DataSeries2_L ;
PriceL = DataSeries1_L - DataSeries2_H;
PriceC = DataSeries1_C - DataSeries2_C ;
Value1 = Stochastic( PriceH, PriceL, PriceC, StochLength, SmoothingLength1,
SmoothingLength2, SmoothingType, var0, var1, var2, var3 ) ;
Plot1( var0, "FastK" ) ;
Plot2( var1, "FastD") ;
Plot3( OverBought, "OverBot" ) ;
Plot4( OverSold, "OverSld" ) ;
condition1 = var1 crosses over OverSold ;
if condition1 then
Alert( "FastD exiting oversold zone" )
else
begin
condition1 = var1 crosses under OverBought ;
if condition1 then
Alert( "FastD exiting overbought zone" ) ;
end;
Thanks for your help.
---------------------------------
inputs:
DataSeries1_H( High of data1 ), DataSeries2_H( High of data2 ),
DataSeries1_L( Low of data1 ), DataSeries2_L( Low of data2 ),
DataSeries1_C( Close of data1 ), DataSeries2_C( Close of data2 ),
StochLength( 14 ),
SmoothingLength1( 3 ),
SmoothingLength2( 3 ),
SmoothingType( 1 ),
OverSold( 20 ),
OverBought( 80 ) ;
variables:
PriceH( 0 ),
PriceL( 0),
PriceC( 0 ),
var0( 0 ),
var1( 0 ),
var2( 0 ),
var3( 0 ) ;
PriceH = DataSeries1_H - DataSeries2_L ;
PriceL = DataSeries1_L - DataSeries2_H;
PriceC = DataSeries1_C - DataSeries2_C ;
Value1 = Stochastic( PriceH, PriceL, PriceC, StochLength, SmoothingLength1,
SmoothingLength2, SmoothingType, var0, var1, var2, var3 ) ;
Plot1( var0, "FastK" ) ;
Plot2( var1, "FastD") ;
Plot3( OverBought, "OverBot" ) ;
Plot4( OverSold, "OverSld" ) ;
condition1 = var1 crosses over OverSold ;
if condition1 then
Alert( "FastD exiting oversold zone" )
else
begin
condition1 = var1 crosses under OverBought ;
if condition1 then
Alert( "FastD exiting overbought zone" ) ;
end;