Simple Coding Help - No Promise.

Is it possible to import additional data to amibroker? I mean apart from the usual price,volume,oi components. I use the josh utility to pull data from nest to ami. Would also like to pull TBQ/TSQ, . Basically, i think that there should be no restriction as to the no. of such data items that one can get into ami. A lot of items can be had on display on the marketwatch
image
of course many of the items above are not relevant in all cases. for eg: no call rho is possible for a futures scrip. Is there any afl code to make this happen
 
With due respect to senior programmers: I have been able to add macd to multi-timeframe ema crossover system afl, which I reproduce to beginner's benefit:
_SECTION_BEGIN("Multipe Timeframe EMA Crossover");
SetChartOptions(0,chartShowArrows|chartShowDates);
bc=ParamColor("Bacground Color",colorGrey40 );
SetChartBkColor( bc);
DayH = TimeFrameGetPrice("H", inDaily, 0);
DayL = TimeFrameGetPrice("L", inDaily, 0);
DayC = TimeFrameGetPrice("C", inDaily, 0);
DayO = TimeFrameGetPrice("O", inDaily, 0);
pDayC = TimeFrameGetPrice("C", inDaily, -1);
pi= (DayH + DayL +DayC+DayO)/4;
if( ParamToggle("Plot current day Pivot", "No|Yes", 0))
Plot( pi," \nPiv : ", ParamColor( "Color", colorBlack ), ParamStyle("Style") );
//_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} \n Op %g, \n Hi %g, \n Lo %g, \n Cl %g, \n "+ EncodeColor(colorBlue)+"Pi=> %g
//{{VALUES}}", O, H, L, C, pi ));
function GetSecondNum()
{
Time = Now( 4 );
Seconds = int( Time % 100 );
Minutes = int( Time / 100 % 100 );
Hours = int( Time / 10000 % 100 );
SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
return SecondNum;
}
RequestTimedRefresh( 1 );
TimeFrame = Interval();
SecNumber = GetSecondNum();
Newperiod = SecNumber % TimeFrame == 0;
SecsLeft = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
SecsToGo = TimeFrame - SecsLeft;
x=Param("xposn",300,0,1000,1);
y=Param("yposn",50,0,1000,1);
GfxSelectSolidBrush( ColorRGB( 230, 230, 230 ) );
GfxSelectPen( ColorRGB( 230, 230, 230 ), 2 );
if ( NewPeriod )
{
GfxSelectSolidBrush( colorYellow );
GfxSelectPen( colorYellow, 2 );
}
FS=Param("Font Size",15,11,100,1);
GfxSelectFont("Callibri", FS , 700, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( colorBlack );
Hor1=Param("Horizontal Position1",820,1,1200,1);
Ver1=Param("Vertical Position1",1,1,830,1);
//GfxTextOut(""+C, Hor1, Ver1);
GfxSetTextColor( colorGrey50 );
//GfxTextOut("PC:"+pDayC,700, Ver1);
GfxSetTextColor( colorBlue );
//GfxTextOut("C:"+DayC, 600, Ver1);
GfxSetTextColor(colorRed );
//GfxTextOut("L:"+DayL,500, Ver1);
GfxSetTextColor(colorBrightGreen );
//GfxTextOut("H:"+DayH,400, Ver1);
GfxSetTextColor( colorLightBlue );
//GfxTextOut("O:"+DayO,300, Ver1);
DD=Prec(C-pDayC ,2);
xx=Prec((DD/pDayC )*100,2);
GfxSelectFont("Times New Roman", 11, 700, True );
GfxSetBkMode( colorBlack );
GfxSetTextColor(colorGrey50 );
//GfxTextOut(""+DD+" ("+xx+"%)", Hor1, Ver1+ 45 );
//1m
ec=WriteIf(EMA(C,5)>EMA(C,13) OR EMA(C,5)<EMA(C,13),"One","x");
ec2=WriteIf(EMA(C,5)>EMA(C,13) AND EMA(C,5)>EMA(C,20),"On","x");
ec3=WriteIf(EMA(C,5)<EMA(C,13) AND EMA(C,5)<EMA(C,20),"Oe","x");
//5m
TimeFrameSet(in5Minute);
e5=EMA(C,5);
e13=EMA(C,13);
e20=EMA(C,20);
TimeFrameRestore();
e5x5=TimeFrameExpand( e5, in5Minute,expandLast );
e5x13=TimeFrameExpand( e13, in5Minute,expandLast );
e5x20=TimeFrameExpand( e20, in5Minute,expandLast );
e5c=WriteIf(e5x5>e5x13 OR e5x5<e5x13,"One","x");
e5c2=WriteIf(e5x5>e5x13 AND e5x5>e5x20,"On","x");
e5c3=WriteIf(e5x5<e5x13 AND e5x5<e5x20,"Oe","x");
//15m
TimeFrameSet(in15Minute);
e15=EMA(C,5);
e113=EMA(C,13);
e120=EMA(C,20);
TimeFrameRestore();
e15x5=TimeFrameExpand( e15, in15Minute,expandLast );
e15x13=TimeFrameExpand( e113, in15Minute,expandLast );
e15x20=TimeFrameExpand( e120, in15Minute,expandLast );
e15c=WriteIf(e15x5>e15x13 OR e15x5<e15x13,"One","x");
e15c2=WriteIf(e15x5>e15x13 AND e15x5>e15x20,"On","x");
e15c3=WriteIf(e15x5<e15x13 AND e15x5<e15x20,"Oe","x");
//1h
TimeFrameSet(inHourly);
e51=EMA(C,5);
e131=EMA(C,13);
e201=EMA(C,20);
TimeFrameRestore();
ehx5=TimeFrameExpand( e51, inHourly,expandLast );
ehx13=TimeFrameExpand( e131, inHourly,expandLast );
ehx20=TimeFrameExpand( e201, inHourly,expandLast );
ehc=WriteIf(ehx5>ehx13 OR ehx5<ehx13,"One","x");
ehc2=WriteIf(ehx5>ehx13 AND ehx5>ehx20,"On","x");
ehc3=WriteIf(ehx5<ehx13 AND ehx5<ehx20,"Oe","x");
//4h
TimeFrameSet(inHourly*4);
eh51=EMA(C,5);
eh131=EMA(C,13);
eh201=EMA(C,20);
TimeFrameRestore();
eh4x5=TimeFrameExpand( eh51, inHourly*4,expandLast );
eh4x13=TimeFrameExpand( eh131, inHourly*4,expandLast );
eh4x20=TimeFrameExpand( eh201, inHourly*4,expandLast );
e4hc=WriteIf(eh4x5>eh4x13 OR eh4x5<eh4x13,"One","x");
e4hc2=WriteIf(eh4x5>eh4x13 AND eh4x5>eh4x20,"On","x");
e4hc3=WriteIf(eh4x5<eh4x13 AND eh4x5<eh4x20,"Oe","x");
//d
TimeFrameSet(inDaily);
ed5=EMA(C,5);
ed13=EMA(C,13);
ed20=EMA(C,20);
TimeFrameRestore();
edx5=TimeFrameExpand( ed5, inDaily,expandLast );
edx13=TimeFrameExpand( ed13, inDaily,expandLast );
edx20=TimeFrameExpand( ed20, inDaily,expandLast );
edc=WriteIf(edx5>edx13 OR edx5<edx13,"One","x");
edc2=WriteIf(edx5>edx13 AND edx5>edx20,"On","x");
edc3=WriteIf(edx5<edx13 AND edx5<edx20,"Oe","x");

Hor=Param("Horizontal Position",600,1,1200,1);
Ver=Param("Vertical Position",35,30,1000,1);
///1
GfxSelectFont("Callibri", 10 , 700, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( colorBlue );
GfxTextOut("EMA Sig ",Hor, Ver);
GfxSetTextColor( colorBlue );
GfxTextOut("1 M ",Hor+72, Ver-15);

if(ec=="One")
GfxSelectSolidBrush(colorGold);
if(ec2=="On")
GfxSelectSolidBrush(colorBrightGreen);
if(ec3=="Oe")
GfxSelectSolidBrush(colorRed);
GfxSelectPen( colorBlack, 1 ); // broader color
GfxRectangle( Hor+70,Ver+5,Hor+100,Ver+15 );
///2
GfxSetTextColor( colorBlue );
GfxTextOut("5 M ",Hor+112, Ver-15);


if(e5c=="One")
GfxSelectSolidBrush(colorGold);
if(e5c2=="On")
GfxSelectSolidBrush(colorBrightGreen);
if(e5c3=="Oe")
GfxSelectSolidBrush(colorRed);
GfxRectangle( Hor+110,Ver+5,Hor+140,Ver+15 );
///3
GfxSetTextColor( colorBlue );
GfxTextOut("15 M ",Hor+150, Ver-15);

if(e15c=="One")
GfxSelectSolidBrush(colorGold);
if(e15c2=="On")
GfxSelectSolidBrush(colorBrightGreen);
if(e15c3=="Oe")
GfxSelectSolidBrush(colorRed);
GfxRectangle( Hor+150,Ver+5,Hor+180,Ver+15 );
///4
GfxSetTextColor( colorBlue );
GfxTextOut("1 H ",Hor+193, Ver-15);


if(ehc=="One")
GfxSelectSolidBrush(colorGold);
if(ehc2=="On")
GfxSelectSolidBrush(colorBrightGreen);
if(ehc3=="Oe")
GfxSelectSolidBrush(colorRed);
GfxRectangle( Hor+190,Ver+5,Hor+220,Ver+15 );
//5
GfxSetTextColor( colorBlue );
GfxTextOut("4 H ",Hor+233, Ver-15);


if(e4hc=="One")
GfxSelectSolidBrush(colorGold);
if(e4hc2=="On")
GfxSelectSolidBrush(colorBrightGreen);
if(e4hc3=="Oe")
GfxSelectSolidBrush(colorRed);
GfxRectangle( Hor+230,Ver+5,Hor+260,Ver+15 );
//6
GfxSetTextColor( colorBlue );
GfxTextOut("D ",Hor+280, Ver-15);


if(edc=="One")
GfxSelectSolidBrush(colorGold);
if(edc2=="On")
GfxSelectSolidBrush(colorBrightGreen);
if(edc3=="Oe")
GfxSelectSolidBrush(colorRed);
GfxRectangle( Hor+270,Ver+5,Hor+300,Ver+15 );
_SECTION_END();
m=MACD();
ma5b=m>0;
ma5s=m<0;
ma5bs=WriteIf(ma5b,"bull",WriteIf(ma5s,"bear","avoid"));
Hor=Param("Horizontal Position",25,1,1200,1);
Ver=Param("Vertical Position",35,30,1000,1);
///1
GfxSelectFont("Callibri", 10 , 700, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( colorWhite );
//1
if(ma5bs=="bull")
GfxSelectSolidBrush(colorBrightGreen);
if(ma5bs=="bear")
GfxSelectSolidBrush(colorRed);
if(ma5bs=="avoid")
GfxSelectSolidBrush(colorGold);
GfxSelectPen( colorBlack, 1 ); // broader color
GfxRectangle( Hor+880,Ver+5,Hor+910,Ver+15 );
//GfxTextOut(" MACD ",Hor+330, Ver-15);
GfxSetTextColor( colorBlue );
GfxTextOut(" MACD ",Hor+878, Ver-15);
 
Friends,

Can somebody code an AFL scanner which gives me the following ...

It should scan stocks which had 7 higher highs or 7 lower lows continuously.

For Ex if I run the scanner or explorer on 24.12.2015 ... It should throw out stocks which had 7 continuous HH or 7 continuous LL on 24.12.2015 EOD .

Thanks a lot
 
Hello Amit ji & all seniors...

i need help to plot exploration for following condition -


For Buy Condition -

1. Price should be above EMA 20 & 50
2. Adx (14) (+DI) Crossing (-DI) in positive way
3 RSI (14 Should be crossing 50 level from below.

If all 3 condition satisfy then Its a BUY



For Sell Condition

1 Price should be below Ema 20 and 50
2 Adx(14) (-DI) Crossing (+DI) in negative way
3 RSI (14) Should be crossing 50 level from top

If all 3 conditions satisfy then its a Sell.


Once check chart - Marking is done on chart with Horizontal lines.

kindly help
 
Last edited:

amitrandive

Well-Known Member
Hello Amit ji & all seniors...

i need help to plot exploration for following condition -


For Buy Condition -

1. Price should be above EMA 20 & 50
2. Adx (14) (+DI) Crossing (-DI) in positive way
3 RSI (14 Should be crossing 50 level from below.

If all 3 condition satisfy then Its a BUY



For Sell Condition

1 Price should be below Ema 20 and 50
2 Adx(14) (-DI) Crossing (+DI) in negative way
3 RSI (14) Should be crossing 50 level from top

If all 3 conditions satisfy then its a Sell.


Once check chart - Marking is done on chart with Horizontal lines.

kindly help
Something similar :D

http://www.wi sest ocktrader.com/indicators/1491-combining-ema-crossover-and-adx
http://www.wisest ocktra der.com/indicators/3756-adx-buy-sell-for-ami-5-3
 
Guys,

Can some one please help me with this:

The oscillator (code included below-Section-1) must use the ATP value from the second code (Section-2)

Section-1

HTML:
_SECTION_BEGIN("CYBER STOCH");
//==================================
//==================================
// 	From John Ehler's book     ===
// 	Rocket Science for Traders ===
//                     	     		===
// 	AFL By Robert Dunbar  	   ===
//==================================
//==================================

Arrows = ParamToggle( "Buy/Sell Arrows", "No|Yes", 1 );
alpha = Param( "Alpha", 0.07, 0.01, 0.4, 0.01, 0.01 );
Len = Param( "Length", 8, 1, 25, 1, 1 );
BullSig = BearSig = Trigger = Cycle = MaxCycle = MinCycle = Value1 = Value2 =
0;
PriceIn = ( ( H + L ) / 2 );

SmoothX = ( PriceIn + 2 * Ref( PriceIn, -1 ) + 2 * Ref( PriceIn, -2 ) + Ref(
PriceIn, -3 ) ) / 6;


for ( i = 6; i < BarCount; i++ )
{
    Cycle[i] = ( ( 1 - 0.5 * alpha ) ^ 2 ) * ( SmoothX[ i ] - 2 * SmoothX[ i - 1
] + SmoothX[ i - 2] ) + 2 * ( 1 - alpha ) * Cycle[ i - 1 ] - ( ( 1 - alpha ) ^ 2
) * Cycle[ i - 2 ];

    if ( i < 7 )
        Cycle[i] = ( PriceIn[i] - 2 * PriceIn[i-1] + PriceIn[i-2] ) / 4;
}

MaxCycle = HHV( Cycle, Len );

MinCycle = LLV( Cycle, Len );

Value1 = IIf( MaxCycle != MinCycle, ( Cycle - MinCycle ) / ( MaxCycle - MinCycle
), Value1 );

Value2 = ( 4 * Value1 + 3 * Ref( Value1, -1 ) + 2 * Ref( Value1, -2 ) + Ref(
Value1, -3 ) ) / 10;

Value2 = 2 * ( Value2 - 0.5 );

Trigger = ( 0.96 * ( Ref( Value2, -1 ) + 0.02 ) );

BullSig = IIf( Cross( Value2, Trigger ), True, False );
BearSig = IIf( Cross( Trigger, Value2 ), True, False );


Plot( Value2, "CyberCycle", colorLightBlue );
Plot( Trigger , "Trigger", colorRed );
Plot( 0 , "", colorWhite, styleDashed );

if ( Arrows )
{
    PlotShapes( shapeUpArrow*BullSig, colorBrightGreen );
    PlotShapes( shapeDownArrow*BearSig, colorRed );
}
_SECTION_END();
Section-2

HTML:
function ATP(a)
{
nd=Day() != Ref(Day(), -1);

Bars = 1 + BarsSince( nd );
TodayVolume = Sum(V,Bars);
StartBar = ValueWhen(TimeNum() == 091500, BarIndex());

at=IIf (BarIndex() >= StartBar,(Sum (a * V, Bars ) /TodayVolume),0);
return at;
}
ATPo = ATP(o);
ATPh = ATP(h);
ATPl = ATP(l);
ATPc = ATP(c);
col = IIf(ATPo<ATPc,colorDarkGreen,colorTan);

PlotOHLC(ATPo,ATPh,ATPl,ATPc,"ATP candles",col,styleCandle);
 
Seniors,

Buy Sell Arrows are not coming in the following AFL
Please help me how to add Buy Sell Arrows

PriyaRamesh

_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));Graph0BarColor= IIf( C > O,colorGreen,colorRed);
Plot( C, "Close", ParamColor("Color", colorLavender ), styleBar | ParamStyle("StyleThick") | GetPriceStyle() );
if( ParamToggle("Tooltip shows", "All Values|Only Prices" ) )
{
ToolTip=StrFormat("Open: %g\nHigh: %g\nLow: %g\nClose: %g (%.1f%%)\nVolume: "+NumToStr( V, 1 ), O, H, L, C, SelectedValue( ROC( C, 1 )));
}


_SECTION_BEGIN("Ravi");
Col = IIf(C > O,colorBrightGreen,colorRed);
Plot(C,"",col,styleBar+styleThick);
_SECTION_BEGIN("Magnified Market Price");
//by mcxnsetips.com//
FS=Param("Font Size",30,11,100,1);
GfxSelectFont("Times New Roman", FS, 700, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorWhite) );
Hor=Param("Horizontal Position",990,1,1200,1);
Ver=Param("Vertical Position",12,1,830,1);
GfxTextOut(""+C, Hor , Ver );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont("Times New Roman", 11, 700, True );
GfxSetBkMode( colorBlack );
GfxSetTextColor(ParamColor("Color",colorYellow) );
GfxTextOut(""+DD+" ("+xx+"%)", Hor , Ver+45 );
_SECTION_END();


_SECTION_BEGIN(" EMA's");
EMA1 = EMA(H,34);
EMA2 = EMA(L,34);
EMA3 = EMA(C,34);

Plot( EMA1, "EMA1" ,ParamColor( "Color1", colorRed ), ParamStyle("Style", styleDashed|styleThick) | styleNoRescale );
Plot( EMA2, "EMA2" ,ParamColor( "Color2", colorGreen ), ParamStyle("Style", styleDashed|styleThick) | styleNoRescale );
Plot( EMA3, "EMA3" ,ParamColor( "Color3", colorBlue ), ParamStyle("Style", styleDashed|styleThick) | styleNoRescale );
_SECTION_END();


TimeFrameSet(inDaily);
DayHigh = LastValue(H);
DayLow = LastValue(L);
TimeFrameRestore();

Title = Date() + ", Op=" + Open + ", Hi=" + High + ", Lo=" + Low + ", LTP=" + Close + ", Change= " + SelectedValue( ROC( C, 1 ) ) + "%" + "\n Today`s High=" + DayHigh + ", Today`s Low=" + DayLow + " © " ;


prev=AMA2(C,1,0);
d=IIf(C>Ref(Max(Max(H,Ref(H,-20)),Max(Ref(H,-10),Ref(H,-15))),-1),Min(Min(L,Ref(L,-20)),Min(Ref(L,-10),Ref(L,-15))),
IIf(C<Ref(Min(Min(L,Ref(L,-20)),Min(Ref(L,-10),Ref(L,-15))),-1),Max(Max(H,Ref(H,-20)),Max(Ref(H,-10),Ref(H,-15))),PREV));
a=Cross(Close,d);
b=Cross(d,Close);
state=IIf(BarsSince(a)<BarsSince(b),1,0);
s=state>Ref(state,-1);
ss=state<Ref(state,-1);
sss=state==Ref(state,-1);
col=IIf(state == 1 ,51,IIf(state ==0,4,1));
//Plot(C,"",Col,64);
Buy = s;
Sell = ss;
///shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
///PlotShapes(shape, IIf(Buy,colorGreen,colorRed), 0, IIf(Buy,Low,High));
///PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-5);
///PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-10);
///PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-7.5);
///PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=10);
///PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=15);
//PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-12.5);
///WriteIf(s,"EXIT all Short positions\nif trading long positions, enter long Now-\nOR at the market price on tomorrow's Open with stop="+EncodeColor(4)+WriteVal(L+.75*ATR(5),1.4)+" ,","");
////WriteIf(ss,"exit all long positions today with a Market On Close (MOC) order\nOR at the market price on tomorrow's Open with stop="+EncodeColor(4)+WriteVal(Ref(H+.75*ATR(5), -1),1.4)+",","");
///WriteIf( sss ,"No trading signals today.","") ;


dist = 2*ATR(5);
dist1 = 5*ATR(5);
for( i = 0; i < BarCount; i++ )
{
if( Buy )
{
PlotText( "\nBuy:" + L[ i ] + "\nT= " + (L*1.005) + "\nSL= " + (L*0.9975), i, L[ i ]-dist, colorGreen, colorWhite );
}
if( Sell )
{
PlotText( "Sell:" + H[ i ] + "\nT= " + (H*0.995) + "\nSL= " + (H*1.0025), i, H[ i ]+dist1, colorRed, colorWhite );
}
}


Filter = s OR sss OR sss ;
AddColumn(C,"close",1.2);
AddColumn( IIf( s, 66,1 ), "buy", formatChar, 1, bkcolor =IIf (s,colorYellow, colorPink ));
AddColumn( IIf( Ss, 83,1 ), "sell", formatChar, 1, bkcolor =IIf (Ss,colorPink, colorWhite ));
AddColumn( IIf( sss, 87,1 ), "wait", formatChar, 1, bkcolor =IIf (sss,colorYellow, colorRed ));


_SECTION_BEGIN("trend");
uptrend=PDI(20)>MDI(10)AND Signal(29)<MACD(13);
downtrend=MDI(10)>PDI(20)AND Signal(29)>MACD(13);
Plot( 2, /* defines the height of the ribbon in percent of pane width */"ribbon",
IIf( uptrend, colorGreen, IIf( downtrend, colorRed, 0 )), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
_SECTION_END();

Buy = s AND a AND uptrend ;
Short = ss AND b AND downtrend ;
Sell = ss AND b AND downtrend ;
Cover = s AND a AND uptrend ;

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Cover=ExRem(Cover,Short);
Short=ExRem(Short,Cover);

Filter=Buy OR Sell;
Filter= Cover OR Short;

AddColumn( Buy, "Buy", 1);
AddColumn(Sell, "Sell", 1);
AddColumn(Close,"Close",1.2);
AddColumn(Volume,"Volume",1.0);


// Plot the Buy and Sell arrows.
//shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
//PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-10);
///PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-20);
///PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-15);
///PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=20);
//PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=30);
//PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-25);
 

vijkris

Learner and Follower
Seniors,

Buy Sell Arrows are not coming in the following AFL
Please help me how to add Buy Sell Arrows


;
hi, copy paste this, u just hav to remove"//" in last paragraph.

_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));Graph0BarColor= IIf( C > O,colorGreen,colorRed);
Plot( C, "Close", ParamColor("Color", colorLavender ), styleBar | ParamStyle("StyleThick") | GetPriceStyle() );
if( ParamToggle("Tooltip shows", "All Values|Only Prices" ) )
{
ToolTip=StrFormat("Open: %g\nHigh: %g\nLow: %g\nClose: %g (%.1f%%)\nVolume: "+NumToStr( V, 1 ), O, H, L, C, SelectedValue( ROC( C, 1 )));
}


_SECTION_BEGIN("Ravi");
Col = IIf(C > O,colorBrightGreen,colorRed);
Plot(C,"",col,styleBar+styleThick);
_SECTION_BEGIN("Magnified Market Price");
//by mcxnsetips.com//
FS=Param("Font Size",30,11,100,1);
GfxSelectFont("Times New Roman", FS, 700, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorWhite) );
Hor=Param("Horizontal Position",990,1,1200,1);
Ver=Param("Vertical Position",12,1,830,1);
GfxTextOut(""+C, Hor , Ver );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont("Times New Roman", 11, 700, True );
GfxSetBkMode( colorBlack );
GfxSetTextColor(ParamColor("Color",colorYellow) );
GfxTextOut(""+DD+" ("+xx+"%)", Hor , Ver+45 );
_SECTION_END();


