Why cant I see upper and lower keltner lines on chart?

 

In the following code im trying to simply create keltner channels but i cant see why it doesnt display the upper and lower lines on the chart. 

input int Keltner_Period=20;
input double Keltner_ATR=1.5;
input int Keltner_MaMode=MODE_SMA;

// OnTick() event handler                
void OnTick()
{
   double close = Close[1];  
   datetime time = iTime(_Symbol,0,1);
 
   string ob_Longs = "Longs "+TimeToStr(time);    
   string ob_Shorts = "Shorts "+TimeToStr(time);

   //--- Indicator Calculations
   double Kelt_Mid_Band = iMA(_Symbol,_Period,Keltner_Period,0,Keltner_MaMode,PRICE_CLOSE,i);
   double Kelt_Upper_Band = Kelt_Mid_Band + (iATR(_Symbol,_Period,Keltner_Period,i)*Keltner_ATR);
   double Kelt_Lower_Band = Kelt_Mid_Band - (iATR(_Symbol,_Period,Keltner_Period,i)*Keltner_ATR);'

   if(close > Kelt_Upper_Band) ObjectCreate(ob_Longs,OBJ_ARROW_UP,0,time,close);      

   if(close < Kelt_Lower_Band) ObjectCreate(ob_Shorts,OBJ_ARROW_DOWN,0,time,close);            
}









 

You don't have any code to draw the lines

   double Kelt_Mid_Band = iMA(_Symbol,_Period,Keltner_Period,0,Keltner_MaMode,PRICE_CLOSE,i);
   double Kelt_Upper_Band = Kelt_Mid_Band + (iATR(_Symbol,_Period,Keltner_Period,i)*Keltner_ATR);
   double Kelt_Lower_Band = Kelt_Mid_Band - (iATR(_Symbol,_Period,Keltner_Period,i)*Keltner_ATR);'

 I don't see where i is declared or given a value

 
GumRai:

You don't have any code to draw the lines

 I don't see where i is declared or given a value

I forgot to add int  i = 0; in my forum thread. I have tried to use int  i = 0; but i can only see the moving average? The ATR line appears as an ATR indicator in the seperate window. But I need to see it as an upper and lower keltner line? 

The code does work as intended but its for some reason the keltner bands are invisible? 

 

input int Keltner_Period=20;
input double Keltner_ATR=1.5;
input int Keltner_MaMode=MODE_SMA;

// OnTick() event handler                
void OnTick()
{
   double close = Close[1];  
   datetime time = iTime(_Symbol,0,1);
 
   string ob_Longs = "Longs "+TimeToStr(time);    
   string ob_Shorts = "Shorts "+TimeToStr(time);

   int i = 1;

   //--- Indicator Calculations
   double Kelt_Mid_Band = iMA(_Symbol,_Period,Keltner_Period,0,Keltner_MaMode,PRICE_CLOSE,i);
   double Kelt_Upper_Band = Kelt_Mid_Band + (iATR(_Symbol,_Period,Keltner_Period,i)*Keltner_ATR);
   double Kelt_Lower_Band = Kelt_Mid_Band - (iATR(_Symbol,_Period,Keltner_Period,i)*Keltner_ATR);'

   if(close > Kelt_Upper_Band) ObjectCreate(ob_Longs,OBJ_ARROW_UP,0,time,close);      

   if(close < Kelt_Lower_Band) ObjectCreate(ob_Shorts,OBJ_ARROW_DOWN,0,time,close);            
}
 
If you want to see the lines, I suggest that you write an indicator to show the lines.
 
GumRai:
If you want to see the lines, I suggest that you write an indicator to show the lines.
Is it not possible to see keltner lines on an expert advisor as it is say bollinger bands using iBand() function? 
 
Unless something has changed, calling iBand() from an EA will not cause the BB lines to be printed on the chart. The exception being in the strategy tester at the end of a test.
 
GumRai:
Unless something has changed, calling iBand() from an EA will not cause the BB lines to be printed on the chart. The exception being in the strategy tester at the end of a test.
Is it possible to use an indicator like an include file so i could write it then apply it to an EA?
 
Eas cannot draw lines in the same way as an indicator using buffers
 
EA's have no eyes; they don't need it to be on the chart. If you need it to be, attach the indicator.
Reason: