Hi can you plz help me in this afl code
i want use Heikin Ashi of Foreign Ticker to generate signal on Main Chart
I.e. when Foreign Ticker turn red candle in Heikin Ashi It should give buy Signal on main chart
I dont know what going wrong
_SECTION_BEGIN("ABC");
SetForeign( "ForeignTickereHere" );
SetChartOptions(0,chartShowArrows | chartShowDates);
HaClose = (O + H + L + C)/4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
xDiff = (HaHigh - Halow) * 10000;
CondB8F = HaOpen < HaClose;
CondS8F = HaOpen > HaClose;
CondB9F = HaLow > ME;
CondS9F = HaHigh < ME;
//Plot(TL,"",colorPink,styleLine);
//Plot(BL,"",colorPink,styleLine);
CondB8F = HaOpen < HaClose;
CondS8F = HaOpen > HaClose;
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorCycle );
Style = ParamStyle("Style");
MBT =BBandTop( P, Periods, Width );
MBL= BBandBot( P, Periods, Width );
Foreign_atr = ATR(20);
RestorePriceArrays();
_SECTION_END();
_SECTION_BEGIN("heiken");
SetChartOptions(0,chartShowArrows | chartShowDates);
HaClose = (O + H + L + C)/4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
xDiff = (HaHigh - Halow) * 10000;
barcolor = IIf(HaClose >= HaOpen,colorBrightGreen,colorRed);
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "", barcolor, styleCandle );
;
Plot(ME,"",colorBlue,styleLine);
Plot(TL,"",colorPink,styleLine);
Plot(BL,"",colorPink,styleLine);
CondB8 = HaOpen < HaClose;
CondS8 = HaOpen > HaClose;
Buy = Cover= CondS8F ;
Short= Sell=CondB8F ;
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);
Long=Flip(Buy,Sell);
Shrt=Flip(Short,Cover);
/* We use live prices here, as ValueWhen function gives negative price sometimes */
buyPrice = LastValue(C);
sellPrice = LastValue(C);
D= floor(10000/C);
SetPositionSize( 500, spsShares ); // max share that can be bought in rs10000 shares by default
PlotShapes(IIf(Buy, shapeUpArrow , shapeNone), colorBlue);
PlotShapes(IIf(Short, shapeDownArrow , shapeNone), colorBlack);
PlotShapes(IIf(Sell, shapeStar , shapeNone), colorBlue);
PlotShapes(IIf(Cover, shapeHollowSmallSquare , shapeNone), colorBlack);
_SECTION_END();
Moderator comment: added REQUIRED code tags
Kind regards
Sam