Simple Coding Help - No Promise.

yasu222

Active Member
I need afl for the below condition . =

h1 = high of 9.26 am bar (time should be variable) ;
l1 = low of 10.21 am bar (time should be variable) ;

buy = close above h1 ;
sell = close below l1 ;

please help.
 

yasu222

Active Member
Bid - ask quantity and spread afl

//Bid - Ask//
_SECTION_BEGIN("Spread Lines");
messageboard = ParamToggle("Message Board","Show|Hide",1);
if (messageboard == 1 )
{
Bid = GetRTData("Bid");
Ask = GetRTData("Ask");
GfxSelectFont( "Tahoma", 13, 100 );
GfxSetBkMode( 1 );
Plot(BID,"BID",colorLightOrange,styleDots,1) ;
Plot(ASK,"ASK",colorYellow,styleDots,1) ;
}
_SECTION_END();

_SECTION_BEGIN("Score Board");
messageboard = ParamToggle("Message Board","Show|Hide",1);
if (messageboard == 1 )
{
szBid = GetRTData("BidSize");
szAsk = GetRTData("AskSize");
Bid = GetRTData("Bid");
Ask = GetRTData("Ask");

GfxSelectFont( "Tahoma", 13, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
GfxSelectSolidBrush( colorBlue ); // this is the box background color

pxHeight = Status( "pxchartheight" ) ;
xx = Status( "pxchartwidth");

x = 1000;
x2 =1090;

y = pxHeight-400;

GfxTextOut( ( "Bid Qty"),x-53,y-100);
GfxTextOut( (" "),x+13,y-100);
GfxTextOut( (""+szBid), x-20, y-80) ; // The text format location

GfxTextOut( ( "Ask Qty"),x+63+92,y-100);
GfxTextOut( (" "),x+13+92,y-100);
GfxTextOut( (""+szAsk), x+93+92, y-80) ; // The text format location

GfxTextOut( ( "Bid"),x+13,y-100);
GfxTextOut( (" "),x+27,y-100);
GfxTextOut( (""+Bid), x+13, y-80) ; // The text format location

GfxTextOut( ( "Ask"),x+13+92,y-100);
GfxTextOut( (" "),x+27+92,y-100);
GfxTextOut( (""+Ask), x+13+92, y-80) ; // The text format location

}
_SECTION_END();
 
Last edited:

cloudTrader

Well-Known Member
I want to compare Yesterday Close Of a Scrip with the Yesterday Close Of Another Scrip.

For Eg. Compare Yesterday Close Of SBIN to Yesterday Close Of PNB.

I am able to get the Yesterday Close Of the first security [SBIN] but unable to get the Yesterday Close of Foreign security [PNB].

Not a technical guy so kept on reading lot of Amibroker help but couldn't get through the coding of this condition.

Kindly give the code line.

Thanks in advance.
 
I want to compare Yesterday Close Of a Scrip with the Yesterday Close Of Another Scrip.

For Eg. Compare Yesterday Close Of SBIN to Yesterday Close Of PNB.

I am able to get the Yesterday Close Of the first security [SBIN] but unable to get the Yesterday Close of Foreign security [PNB].

Not a technical guy so kept on reading lot of Amibroker help but couldn't get through the coding of this condition.

Kindly give the code line.

Thanks in advance.

On a SBIN Chart

Code:
pnbClose = Foreign( "PNB", "Close", 1);
will give you close price of pnb. Ref(pnbClose, -1) will get you to previous day price.
 

yasu222

Active Member
EMARSICCI-system

_SECTION_BEGIN("EMARSICCI");

trailstop=0; strailstop=0;
trailARRAY=Null; strailARRAY=Null;
refL1=0; refL2=0; refH1=0; refH2=0;

perc = Param("% Stop",0.295,0.0001,100,0.0001);

A1 = Optimize("A1",3,1,10,1);
A2 = Optimize("A2",13,5,30,1);

z1 = Ref(L,-1)<Ref(L,0) AND Ref(L,-1)<Ref(L,-2);
z2 = Ref(L,-1);
z3 = Ref(H,-1)>Ref(H,0) AND Ref(H,-1)>Ref(H,-2);
z4 = Ref(H,-1);

refL1 = LLV(L,5) * ((100-perc)/100); //static SL.
refL2 = IIf(z1, z2, 0); //trailing SL
refH1 = HHV(H,5)* ((100+perc)/100);//static SL.
refH2 = IIf(z3, z4, 0); //trailing SL

crossEMA1 = Cross(C,EMA(C,A2));
crossRSI1 = Cross(RSI(13),50);
cross2EMA1 = Cross(CCI(13),0);
crossEMA2 = Cross(EMA(C,A2),C);
crossRSI2 = Cross(50,RSI(13));
cross2EMA2 = Cross(0,CCI(13));

Buy = crossEMA1 AND crossRSI1 AND cross2EMA1;
Sell = 0;

Short = crossEMA2 AND crossRSI2 AND cross2EMA2;
Cover = 0;

for(i=0; i<BarCount; i++)

{
/*fh = fopen( "D:/myfile.txt", "a");
if( fh )
{
fputs("i"+i+"__t"+trailstop+"___"+Buy+"__P"+C+"\n", fh );
fclose( fh );
}*/
//_TRACE("i"+i+"__t"+trailstop+"___"+Buy+"__P"+C);
if( trailstop == 0 AND Buy[ i ] )
{
BuyPrice = O;
trailstop= refL1;

//BuyToFuse(BuyPrice,0);
}

else Buy[ i ] = 0; // remove excess buy signals

if( strailstop == 0 AND Short[ i ] )
{
ShortPrice = O;
strailstop= refH1;

/*if(i == (BarCount-2))
{
ShortToFuse(ShortPrice,0);
}*/
}

else Short[ i ] = 0; // remove excess short signals

if( trailstop > 0 )
{
trailstop= Max( refL2[ i ] * ((100-perc)/100), trailstop);
trailARRAY[ i ] = trailstop;
}

if( strailstop > 0 )
{
if(refH2 == 0) {y = strailstop;} else y = refH2;
strailstop= Min( y * ((100+perc)/100), strailstop);
strailARRAY[ i ] = strailstop;
}

if( trailstop > 0 AND Low[ i ] < trailstop )
{
Sell[ i ] = 1;
SellPrice[ i ] = trailstop;
trailstop=0;

/*if(i==(BarCount -2))
{
SellToFuse(SellPrice[ i ],0);
}*/
}

if( strailstop > 0 AND High[ i ] > strailstop )

{
Cover[ i ] = 1;
CoverPrice[ i ] = strailstop;
strailstop=0;


/*if(i==(BarCount -2))
{
CoverToFuse(CoverPrice[ i ],0);
}*/
}

if( trailstop > 0 AND Short)
{
Sell[ i ] = 1;
SellPrice[ i ] = O;
trailstop=0;


/*if(i==(BarCount -2))
{
SellToFuse(SellPrice[ i ],0);
}*/
}

if( strailstop > 0 AND Buy )

{
Cover[ i ] = 1;
CoverPrice[ i ] = O;
strailstop=0;

/*if(i==(BarCount -2))
{
CoverToFuse(CoverPrice[ i ],0);
}*/
}

}


/*fh = fopen( "D:/myfile.txt", "a");
if( fh )
{
fputs("EndFor\n", fh );
fclose( fh );
} */


Plot( Close,"Price",colorBlack,styleCandle);
Plot( trailARRAY,"Buy Stoploss", colorRed, shapeStar );
Plot( strailARRAY,"Short Stoploss", colorBlue, shapeStar );

PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorBlue, 0,L, Offset=-45);