_SECTION_BEGIN(" EMA's");
EMA1 = EMA(H,34);
EMA2 = EMA(L,34);
EMA3 = EMA(C,34);

Plot( EMA1, "EMA1" ,ParamColor( "Color1", colorRed ), ParamStyle("Style", styleDashed|styleThick) | styleNoRescale );
Plot( EMA2, "EMA2" ,ParamColor( "Color2", colorGreen ), ParamStyle("Style", styleDashed|styleThick) | styleNoRescale );
Plot( EMA3, "EMA3" ,ParamColor( "Color3", colorBlue ), ParamStyle("Style", styleDashed|styleThick) | styleNoRescale );
_SECTION_END();


TimeFrameSet(inDaily);
DayHigh = LastValue(H);
DayLow = LastValue(L);
TimeFrameRestore();

Title = Date() + ", Op=" + Open + ", Hi=" + High + ", Lo=" + Low + ", LTP=" + Close + ", Change= " + SelectedValue( ROC( C, 1 ) ) + "%" + "\n Today`s High=" + DayHigh + ", Today`s Low=" + DayLow + " © " ;


prev=AMA2(C,1,0);
d=IIf(C>Ref(Max(Max(H,Ref(H,-20)),Max(Ref(H,-10),Ref(H,-15))),-1),Min(Min(L,Ref(L,-20)),Min(Ref(L,-10),Ref(L,-15))),
IIf(C<Ref(Min(Min(L,Ref(L,-20)),Min(Ref(L,-10),Ref(L,-15))),-1),Max(Max(H,Ref(H,-20)),Max(Ref(H,-10),Ref(H,-15))),PREV));
a=Cross(Close,d);
b=Cross(d,Close);
state=IIf(BarsSince(a)<BarsSince(b),1,0);
s=state>Ref(state,-1);
ss=state<Ref(state,-1);
sss=state==Ref(state,-1);
col=IIf(state == 1 ,51,IIf(state ==0,4,1));
//Plot(C,"",Col,64);
Buy = s;
Sell = ss;
///shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
///PlotShapes(shape, IIf(Buy,colorGreen,colorRed), 0, IIf(Buy,Low,High));
///PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-5);
///PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-10);
///PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-7.5);
///PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=10);
///PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=15);
//PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-12.5);
///WriteIf(s,"EXIT all Short positions\nif trading long positions, enter long Now-\nOR at the market price on tomorrow's Open with stop="+EncodeColor(4)+WriteVal(L+.75*ATR(5),1.4)+" ,","");
////WriteIf(ss,"exit all long positions today with a Market On Close (MOC) order\nOR at the market price on tomorrow's Open with stop="+EncodeColor(4)+WriteVal(Ref(H+.75*ATR(5), -1),1.4)+",","");
///WriteIf( sss ,"No trading signals today.","") ;


