Join our facebook group for Amibroker afl code discussion https://www.facebook.com/groups/603980776889348

Next Candle Prediction With Candlestick Demo



Next Candle Prediction With Candlestick Demo
Next Candle Prediction With Candlestick Demo




//www.aflcode.com

_SECTION_BEGIN("Candle Stick Demo");

BI    = BarIndex();
barvisible  = Status("barvisible");
FirstBarIndx= LastValue( Lowest(ValueWhen(BarVisible,BI)));
LastBarIndx = LastValue( Highest(ValueWhen(BarVisible,BI)));
FirstBarVis = FirstBarIndx == BI; 
LastBarVis  = LastBarIndx == BI; 

Width=Param("Bar Width",5,1,30,1);
EndCandle = SelectedValue(BarIndex())+int(Width/2)+1; 
StartCandle = Endcandle-Width;
CandleData = Flip(StartCandle == BI,EndCandle == BI);

MAsk2 = IIf(BI>=StartCandle,1,Null);
MAsk1 = IIf(CandleData OR LastBarVis, 1, Null);

Oc = LastValue(ValueWhen(StartCandle == BI, O));
Hc = LastValue(ValueWhen(CandleData , HHV(H,Width)));
Lc = LastValue(ValueWhen(CandleData , LLV(L,Width)));
CC = LastValue(ValueWhen(CandleData , C));

O = IIf( LastBarVis, Oc, O);
H = IIf( LastBarVis, HC, H);
L = IIf( LastBarVis, LC, L);
C = IIf( LastBarVis, CC, C);

if( Param("Style: Candle/Bar",0,0,1,1) == 0 ) BarStyle = 64; else BarStyle = 128; 
Plot(C,"",1,BarStyle |styleNoLabel|styleThick);
Plot(Mask2*Oc,"",7,styleStaircase);
Plot(Mask2*CC,"",2,styleStaircase);
Plot(Mask2*HC,"",8,styleStaircase);
Plot(Mask2*LC,"",4,styleStaircase);

Co1 = Param("BackGroundColor",47,0,64,1);
Plot(Mask1*LC,"",Co1,styleArea);
Co2 = Param("CandleAreaColor",39,0,64,1);
Plot(Mask1*HC,"",Co2,styleArea);

Title="\nCandlestick Demo\n"+
"Candle Date:   "+Date()+"\n"+
"Candle Width:   "+NumToStr(Width,1.0)+" bars\n";

GraphXSpace = 5;
 
_SECTION_END();

Previous
Next Post »