PlotShapes(IIf(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorBlack, 0,H, Offset=-45);

PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-20);
PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorLime, 0,L, Offset=-30);
PlotShapes(IIf(Cover, shapeUpArrow, shapeNone),colorBlack, 0,L, Offset=-25);

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),colorBlue, 0,H, Offset=-25);


_SECTION_END();
RequestTimedRefresh( 1,onlyvisible=False );
_SECTION_BEGIN("EMARSICCI-1");

a5=(Sell);
a4=(Cover);
a1=(Buy);
a2=(Short);
a3= Ref(C,-1);
a7=Ref(L,-1);
a6= 0;


tb= Nz(trailArray, -1);
ts= Nz(strailArray, -1);



_SECTION_END();

ClientID = ParamStr("ClientId","000000");
Symbol= ParamStr("Symbol","NIFTY13APRFUT");
Price=NumToStr(C,8.3,True);
Quantity=Param("Quantity",1,1,100,1);
OE = ParamList("Order Execution","Immediate,On Candle Completion",1);
AT = ParamToggle("AutoTrade","No,Yes");

if(OE=="On Candle Completion")
{
Buy=Ref(Buy,-1);
Short=Ref(Short,-1);
Sell=Ref(Sell,-1);
Cover=Ref(Cover,-1);
}

AplliedQuantity=IIf(LastValue(Buy) AND LastValue(Cover) OR LastValue(Short) AND LastValue(Sell),Quantity*2,Quantity);
RefNumber = Nz(StaticVarGet("RefNumber"));
Checkdt=Nz(StaticVarGet("lastdt"));
dt = LastValue( DateTime() );
Cond=LastValue(Buy) OR LastValue(Short) OR LastValue(Sell) OR LastValue(Cover);

if(AT)
{
plus = CreateStaticObject("Nest.PlusApi");
if(plus)
{
plus.SetObjectName(ClientID);
if(Cond AND Checkdt != dt )
{
if(LastValue(Buy) OR LastValue(Cover)){plus.PlaceOrder("BUY",RefNumber,"NFO",Symbol,"DAY","LIMIT",AplliedQuantity,Price,0,1,"NRML",ClientID);}
if(LastValue(Short) OR LastValue(Sell)){plus.PlaceOrder("SELL",RefNumber,"NFO",Symbol,"DAY","LIMIT",AplliedQuantity,Price,0,1,"NRML",ClientID);}
StaticVarSet("RefNumber",RefNumber+1);
StaticVarSet("lastdt",dt );
}
}
}
 
also can i know to make the following strings in AFL

mygroup1
mygroup2
mygroup3
mygroup4
mygroup5

and so on the only restrictions in the string are not having commas and not being repeated thorough the day

want to use them as parameters for OrderID in OCA
 
Last edited:
Please give afl code of dashed lines with different colors for different times frames for 60min pvt, 30min pvt and 15min pvt separate dashed lines when applied on 5min charts.
anjanbm
 

Similar threads