dist = 2*ATR(5);
dist1 = 5*ATR(5);
for( i = 0; i < BarCount; i++ )
{
if( Buy )
{
PlotText( "\nBuy:" + L[ i ] + "\nT= " + (L*1.005) + "\nSL= " + (L*0.9975), i, L[ i ]-dist, colorGreen, colorWhite );
}
if( Sell )
{
PlotText( "Sell:" + H[ i ] + "\nT= " + (H*0.995) + "\nSL= " + (H*1.0025), i, H[ i ]+dist1, colorRed, colorWhite );
}
}


Filter = s OR sss OR sss ;
AddColumn(C,"close",1.2);
AddColumn( IIf( s, 66,1 ), "buy", formatChar, 1, bkcolor =IIf (s,colorYellow, colorPink ));
AddColumn( IIf( Ss, 83,1 ), "sell", formatChar, 1, bkcolor =IIf (Ss,colorPink, colorWhite ));
AddColumn( IIf( sss, 87,1 ), "wait", formatChar, 1, bkcolor =IIf (sss,colorYellow, colorRed ));


_SECTION_BEGIN("trend");
uptrend=PDI(20)>MDI(10)AND Signal(29)<MACD(13);
downtrend=MDI(10)>PDI(20)AND Signal(29)>MACD(13);
Plot( 2, /* defines the height of the ribbon in percent of pane width */"ribbon",
IIf( uptrend, colorGreen, IIf( downtrend, colorRed, 0 )), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
_SECTION_END();

Buy = s AND a AND uptrend ;
Short = ss AND b AND downtrend ;
Sell = ss AND b AND downtrend ;
Cover = s AND a AND uptrend ;

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Cover=ExRem(Cover,Short);
Short=ExRem(Short,Cover);

Filter=Buy OR Sell;
Filter= Cover OR Short;

AddColumn( Buy, "Buy", 1);
AddColumn(Sell, "Sell", 1);
AddColumn(Close,"Close",1.2);
AddColumn(Volume,"Volume",1.0);


//Plot the Buy AND Sell arrows.
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-10);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-20);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-15);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=20);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=30);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-25);
 

Similar threads