Why cant I see upper and lower keltner lines on chart?
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
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.
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.
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); }