Dark Theme
Light Theme
Trading Articles
Article Categories
Article Tools
Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to
register in order to view the content of the threads and start contributing to our community.
It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Help w/ Keltner from TradeStation to NT7
Updated November 8, 2010
Help w/ Keltner from TradeStation to NT7
November 6th, 2010, 12:48 AM
Honolulu, Hawaii
Experience: Intermediate
Platform: NinjaTrader
Broker: ATC/TT, AMP/Zen-Fire, AMP/CQG
Trading: TF
Posts: 2,543 since Jun 2010
Thanks Given: 3,803
Thanks Received: 2,842
Hi all,
Can someone help me put this into NT7? I have used this Keltner for over 1 year and it is VERY useful to my technique. It would take me weeks if not over a month to do this myself. It is pretty useful and we could share it with the community.
One thing though is that I don't use the MA's (except the keltner settings).
Code
inputs:
Mid_Channel_PriceType ( 1) ,
Mid_Channel_SimpleOrExpAvg ( 2) ,
Mid_Channel_Length_Day ( 52) ,
Mid_Channel_Length_ID ( 52) ,
True_or_Price_Range ( 1) ,
ATR_APR_SimpleOrExpRange ( 2) ,
TR_or_PR_Length_Day ( 52) ,
TR_or_PR_Length_ID ( 52) ,
Upper_Factor ( 3.5) ,
Lower_Factor ( 3.5) ,
PiercePercent ( .33) ,
MA_Fast_Type ( 2 ) ,
MA_Fast_Length_Day ( 13 ) ,
MA_Fast_Length_ID ( 13 ) ,
MA_Slow_Type ( 2 ) ,
MA_Slow_Length_Day ( 34) ,
MA_Slow_Length_ID ( 34) ,
Chart_Color_MA_Fast ( rgb (130,130,130)) ,
Chart_Color_MA_Slow ( rgb (130,130,130)) ,
Chart_Color_LKC ( rgb (0,255,0)) ,
Chart_Color_MKC ( rgb(255,0,255)) ,
Chart_Color_UKC ( rgb (0,255,0)) ,
BearishColor ( rgb (130,130,130)) ,
BullishColor ( rgb (130,130,130)) ,
CautionColor ( rgb (130,130,130)) ,
Round_Control ( 2) ,
AlertsOn ( false ) ,
Display_KeltnerChannels ( true ) ,
Display_MA_Fast ( false) ,
Display_MA_Slow ( false) ,
Display_Signals ( false) ,
InputEdits ( false) ,
Graph_Delay ( 0 ) ,
Displace_MAF ( 0 ) ,
Displace_MAS ( 0 ) ,
Displace_LKC ( 0 ) ,
Displace_MKC ( 0) ,
Displace_UKC ( 0 ) ,
DisplayAdjustment ( 1) ,
CommentaryTable ( false) ,
dFormat ( "YYYYMMDD") ,
SepChar ( "/" ) ;
variables :
RadarScreen ( false ) ,
Chart ( false ) ,
ChartorRadarScreen ( 0 ) ,
LBOC ( false ) ,
double Average_Price_Range ( 0.00 ) ,
double Price ( 0.00 ) ,
double Price_Range ( 0.00 ) ,
Price_Range_Smooth ( 0.00 ) ,
double Average_True_Range ( 0.00 ) ,
TR_or_PR_Length ( 21 ) ,
double True_High ( 0.00 ) ,
double True_Low ( 0.00 ) ,
double True_Range ( 0.00 ) ,
True_Range_Smooth ( 0.00 ) ,
double Upper_Channel ( 1.00 ) ,
double Mid_Channel ( 0.50 ) ,
double Lower_Channel ( 1.00 ) ,
Mid_Channel_Length ( 21 ) ,
Mid_Channel_Smooth ( 0.00 ) ,
double Upper_Width ( 1.00 ) ,
double Lower_Width ( 1.00 ) ,
Lower_Lower ( 0 ) ,
Upper_Upper ( 0 ) ,
double MA_Fast ( 0.00 ) ,
MA_Fast_Length ( 13 ) ,
MA_Fast_Smooth ( 0.00 ) ,
double MA_Slow ( 0.00 ) ,
MA_Slow_Length ( 34 ) ,
MA_Slow_Smooth ( 0.00 ) ,
DirectionPredict ( "Neutral" ) ,
KCA_Day ( "" ) ,
KCA_Date ( "" ) ,
KCA_Time ( "" ) ,
tYear ( "" ) ,
tMonth ( "" ) ,
tDay ( "" ) ,
Symbol_Name ( "" ) ,
s ( "" ) ,
Plot_Close_OverUKC ( 0.00 ) ,
Plot_Close_OverLKC ( 0.00 ) ,
Plot_Close_UnderUKC ( 0.00 ) ,
Plot_Close_UnderLKC ( 0.00 ) ,
Plot_$Predict ( "" ) ,
Color_Close_OverUKC ( rgb ( 0 , 0 , 0 ) ) ,
Color_Close_OverLKC ( rgb ( 0 , 0 , 0 ) ) ,
Color_Close_UnderUKC ( rgb ( 0 , 0 , 0 ) ) ,
Color_Close_UnderLKC ( rgb ( 0 , 0 , 0 ) ) ,
Color_LowerChannel ( rgb ( 0 , 0 , 0 ) ) ,
Color_MiddleChannel ( rgb ( 0 , 0 , 0 ) ) ,
Color_UpperChannel ( rgb ( 0 , 0 , 0 ) ) ,
Color_$Predict ( rgb ( 0 , 0 , 0 ) ) ,
BuildKCAll ( "tachyonv Keltner Channels All " +
"Ver. 4.3 Build 23 February 5, 2006" ) ;
#BeginCmtry ;
Array :
string HTML_str [] ( "" ) ;
#End ;
{
******************************************************************
* H 0. Start up "housekeeping" routines
******************************************************************
}
{ ______________________________________________________________
| H 1. Input edits
|_____________________________________________________________
}
if currentbar = 1 and InputEdits then
begin
if Mid_Channel_PriceType <> 1 and
Mid_Channel_PriceType <> 2 and
Mid_Channel_PriceType <> 3 and
Mid_Channel_PriceType <> 4 and
Mid_Channel_PriceType <> 5 then
raiseruntimeerror
( "Mid_Channel_PriceType input value wrong" ) ;
if Mid_Channel_SimpleOrExpAvg <> 1 and
Mid_Channel_SimpleOrExpAvg <> 2 then
raiseruntimeerror
( "Mid_Channel_SimpleOrExpAvg input value wrong" ) ;
if Mid_Channel_Length_Day < 2 or
Mid_Channel_Length_Day > 200 then
raiseruntimeerror
( "Mid_Channel_Length_Day input value wrong" ) ;
if Mid_Channel_Length_ID < 2 or
Mid_Channel_Length_ID > 200 then
raiseruntimeerror
( "Mid_Channel_Length_ID input value wrong" ) ;
if True_or_Price_Range <> 1 and
True_or_Price_Range <> 2 then
raiseruntimeerror
( "True_or_Price_Range input value wrong" ) ;
if ATR_APR_SimpleOrExpRange <> 1 and
ATR_APR_SimpleOrExpRange <> 2 then
raiseruntimeerror
( "ATR_APR_SimpleOrExpRange input value wrong" ) ;
if TR_or_PR_Length_Day < 2 or
TR_or_PR_Length_Day > 200 then
raiseruntimeerror
( "TR_or_PR_Length_Day input value wrong" ) ;
if TR_or_PR_Length_Day < 2 or
TR_or_PR_Length_Day > 200 then
raiseruntimeerror
( "TR_or_PR_Length_Day input value wrong" ) ;
if Upper_Factor <= 0 or
Upper_Factor >= 10.0 then
raiseruntimeerror
( "Upper_Factor input value wrong" ) ;
if Lower_Factor <= 0 or
Lower_Factor >= 10.0 then
raiseruntimeerror
( "Lower_Factor input value wrong" ) ;
if MA_Fast_Type <> 1 and MA_Fast_Type <> 2 then
raiseruntimeerror
( "MA_Fast_Type input value wrong" ) ;
if MA_Fast_Length_Day <= 0 or
MA_Fast_Length_Day > 200 or
MA_Fast_Length_Day >= MA_Slow_Length_Day then
raiseruntimeerror
( "MA_Fast_Length_Day input value wrong" ) ;
if MA_Fast_Length_ID <= 0 or
MA_Fast_Length_ID > 200 or
MA_Fast_Length_ID >= MA_Slow_Length_Day then
raiseruntimeerror
( "MA_Fast_Length_ID input value wrong" ) ;
if MA_Slow_Type <> 1 and MA_Slow_Type <> 2 then
raiseruntimeerror
( "MA_Slow_Type input value wrong" ) ;
if MA_Slow_Length_Day <= 0 or
MA_Slow_Length_Day > 200 or
MA_Slow_Length_Day <= MA_Fast_Length_Day then
raiseruntimeerror
( "MA_Slow_Length_Day input value wrong" ) ;
if MA_Slow_Length_Day <= 0 or
MA_Slow_Length_Day > 200 or
MA_Slow_Length_Day <= MA_Fast_Length_Day then
raiseruntimeerror
( "MA_Slow_Length_Day input value wrong" ) ;
if PiercePercent < 0.00 or
PiercePercent >= 1.00 then
RaiseRunTimeError
( "PiercePercent input value wrong" ) ;
if Round_Control > 6 or
Round_Control < 0 then
RaiseRunTimeError
( "Round_Control input wrong (0-6)" ) ;
if Graph_Delay < 0 or Graph_Delay > 5 then
raiseruntimeerror
( "Graph_Delay input value wrong" ) ;
if Displace_MAF < ( - 5 ) or Displace_MAF > 5 then
raiseruntimeerror
( "Displace_MAF input value wrong" ) ;
if Displace_MAS < ( - 5 ) or Displace_MAS > 5 then
raiseruntimeerror
( "Displace_MAS input value wrong" ) ;
if Displace_LKC < ( - 5 ) or Displace_LKC > 5 then
raiseruntimeerror
( "Displace_LKC input value wrong" ) ;
if Displace_MKC < ( - 5 ) or Displace_MKC > 5 then
raiseruntimeerror
( "Displace_MKC input value wrong" ) ;
if Displace_UKC < ( - 5 ) or Displace_UKC > 5 then
raiseruntimeerror
( "Displace_UKC input value wrong" ) ;
if DisplayAdjustment <= 0 or
DisplayAdjustment >= 10.00 then
raiseruntimeerror
( "DisplayAdjustment input value wrong" ) ;
if dFormat <> "DDMMYYYY" and
dFormat <> "MMDDYYYY" and
dFormat <> "YYYYMMDD" then
RaiseRunTimeError
( "dFormat input value wrong" ) ;
end ;
{
______________________________________________________________
| H 2. Resets variable each pass.
|_____________________________________________________________
}
DirectionPredict = "Neutral" ;
{
______________________________________________________________
| H 3. Determines if this indicator is running in a
| RadarScreen table or in a chart.
|_____________________________________________________________
}
if currentbar = 1 then
begin
ChartorRadarScreen = getappinfo ( aiapplicationtype ) ;
if ChartorRadarScreen = 1 then
Chart = true
else
Chart = false ;
if ChartorRadarScreen = 2 then
RadarScreen = true
else
RadarScreen = false ;
if Chart = false and RadarScreen = false then
raiseruntimeerror
( "This indicator runs only in charts or RadarScreen" ) ;
end ;
if RadarScreen then
LBOC = date = juliantodate ( lastcalcjdate ) and
time = 100 * Mod
( IntPortion ( LastCalcMMTime / 60 ) , 24 ) +
( LastCalcMMTime -
60 * IntPortion ( LastCalcMMTime / 60 ) ) ;
{ ______________________________________________________________
| H 4. One time set up - intraday or day interval variables.
|_____________________________________________________________
}
if currentbar = 1 and ( bartype = 0 or bartype = 1 ) then
begin
TR_or_PR_Length = TR_or_PR_Length_ID ;
Mid_Channel_Length = Mid_Channel_Length_ID ;
MA_Fast_Length = MA_Fast_Length_ID ;
MA_Slow_Length = MA_Slow_Length_ID ;
end
else
if currentbar = 1 and bartype > 1 then
begin
TR_or_PR_Length = TR_or_PR_Length_Day ;
Mid_Channel_Length = Mid_Channel_Length_Day ;
MA_Fast_Length = MA_Fast_Length_Day ;
MA_Slow_Length = MA_Slow_Length_Day ;
end ;
{
******************************************************************
* KC 0. Keltner Channel Indicator
******************************************************************
}
{
______________________________________________________________
| KC 1. Average True Range , True Range and
| Price Range
|_____________________________________________________________
}
if True_Or_Price_Range = 1 and currentbar > 1 then
begin
if close [ 1 ] > high then
True_High = close [ 1 ]
else
True_High = high ;
if close [ 1 ] < low then
True_Low = close [ 1 ]
else
True_Low = low ;
True_Range = True_High - True_Low ;
if ATR_APR_SimpleOrExpRange = 2 then
Average_True_Range = round
( Average_True_Range [ 1 ] +
True_Range_Smooth *
( True_Range - Average_True_Range [ 1 ] ) ,
Round_Control ) ;
end ;
if True_Or_Price_Range = 1 and
currentbar >= TR_or_PR_Length and
ATR_APR_SimpleOrExpRange = 1 then
Average_True_Range = round
( averagefc2 ( True_Range ,
TR_or_PR_Length ) , Round_Control )
else
if True_Or_Price_Range = 1 and
currentbar < TR_or_PR_Length and
ATR_APR_SimpleOrExpRange = 1 then
Average_True_Range = True_Range ;
if True_Or_Price_Range = 1 and currentbar = 1 then
begin
True_Range = high - low ;
if ATR_APR_SimpleOrExpRange = 2 then
begin
Average_True_Range = True_Range ;
True_Range_Smooth = round
( 2 / ( TR_or_PR_Length + 1 ) ,
Round_Control ) ;
end
else
if ATR_APR_SimpleOrExpRange = 1 then
Average_True_Range = True_Range ;
end ;
if True_Or_Price_Range = 2 and currentbar > 1 and
ATR_APR_SimpleOrExpRange = 2 then
Average_Price_Range = round
( Average_Price_Range [ 1 ] + Price_Range_Smooth *
( Price_Range - Average_Price_Range [ 1 ] ) ,
Round_Control ) ;
if True_Or_Price_Range = 2 and
currentbar >= TR_or_PR_Length and
ATR_APR_SimpleOrExpRange = 1 then
Average_Price_Range = round
( averagefc2 ( Price_Range , TR_or_PR_Length ) ,
Round_Control )
else
if True_Or_Price_Range = 2 and
currentbar < TR_or_PR_Length and
ATR_APR_SimpleOrExpRange = 1 then
Average_Price_Range = high - low ;
if True_Or_Price_Range = 2 and currentbar = 1 then
begin
Price_Range = high - low ;
Average_Price_Range = Price_Range ;
end ;
{
______________________________________________________________
| KC 2. Determines which calculation of Price to use for
| calculating the Middle Keltner Channel.
|_____________________________________________________________
}
if Mid_Channel_PriceType = 1 then
Price = close
else
if Mid_Channel_PriceType = 2 then
Price = round ( ( open + close ) * 0.5 ,
Round_Control )
else
if Mid_Channel_PriceType = 3 then
Price = round ( ( high + low ) * 0.5 ,
Round_Control )
else
if Mid_Channel_PriceType = 4 then
Price = round ( ( high + low + close ) * 0.333 ,
Round_Control )
else
if Mid_Channel_PriceType = 5 then
Price = round ( ( open + low + high + close ) * 0.25 ,
Round_Control ) ;
{
______________________________________________________________
| KC 3. Calculates the Middle Keltner Channel.
|_____________________________________________________________
}
if Mid_Channel_SimpleOrExpAvg = 2 and currentbar > 1 then
Mid_Channel = round ( Mid_Channel [ 1 ] +
Mid_Channel_Smooth * ( Price - Mid_Channel [ 1 ] ) ,
Round_Control ) ;
if Mid_Channel_SimpleOrExpAvg = 1 and
currentbar >= Mid_Channel_Length then
Mid_Channel = round ( averagefc2
( Price, Mid_Channel_Length ) ,
Round_Control )
else
if Mid_Channel_SimpleOrExpAvg = 1 and
currentbar < Mid_Channel_Length then
Mid_Channel = Price ;
if Mid_Channel_SimpleOrExpAvg = 2 and currentbar = 1 then
begin
Mid_Channel = Price ;
Mid_Channel_Smooth = round
( 2 / ( Mid_Channel_Length + 1 ) ,
Round_Control ) ;
end ;
{
______________________________________________________________
| KC 4. Calculates the distance above and below the Middle
| Keltner Channel, for the Upper and Lower Keltner Channels.
|_____________________________________________________________
}
if True_or_Price_Range = 1 then
begin
Upper_Width = round ( Average_True_Range *
Upper_Factor , Round_Control ) ;
Lower_Width = round ( Average_True_Range *
Lower_Factor , Round_Control ) ;
end
else
if True_or_Price_Range = 2 then
begin
Upper_Width = round ( Average_Price_Range *
Upper_Factor , Round_Control ) ;
Lower_Width = round ( Average_Price_Range *
Lower_Factor , Round_Control ) ;
end ;
{
______________________________________________________________
| KC 5. Calculates the Upper and Lower Keltner Channels.
|_____________________________________________________________
}
Upper_Channel = Mid_Channel + Upper_Width ;
Lower_Channel = Mid_Channel - Lower_Width ;
{
______________________________________________________________
| KC 7. Alerts if candlestick price penetrates Keltner
| Channel by the PricePercent or more at close. This is
| helpful if seeking reversals and breakouts/breakdowns.
|_____________________________________________________________
}
if currentbar > Graph_Delay * maxlist
( TR_or_PR_Length , Mid_Channel_Length ) then
begin
if ( absvalue ( close - open) > 0 ) and
(( absvalue ( close - Upper_Channel ) ) /
absvalue ( close - open ) > PiercePercent ) and
( close - open ) >= 0 and ( close > Upper_Channel ) and
close crosses over Upper_Channel then
begin
if AlertsOn then
alert ( "Price closed over Upper KC" ) ;
DirectionPredict = "Caution" ;
if Chart and Display_Signals then
begin
Plot_Close_OverUKC =
high + DisplayAdjustment ;
Color_Close_OverUKC = CautionColor ;
end ;
if Radarscreen and LBOC then
begin
Color_UpperChannel = CautionColor ;
Color_Close_OverUKC = CautionColor ;
Color_$Predict = CautionColor ;
Plot_Close_OverUKC = Close ;
Plot_$Predict = DirectionPredict ;
end ;
end ;
if ( absvalue ( close - open) > 0 ) and
(( absvalue ( close - Upper_Channel ) ) /
absvalue ( close - open ) > PiercePercent ) and
( close - open ) <= 0 and ( close < Upper_Channel ) and
close crosses under Upper_Channel then
begin
if AlertsOn then
alert ( "Price closed under Upper KC" ) ;
DirectionPredict = "Bearish" ;
if Chart and Display_Signals then
begin
Plot_Close_UnderUKC =
high + DisplayAdjustment ;
Color_Close_UnderUKC = BearishColor ;
end ;
if RadarScreen and barstatus ( 1 ) = 2 and LBOC then
begin
Color_UpperChannel = BearishColor ;
Color_Close_UnderUKC = BearishColor ;
Color_$Predict = BearishColor ;
Plot_Close_UnderUKC = Close ;
Plot_$Predict = DirectionPredict ;
end ;
end ;
if ( absvalue ( close - open) > 0 ) and
( absvalue ( close - Lower_Channel ) ) /
absvalue ( close - open ) > PiercePercent and
( close - open ) <= 0 and ( close < Lower_Channel ) and
close crosses under Lower_Channel then
begin
if AlertsOn then
alert ( "Price closed under Lower KC" ) ;
DirectionPredict = "Caution" ;
if Chart and Display_Signals and
low - DisplayAdjustment > 0 then
begin
Plot_Close_UnderLKC = low - DisplayAdjustment ;
Color_Close_UnderLKC = CautionColor ;
end ;
if RadarScreen and barstatus ( 1 ) = 2 and LBOC then
begin
Color_LowerChannel = CautionColor ;
Color_Close_UnderLKC = CautionColor ;
Color_$Predict = CautionColor ;
Plot_Close_UnderLKC = Close ;
Plot_$Predict = DirectionPredict ;
end ;
end ;
if ( absvalue ( close - open) > 0 ) and
( absvalue ( close - Lower_Channel ) ) /
absvalue ( close - open ) > PiercePercent and
( close - open ) >= 0 and ( close > Lower_Channel ) and
close crosses above Lower_Channel then
begin
if AlertsOn then
alert ( "Price closed over Lower KC" ) ;
DirectionPredict = "Bullish" ;
if Chart and Display_Signals and
low - DisplayAdjustment > 0 then
begin
Plot_Close_OverLKC =
low - DisplayAdjustment ;
Color_Close_OverLKC = BullishColor ;
end ;
if RadarScreen and barstatus ( 1 ) = 2 and LBOC then
begin
Color_LowerChannel = BullishColor ;
Color_Close_OverLKC = BullishColor ;
Color_$Predict = BullishColor ;
Plot_Close_OverLKC = Close ;
Plot_$Predict = DirectionPredict ;
end ;
end ;
end ;
{ ______________________________________________________________
| I02. Indicator: Moving averages, fast and slow
|_____________________________________________________________
}
if MA_Fast_Type = 2 and currentbar > 1 then
MA_Fast = round
( MA_Fast [ 1 ] + MA_Fast_Smooth *
( close - MA_Fast [ 1 ] ) , Round_Control ) ;
if MA_Fast_Type = 1 and currentbar >= MA_Fast_Length then
MA_Fast = round ( kc_averagefc
( close , MA_Fast_Length ) ,
Round_Control )
else
if MA_Fast_Type = 1 and currentbar < MA_Fast_Length then
MA_Fast = round ( ( high + low ) * 0.5 ,
Round_Control ) ;
if MA_Fast_Type = 2 and currentbar = 1 then
begin
MA_Fast = round ( ( high + low ) * 0.5 ,
Round_Control ) ;
MA_Fast_Smooth = 2 / ( MA_Fast_Length + 1 ) ;
end ;
if MA_Slow_Type = 2 and currentbar > 1 then
MA_Slow = round
( MA_Slow [ 1 ] + MA_Slow_Smooth *
( close - MA_Slow [ 1 ] ) , Round_Control ) ;
if MA_Slow_Type = 1 and currentbar >= MA_Slow_Length then
MA_Slow = round ( kc_averagefc ( close ,
MA_Slow_Length ) , Round_Control )
else
if MA_Slow_Type = 1 and currentbar < MA_Slow_Length then
MA_Slow = round ( ( high + low ) * 0.5 ,
Round_Control ) ;
if MA_Slow_Type = 2 and currentbar = 1 then
begin
MA_Slow = round ( ( high + low ) * 0.5 ,
Round_Control ) ;
MA_Slow_Smooth = 2 / ( MA_Slow_Length + 1 ) ;
end ;
{ ______________________________________________________________
| RS 0 RadarScreen plots
|_____________________________________________________________
}
if RadarScreen and LBOC then
begin
{ ______________________________________________________________
| RS I RadarScreen indicator plots
|_____________________________________________________________
}
if Lower_Channel > 0 then
begin
plot21 ( Lower_Channel , "Lower KC" ,
Color_LowerChannel ) ;
end ;
if Upper_Channel > 0 then
begin
plot25 ( Upper_Channel , "Upper KC" ,
Color_UpperChannel ) ;
end ;
{ ______________________________________________________________
| RS A RadarScreen alert plots
|_____________________________________________________________
}
if Plot_$Predict <> "" then
begin
plot1 ( Plot_$Predict, "$ Predict" ,
Color_$Predict ) ;
Color_$Predict = rgb ( 0 , 0 , 0 ) ;
Plot_$Predict = "" ;
end ;
if Plot_Close_OverUKC > 0 then
begin
plot4 ( Plot_Close_OverUKC , "Close>UKC" ,
Color_Close_OverUKC ) ;
Color_Close_OverUKC = rgb ( 0 , 0 , 0 ) ;
Plot_Close_OverUKC = 0 ;
end ;
if Plot_Close_OverLKC > 0 then
begin
plot7 ( Close , "Close>LKC" ,
Color_Close_OverLKC ) ;
Color_Close_OverLKC = rgb ( 0 , 0 , 0 ) ;
Plot_Close_OverLKC = 0 ;
end ;
if Plot_Close_UnderUKC > 0 then
begin
plot12 ( Close , "Close<UKC" , Color_Close_UnderUKC ) ;
Color_Close_UnderUKC = rgb ( 0 , 0 , 0 ) ;
Plot_Close_UnderUKC = 0 ;
end ;
if Plot_Close_UnderLKC > 0 then
begin
plot15 ( Close , "Close<LKC" , Color_Close_UnderLKC ) ;
Color_Close_UnderLKC = rgb ( 0 , 0 , 0 ) ;
Plot_Close_UnderLKC = 0 ;
end ;
end ;
{ ______________________________________________________________
| CP 0 Chart plots
|_____________________________________________________________
}
if Chart and currentbar > 5 and currentbar >
Graph_Delay * maxlist ( MA_Fast_Length , MA_Slow_Length ,
TR_or_PR_Length , Mid_Channel_Length ) then
begin
{ ______________________________________________________________
| CP 1 Plots the indicators on charts
|_____________________________________________________________
}
if Display_KeltnerChannels and Lower_Channel > 0 then
plot60 [ Displace_LKC ] ( Lower_Channel ,
"LowerChannel" , Chart_Color_LKC ) ;
if Display_KeltnerChannels and Mid_Channel > 0 then
plot61 [ Displace_MKC ] ( Mid_Channel ,
"Mid_Channel" , Chart_Color_MKC ) ;
if Display_KeltnerChannels and Upper_Channel > 0 then
plot62 [ Displace_UKC ] ( Upper_Channel ,
"UpperChannel" , Chart_Color_UKC ) ;
if Display_MA_Fast and MA_Fast > 0 then
plot70 [ Displace_MAF ] ( MA_Fast ,
"MA Fast" , Chart_Color_MA_Fast ) ;
if Display_MA_Slow and MA_Slow > 0 then
plot71 [ Displace_MAS ] ( MA_Slow ,
"MA Slow" , Chart_Color_MA_Slow ) ;
{ ______________________________________________________________
| CP 1 Plots the alerts on charts
|_____________________________________________________________
}
if Display_Signals and Plot_Close_OverUKC > 0 then
begin
plot80 ( Plot_Close_OverUKC , "KC_Alert" ,
Color_Close_OverUKC ) ;
Plot_Close_OverUKC = 0 ;
Color_Close_OverUKC = rgb ( 0 , 0 , 0 ) ;
end
else
if Display_Signals and Plot_Close_UnderUKC > 0 then
begin
plot80 ( Plot_Close_UnderUKC , "KC_Alert" ,
Color_Close_UnderUKC ) ;
Plot_Close_UnderUKC = 0 ;
Color_Close_UnderUKC = rgb ( 0 , 0 , 0 ) ;
end
else
if Display_Signals and Plot_Close_UnderLKC > 0 then
begin
plot80 ( Plot_Close_UnderLKC , "KC_Alert" ,
Color_Close_UnderLKC ) ;
Plot_Close_UnderLKC = 0 ;
Color_Close_UnderLKC = rgb ( 0 , 0 , 0 ) ;
end
else
if Display_Signals and Plot_Close_OverLKC > 0 then
begin
plot80 ( Plot_Close_OverLKC , "KC_Alert" ,
Color_Close_OverLKC ) ;
Plot_Close_OverLKC = 0 ;
Color_Close_OverLKC = rgb ( 0 , 0 , 0 ) ;
end ;
end ;
{
******************************************************************
* C 0. Commentary window display
******************************************************************
}
if currentbar = 1 and CommentaryTable then
begin
Array_SetMaxIndex ( HTML_str , 1 ) ;
Symbol_Name = getsymbolname ;
end ;
#BeginCmtry ;
if AtCommentaryBar and CommentaryTable then
begin
if date <> date [ 1 ] then
begin
tYear = numtostr ( year ( date ) + 1900 , 0 ) ;
tMonth = numtostr ( month ( date ) , 0 ) ;
tDay = numtostr ( dayofmonth ( date ) , 0 ) ;
if strlen ( tMonth ) = 1 then
tMonth = "0" + tMonth ;
if strlen ( tDay ) = 1 then
tDay = "0" + tDay ;
if dFormat = "YYYYMMDD" then
KCA_Date = tYear + SepChar + tMonth +
SepChar + tDay
else
if dFormat = "MMDDYYYY" then
KCA_Date = tMonth + SepChar + tDay +
SepChar + tYear
else
if dFormat = "DDMMYYYY" then
KCA_Date = tDay + SepChar + tMonth +
SepChar + tYear
else
if dFormat = "YYMMDD" then
KCA_Date = rightstr ( tYear, 2 ) +
SepChar + tMonth + SepChar + tDay
else
if dFormat = "MMDDYY" then
KCA_Date = tMonth + SepChar + tDay +
SepChar + rightstr ( tYear , 2 )
else
if dFormat = "DDMMYY" then
KCA_Date = tDay + SepChar + tMonth +
SepChar + rightstr ( tYear , 2 )
else
raiseruntimeerror
( "Input to dFormat is incorrect" ) ;
KCA_Day = formatdate ( "ddd" ,
eldatetodatetime ( date )) ;
end ;
if time <> time [ 1 ] or date <> date [ 1 ] then
KCA_Time = formattime ( "hh:mm" ,
eltimetodatetime ( time ) ) ;
if bartype = 0 then
s = "Tick Interval"
else
if bartype = 1 then
s = "Intraday Interval"
else
if bartype = 2 then
s = "Day Interval"
else
if bartype = 3 then
s = "Week Interval"
else
if bartype = 4 then
s = "Month Interval"
else
if bartype = 5 then
s = "Point and Figure"
else
if bartype > 5 or bartype < 0 then
s = "Unknown Interval" ;
if Chart then
s = s + " - Chart"
else
if RadarScreen then
s = s + " - RadarScreen" ;
s = "<font color='black'> <b> " +
Symbol_Name + " - " + KCA_Time + ", " +
KCA_Day + ", " + KCA_Date + " - " +
s + "</b></font>" ;
commentary ( "<font size='+2'>" + s + "</font>" ) ;
if HTML_str [ 1 ] = "" then begin
Array_SetMaxIndex ( HTML_str , 6 ) ;
HTML_str [ 1 ] = { TblBorderColor } "#6699CC" ;
HTML_str [ 2 ] = { THBGColor } "#BEC8D1" ;
HTML_str [ 3 ] = { TblStyle }
"style='{ text-align: left;" +
"font-family: Verdana; " +
"font-weight: bold; " +
"font-size: 11px;" +
"color: #404040; " +
"background-color: #fafafa;" +
"border: 1px " +
HTML_str[ 1 ] + " ; " +
"border-collapse: collapse; " +
"border-spacing: 0px; }'" ;
HTML_str [ 4 ] = { THStyle }
"style= '{ text-align: center; " +
"border-bottom: 2px " + HTML_str[ 1 ]+"; " +
"border-left: 2px "+HTML_str[ 1 ]+"; " +
"background-color: "+HTML_str[ 2 ]+"; " + " }'" ;
HTML_str [ 5 ] = { Cell1Style }
"style= '{ color= #0000ff; }'" ;
HTML_str [ 6 ] = { Cell2Style }
"style= '{ text-align: right; }'" ;
end ;
commentary ( "<TABLE cellpadding=2 border=1 " +
HTML_str [ 3 ] + ">" ) ;
commentary ( "<TR>" +
"<TH " + HTML_str [ 4 ] + ">Data</>" +
"<TH " + HTML_str [ 4 ] + ">Value</>" + "</TR>" ) ;
commentary ( "<TR>" +
"<TD " + HTML_str [ 5 ] + ">Upper Channel" + "</>" +
"<TD " + HTML_str [ 6 ] + ">$" +
NumToStr ( Upper_Channel , 2 ) + "</></TR>" ) ;
commentary ( "<TR>" +
"<TD " + HTML_str [ 5 ] + ">Mid Channel" + "</>" +
"<TD " + HTML_str [ 6 ] + ">$" +
NumToStr ( Mid_Channel , 2 ) + "</></TR>" ) ;
commentary ( "<TR>" +
"<TD " + HTML_str [ 5 ] + ">Lower Channel" + "</>" +
"<TD " + HTML_str [ 6 ] + ">$" +
NumToStr ( Lower_Channel , 2 ) + "</></TR>" ) ;
commentary ( "<TR>" +
"<TD " + HTML_str [ 5 ] + ">Upper Width" + "</>" +
"<TD " + HTML_str [ 6 ] + ">$" +
NumToStr ( Upper_Width , 2 ) + "</></TR>" ) ;
commentary ( "<TR>" +
"<TD " + HTML_str [ 5 ] + ">Lower Width" + "</>" +
"<TD " + HTML_str [ 6 ] + ">$" +
NumToStr ( Lower_Width , 2 ) + "</></TR>" ) ;
commentary ( "<TR>" +
"<TD " + HTML_str [ 5 ] + ">Price" + "</>" +
"<TD " + HTML_str [ 6 ] + ">$" +
NumToStr ( Price , 2 ) + "</></TR>" ) ;
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
November 6th, 2010, 12:49 AM
Honolulu, Hawaii
Experience: Intermediate
Platform: NinjaTrader
Broker: ATC/TT, AMP/Zen-Fire, AMP/CQG
Trading: TF
Posts: 2,543 since Jun 2010
Thanks Given: 3,803
Thanks Received: 2,842
Code
if True_or_Price_Range = 1 then
commentary ( "<TR>" +
"<TD " + HTML_str [ 5 ] +
">Average True Range" + "</>" +
"<TD " + HTML_str [ 6 ] + ">$" +
NumToStr ( Average_True_Range , 2 ) +
"</></TR>" )
else
if True_or_Price_Range = 2 then
commentary ( "<TR>" +
"<TD " + HTML_str [ 5 ] +
">Average Price Range" + "</>" +
"<TD " + HTML_str [ 6 ] + ">$" +
NumToStr ( Average_Price_Range , 2 ) +
"</></TR>" ) ;
if DirectionPredict = "Bullish" then
commentary ( "<TR>" +
"<TD><font color='green'> <b>" + "Direction Predict" +
"</>" +
"<TD><font color='green'> <b>" + DirectionPredict +
"</b></font></></TR>" )
else
if DirectionPredict = "Bearish" then
commentary ( "<TR>" +
"<TD><font color='red'> <b>" + "Direction Predict" +
"</>" +
"<TD><font color='red'> <b>" + DirectionPredict +
"</b></font></></TR>" )
else
if DirectionPredict = "Caution" then
commentary ( "<TR>" +
"<TD><font color='orange'> <b>" + "Direction Predict" +
"</>" +
"<TD><font color='orange'> <b>" + DirectionPredict +
"</b></font></></TR>" )
else
if DirectionPredict = "Neutral" then
commentary ( "<TR>" +
"<TD><font color='gray'> <b>" + "Direction Predict" +
"</>" +
"<TD><font color='gray'> <b>" + DirectionPredict +
"</b></font></></TR>" ) ;
commentary ( "</TABLE>" ) ;
commentary ( BuildKCAll ) ;
end ;
#end ;
if RadarScreen then
value99 = ticks ;
November 6th, 2010, 02:28 AM
las vegas
Experience: Intermediate
Platform: Sierra Chart
Broker: Velocity/IB
Trading: 6E
Posts: 1,145 since Feb 2010
Thanks Given: 304
Thanks Received: 844
what does it do?
November 6th, 2010, 06:11 AM
Berlin, Europe
Market Wizard
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,103
vegasfoster
We cannot try to decipher hundred lines of code. If you show us a chart, we might be able to put this up in a few minutes. The code actually looks like two keltner channels.
A keltner channel is very simple:
- a moving average (which Type, SMA , EMA, exotic, which period?)
- some bands (based on simple range or average true range , bandperiod?)
- smoothing (do you want some smoothing added to the bands)
- alerts (any alerts required?)
So we would need a chart and a small description, how you use it.
November 6th, 2010, 06:35 PM
Quebec Canada
Market Wizard
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: ES, NQ, YM
Frequency: Daily
Duration: Minutes
Posts: 4,527 since Oct 2009
Thanks Given: 4,179
Thanks Received: 6,022
Fat Tails
We cannot try to decipher hundred lines of code. If you show us a chart, we might be able to put this up in a few minutes. The code actually looks like two keltner channels.
A keltner channel is very simple:
- a
moving average (which Type,
SMA , EMA, exotic, which period?)
- some bands (based on simple
range or
average true range , bandperiod?)
- smoothing (do you want some smoothing added to the bands)
- alerts (any alerts required?)
So we would need a chart and a small description, how you use it.
YouTube - Keltner Channel
November 6th, 2010, 07:07 PM
Honolulu, Hawaii
Experience: Intermediate
Platform: NinjaTrader
Broker: ATC/TT, AMP/Zen-Fire, AMP/CQG
Trading: TF
Posts: 2,543 since Jun 2010
Thanks Given: 3,803
Thanks Received: 2,842
Fat Tails
We cannot try to decipher hundred lines of code. If you show us a chart, we might be able to put this up in a few minutes. The code actually looks like two keltner channels.
A keltner channel is very simple:
- a
moving average (which Type,
SMA , EMA, exotic, which period?)
- some bands (based on simple
range or
average true range , bandperiod?)
- smoothing (do you want some smoothing added to the bands)
- alerts (any alerts required?)
So we would need a chart and a small description, how you use it.
It is utilized like Bollinger Bands, but the calculation is a bit different.
Here are some photos of it in my trading:
https://nexusfi.com/attachments/23528d1287515418
https://nexusfi.com/attachments/23617d1287594507
Basically on the smaller timeframes you use it for when it exceeds the Keltner Channel you then expect it to retrace. Like I used it on the 144 mainly and if it exceeds the Keltner or just touches it then it is a good chance it will float back towards the center or opposite side of the band. It really is just a visual ATR indicator.
It is used in conjunction with many indicators and for some reason the one that is default with NinjaTrader is VERY much different than the one I used in TradeStation which was custom built.
The code doesn't seem overwhelming, but I know very little to nothing about C#, so I figured this would be an easy feat for good coders. If it were MQL, I would have little issues, but I need help on this one, otherwise I will end up spending a month for this guy.
Thanks in advance for any assistance and for even looking at it.
PS- I don't need anything but the center band and the 2 outside bands. The alerts, MA's etc.. Don't need em'
November 6th, 2010, 10:08 PM
Honolulu, Hawaii
Experience: Intermediate
Platform: NinjaTrader
Broker: ATC/TT, AMP/Zen-Fire, AMP/CQG
Trading: TF
Posts: 2,543 since Jun 2010
Thanks Given: 3,803
Thanks Received: 2,842
Ok, so here is a perfect example of how they are different. I don't know if my settings are correct, but for TS they are the default and for NT they are 2,52
I hope this explains on the differences between the default keltner in Ninja and this one.
November 6th, 2010, 10:45 PM
Honolulu, Hawaii
Experience: Intermediate
Platform: NinjaTrader
Broker: ATC/TT, AMP/Zen-Fire, AMP/CQG
Trading: TF
Posts: 2,543 since Jun 2010
Thanks Given: 3,803
Thanks Received: 2,842
I am also trying to get tickcounter2 to work like the view from my TradeStation account.
However, when I select 'Float_with_Price', it actually puts it next to price on the right. I want it to be next to the bar like in Tradestation.
How would I change this code to be off the current tick price in the bar?
Code
case DisplayLocation.Float_with_price:
x = bounds.X + bounds.Width - ChartControl.BarMarginRight + 5;
y = (int)(((bounds.Y + bounds.Height) - ((Close[0] - min) / ChartControl.MaxMinusMin(max, min)) * bounds.Height) - textHeight*0.4);
if(ChartControl.BarMarginRight < textWidth-12)
graphics.DrawString("Increase chart Properties - Right side margin", TextFont, textBrush, bounds.X + bounds.Width - noTickTextWidth, bounds.Y + bounds.Height - noTickTextHeight, stringFormat);
break;
November 7th, 2010, 12:42 AM
Honolulu, Hawaii
Experience: Intermediate
Platform: NinjaTrader
Broker: ATC/TT, AMP/Zen-Fire, AMP/CQG
Trading: TF
Posts: 2,543 since Jun 2010
Thanks Given: 3,803
Thanks Received: 2,842
Here is the code for the Tradestation ticker which is quite nice and it glows red when the bar is about to close.
Code
// ==================================================
// PZT TICK COUNTDOWN Indicator (Version 2.0)
// ==================================================
inputs:
tickThreshold(20),
normalColor(yellow),
thresholdColor(red),
horizOffset(0);
variables:
setPosition( 0 ),
tickReg( 0 ),
txtStr( "" ),
txtID( -1 ),
horizontalLocation(-2),
txtPos( 0 );
if BarType = 0 then begin
setPosition = Close;
if BarNumber = 1 then begin
txtID = text_new(date,time,close,"Start");
if horizontalLocation = 0 then text_SetStyle(txtID,1,2)
else text_SetStyle(txtID,1,2);
text_SetColor(txtID,normalColor);
end;
if time <> time[1] or tickReg <= 0 then begin
tickReg = BarInterval;
if horizontalLocation <= 0 then begin
text_SetStyle(txtID,0,1);
Text_SetLocation( TxtID,Date,Calctime( Time, -horizontalLocation),setPosition ) ;
end
else begin
text_SetStyle(txtID,1,2);
txtPos = setPosition;
text_SetLocation(txtID,date[horizontalLocation],time[horizontalLocation],setPosition);
end;
end;
tickReg = tickReg - ticks;
TxtStr = "< "+NumToStr(tickReg,0);
if tickReg >= 10 then begin
horizontalLocation = -3-horizOffset;
end;
if tickReg >= 100 then begin
horizontalLocation = -4-horizOffset;
end;
text_SetString(txtID,TxtStr);
if horizontalLocation <= 0 then begin
if close < open then begin
text_SetStyle(txtID,1,2);
Text_SetLocation( TxtID,Date,Calctime( Time, -horizontalLocation),setPosition);
end
else begin
text_SetStyle(txtID,1,2);
Text_SetLocation( TxtID,Date,Calctime( Time, -horizontalLocation),setPosition);
end;
end;
if tickReg > tickThreshold then text_SetColor(txtID,normalColor)
else text_SetColor(txtID,thresholdColor);
end;
Last Updated on November 8, 2010