Amibroker with IB

#72
i dont have the data for 6 months to back test this afl

can someone provide me the data for sixmonths for testing

i think one minute data would be great. or dell would it require tick data testing ?
 

ocil

Well-Known Member
#73
Hi Bait you need the bank nifty and nifty 1m data? i have 1 year data. can you advice me what AFL you want to test i will post the result.
 

dell

Well-Known Member
#74
i dont have the data for 6 months to back test this afl

can someone provide me the data for sixmonths for testing

i think one minute data would be great. or dell would it require tick data testing ?
imo , u should test it on prior 4-5 yrs atleast , for a better understanding of ur sys , as in 4-5 yrs nearly all type of market condition occurs , so it is a test for our system that how he behaves in all condition's .

regarding tf , it is ur choice that where u want to trade , if u trade 15m tf than u have to test on it and tweak system according to tf .
tick data is of no use if u are testing on tf higher than 1m .tick data is for hft and scalpers only .

i have nearly 5 yrs data , all fno gfdl pure data ,mcx data , cash data ( all data are pure and of 1m time stamp ). if u have any robust one and need to backtest on it , u can send me through p.m. or here , i will test and publish report here and also if i have some tweaks than also will share with u .
 
#75
this is the afl to test

this code is not supertrend + helenski ashi
supertrend for entry
Heikin-Ashi for exit

afl proposed by bunti_k23

i just made it autotrading for Interactive Brokers so that it will run without any human input

to see this file in action you have to set autotrade = yes in the parameters

the time frame for trading is one min, three min and 5 min.

Code:
_SECTION_BEGIN("SuperTrend");
SetBarsRequired(100000,0);
GraphXSpace = 15;
SetChartOptions(0,chartShowArrows|chartShowDates);

/*
Heikin-Ashi(Koma-Ashi) with Moving Average Type
*/
SetChartOptions(2, chartWrapTitle);

// Calculate Moving Average
MAPeriod = Param("MA Period", 15, 1, 100);
MAOpen = EMA(Open, MAPeriod);
MAHigh = EMA(High, MAPeriod);
MALow = EMA(Low, MAPeriod);
MAClose = EMA(Close, MAPeriod);

HaClose = (MAOpen + MAHigh + MALow + MAClose) / 4;
HaOpen = AMA(Ref(HaClose, -1), 0.5);

// for graph collapse
for(i = 0; i <= MAPeriod; i++) HaClose[i] = Null;
/*
// same
// HaOpen = (Ref(HaOpen, -1) + Ref(HaClose, -1)) / 2;
HaOpen[ 0 ] = HaClose[ 0 ];
for(i = 1; i < BarCount; i++) {
HaOpen[i] = (HaOpen[i - 1] + HaClose[i - 1]) / 2;
}
*/

HaHigh = Max(MAHigh, Max(HaClose, HaOpen));
HaLow = Min(MALow, Min(HaClose, HaOpen));

// outs comments
"BarIndex = " + BarIndex();
"Open = " + Open;
"High = " + High;
"Low = " + Low;
"Close = "+ Close;
"HaOpen = " + HaOpen;
"HaHigh = " + HaHigh;
"HaLow = " + HaLow;
"HaClose = "+ HaClose;

// Plot graphs
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} HaOpen %g, HaHigh %g,
HaLow %g, HaClose %g (%.1f%%) {{VALUES}}",
HaOpen, HaHigh, HaLow, HaClose, SelectedValue(ROC( HaClose, 1))));
PlotOHLC(HaOpen, HaHigh, HaLow, HaClose, _DEFAULT_NAME(), ParamColor("Color",
colorBlack), styleCandle);

_SECTION_BEGIN("Colour Tap");
SetChartBkGradientFill( ParamColor("BgTop", ColorRGB( 172,172,172 )),

ParamColor("BgBottom", ColorRGB( 172,172,172 )),ParamColor("titleblock",ColorRGB( 172,172,172 )));
_SECTION_END();

_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

PositionSize = 350000;

TrendMode = ParamToggle("TrendMode","Off|On",1);
Factor=Optimize("Factor",4,0.1,10,0.1);
Pd=Optimize("ATR Periods",5,1,20,1);
Up=(H+L)/2+(Factor*ATR(Pd));
Dn=(H+L)/2-(Factor*ATR(Pd));
iATR=ATR(Pd);
TrendUp=TrendDown=Null;
trend[0]=1;
changeOfTrend=0;
flag=flagh=0;

for (i = 1; i <BarCount; i++) {
TrendUp[i] = Null;
TrendDown[i] = Null;

trend[i]=1;


if (Close[i]>Up[i-1]) {
trend[i]=1;
if (trend[i-1] == -1) changeOfTrend = 1;

}
else if (Close[i]<Dn[i-1]) {
trend[i]=-1;
if (trend[i-1] == 1) changeOfTrend = 1;
}
else if (trend[i-1]==1) {
trend[i]=1;
changeOfTrend = 0;
}
else if (trend[i-1]==-1) {
trend[i]=-1;
changeOfTrend = 0;
}

if (trend[i]<0 && trend[i-1]>0) {
flag=1;
}
else {
flag=0;
}

if (trend[i]>0 && trend[i-1]<0) {
flagh=1;
}
else {
flagh=0;
}

if (trend[i]>0 && Dn[i]<Dn[i-1]){
Dn[i]=Dn[i-1];
}

if (trend[i]<0 && Up[i]>Up[i-1])
{ Up[i]=Up[i-1];
}

if (flag==1)
{ Up[i]=(H[i]+L[i])/2+(Factor*iATR[i]);;
}
if (flagh==1)
{ Dn[i]=(H[i]+L[i])/2-(Factor*iATR[i]);;
}
if (trend[i]==1) {
TrendUp[i]=Dn[i];
if (changeOfTrend == 1) {
TrendUp[i-1] = TrendDown[i-1];
changeOfTrend = 0;
}
}
else if (trend[i]==-1) {
TrendDown[i]=Up[i];
if (changeOfTrend == 1) {
TrendDown[i-1] = TrendUp[i-1];
changeOfTrend = 0;
}
}
}

Plot(TrendUp,"Trend",colorBlue);
Plot(TrendDown,"Down",colorRed);


/*================================================= ================================================== ================================================== ===================*/
/*================================================= ================================================== ================================================== ===================*/
/*================================================= ================================================== ================================================== ===================*/

TrendMode = ParamToggle("TrendMode","Off|On",1);
Factor1=Optimize("Factor1",2,5,10,2);
Pd1=Optimize("ATR Periods1",5,1,10,1);
Up1=(H+L)/2+(Factor1*ATR(Pd1));
Dn1=(H+L)/2-(Factor1*ATR(Pd1));
iATR1=ATR(Pd1);
TrendUp1=TrendDown1=Null;
trend1[0]=1;
changeOfTrend1=0;
flag1=flagh1=0;

for (i = 1; i <BarCount; i++) {
TrendUp1[i] = Null;
TrendDown1[i] = Null;

trend1[i]=1;


if (Close[i]>Up1[i-1]) {
trend1[i]=1;
if (trend1[i-1] == -1) changeOfTrend1 = 1;

}
else if (Close[i]<Dn1[i-1]) {
trend1[i]=-1;
if (trend1[i-1] == 1) changeOfTrend1 = 1;
}
else if (trend1[i-1]==1) {
trend1[i]=1;
changeOfTrend1 = 0;
}
else if (trend1[i-1]==-1) {
trend1[i]=-1;
changeOfTrend1 = 0;
}

if (trend1[i]<0 && trend1[i-1]>0) {
flag1=1;
}
else {
flag1=0;
}

if (trend1[i]>0 && trend1[i-1]<0) {
flagh1=1;
}
else {
flagh1=0;
}

if (trend1[i]>0 && Dn1[i]<Dn1[i-1]){
Dn1[i]=Dn1[i-1];
}

if (trend1[i]<0 && Up1[i]>Up1[i-1])
{ Up1[i]=Up1[i-1];
}

if (flag1==1)
{ Up1[i]=(H[i]+L[i])/2+(Factor1*iATR1[i]);;
}
if (flagh1==1)
{ Dn1[i]=(H[i]+L[i])/2-(Factor1*iATR1[i]);;
}
if (trend1[i]==1) {
TrendUp1[i]=Dn1[i];
if (changeOfTrend1 == 1) {
TrendUp1[i-1] = TrendDown1[i-1];
changeOfTrend1 = 0;
}
}
else if (trend1[i]==-1) {
TrendDown1[i]=Up1[i];
if (changeOfTrend1 == 1) {
TrendDown1[i-1] = TrendUp1[i-1];
changeOfTrend1 = 0;
}
}
}

Plot(TrendUp1,"Trend",colorWhite);
Plot(TrendDown1,"Down",colorWhite);


/*================================================= ================================================== ================================================== ===================*/
/*================================================= ================================================== ================================================== ===================*/
/*================================================= ================================================== ================================================== ===================*/

Buy = trend==1 AND trend1==1 ;
Short=trend==-1 AND trend1==-1;
Sell=trend1==-1;
Cover=trend1==1;

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



BuyPrice=ValueWhen(Buy,C);
SellPrice=ValueWhen(Sell,C);
ShortPrice=ValueWhen(Short,C);
CoverPrice=ValueWhen(Cover,C);














RequestTimedRefresh( 1 ); 
ibc = GetTradingInterface("IB"); 
Reset = ParamTrigger("Reset All","RESET"); 
//Price=NumToStr(C,8.3,True);
AT = ParamToggle("AutoTrade","No,Yes");
Quantity=50;
LastTrade = StaticVarGetText("LastTrade"); 
AplliedQuantity=IIf(LastTrade == "",Quantity,Quantity);
RefNumber = Nz(StaticVarGet("RefNumber"));
Checkdt=Nz(StaticVarGet("lastdt"));
dt = LastValue( DateTime() );
Cond=LastValue(Buy) OR LastValue(Sell) OR LastValue(Short) OR LastValue(Cover);



if(AT)
{

if(Cond AND Checkdt != dt )
{

if(LastValue(Buy))
{
if( LastTrade != "Buy" OR LastTrade == "" )
{
ibc.PlaceOrder( Name(), "BUY", AplliedQuantity, "MKT", 0, 0, "Day", True);  
StaticVarSetText("LastTrade", "Buy");
}
}

if(LastValue(Sell))
{
if( LastTrade != "Sell" OR LastTrade == "" )
{
ibc.PlaceOrder( Name(), "SELL", AplliedQuantity, "MKT", 0, 0, "Day", True);   
StaticVarSetText("LastTrade", "Sell");
}
}


if(LastValue(Cover))
{
if( LastTrade != "Cover" OR LastTrade == "" )
{
ibc.PlaceOrder( Name(), "BUY", AplliedQuantity, "MKT", 0, 0, "Day", True);  
StaticVarSetText("LastTrade", "Cover");
}
}

if(LastValue(Short))
{
if( LastTrade != "Short" OR LastTrade == "" )
{
ibc.PlaceOrder( Name(), "SELL", AplliedQuantity, "MKT", 0, 0, "Day", True);   
StaticVarSetText("LastTrade", "Short");
}
}




StaticVarSet("RefNumber",RefNumber+1);
StaticVarSet("lastdt",dt );

}
 
if( Reset ) 
{ 
ibc.CloseAllOpenPositions(); 
ibc.cancelallpendingorders();
StaticVarSetText("LastTrade", "");
} 


}














Title = EncodeColor(colorWhite)+ "Super Trend AFL code from www.marketcalls.in" + " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
" - " + Date() +" - "+"\n" +EncodeColor(colorRed) +"Op-"+O+" "+"Hi-"+H+" "+"Lo-"+L+" "+
"Cl-"+C+" "+ "Vol= "+ WriteVal(V)+"\n"+
EncodeColor(colorLime)+
WriteIf (Buy , " GO LONG / Reverse Signal at "+C+" ","")+
WriteIf (Sell , " EXIT LONG / Reverse Signal at "+C+" ","")+"\n"+EncodeColor(colorYellow)+
WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+
WriteIf(Buy , "Total Profit/Loss for the Last trade Rs."+(SellPrice-C)+"","");

PlotShapes(IIf(Buy==1, shapeUpArrow , shapeNone), colorGreen, 0,Low, Offset=-50);
PlotShapes(IIf(Sell==1, shapeStar, shapeNone), colorRed, 0,High, Offset=30);
PlotShapes(IIf(Short==1, shapeDownArrow, shapeNone), colorRed, 0,High, Offset=-50);
PlotShapes(IIf(Cover==1, shapeStar, shapeNone), colorGreen, 0,Low, Offset=-30);


_SECTION_END();



P = ParamField("Price field",-1);
Periods = Param("Periods", 9, 2, 300, 1, 10 );
Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );

_SECTION_BEGIN("supp");
("Price");
RSIperiod = 15; // Param("RSI p",3,14,30,1);
Percent = 5; // Param("ZIG %",8,9,15,1);
EMAperiod = 5; //Param("EMA p",4,5,10,1);
HHVperiod = 8; //Param("HHV p",3,5,10,1);
NumLine = 2; //Param("Num Lines",3,1,20,1);

Base = DEMA(RSI(RSIperiod),EMAperiod);

GraphXSpace=0.5;


for( i = 1; i <= numline; i++ )
{
ResBase = LastValue(Peak(Base,Percent,i));
SupBase = LastValue(Trough(Base,Percent,i));
Plot(ValueWhen( ResBase==Base, HHV(H,HHVperiod) ), "Resist Level", colorRed, styleLine);
Plot(ValueWhen( supbase==Base, LLV(L,HHVperiod) ), "Support Level", colorGreen, styleLine);
}

_SECTION_END();
 
Last edited:
#76
this is the afl to test

this code is not supertrend + helenski ashi
supertrend for entry
Heikin-Ashi for exit

afl proposed by bunti_k23

i just made it autotrading for Interactive Brokers so that it will run without any human input

to see this file in action you have to set autotrade = yes in the parameters

the time frame for trading is one min, three min and 5 min.

Code:
_SECTION_BEGIN("SuperTrend");
SetBarsRequired(100000,0);
GraphXSpace = 15;
SetChartOptions(0,chartShowArrows|chartShowDates);

/*
Heikin-Ashi(Koma-Ashi) with Moving Average Type
*/
SetChartOptions(2, chartWrapTitle);

// Calculate Moving Average
MAPeriod = Param("MA Period", 15, 1, 100);
MAOpen = EMA(Open, MAPeriod);
MAHigh = EMA(High, MAPeriod);
MALow = EMA(Low, MAPeriod);
MAClose = EMA(Close, MAPeriod);

HaClose = (MAOpen + MAHigh + MALow + MAClose) / 4;
HaOpen = AMA(Ref(HaClose, -1), 0.5);

// for graph collapse
for(i = 0; i <= MAPeriod; i++) HaClose[i] = Null;
/*
// same
// HaOpen = (Ref(HaOpen, -1) + Ref(HaClose, -1)) / 2;
HaOpen[ 0 ] = HaClose[ 0 ];
for(i = 1; i < BarCount; i++) {
HaOpen[i] = (HaOpen[i - 1] + HaClose[i - 1]) / 2;
}
*/

HaHigh = Max(MAHigh, Max(HaClose, HaOpen));
HaLow = Min(MALow, Min(HaClose, HaOpen));

// outs comments
"BarIndex = " + BarIndex();
"Open = " + Open;
"High = " + High;
"Low = " + Low;
"Close = "+ Close;
"HaOpen = " + HaOpen;
"HaHigh = " + HaHigh;
"HaLow = " + HaLow;
"HaClose = "+ HaClose;

// Plot graphs
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} HaOpen %g, HaHigh %g,
HaLow %g, HaClose %g (%.1f%%) {{VALUES}}",
HaOpen, HaHigh, HaLow, HaClose, SelectedValue(ROC( HaClose, 1))));
PlotOHLC(HaOpen, HaHigh, HaLow, HaClose, _DEFAULT_NAME(), ParamColor("Color",
colorBlack), styleCandle);

_SECTION_BEGIN("Colour Tap");
SetChartBkGradientFill( ParamColor("BgTop", ColorRGB( 172,172,172 )),

ParamColor("BgBottom", ColorRGB( 172,172,172 )),ParamColor("titleblock",ColorRGB( 172,172,172 )));
_SECTION_END();

_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

PositionSize = 350000;

TrendMode = ParamToggle("TrendMode","Off|On",1);
Factor=Optimize("Factor",4,0.1,10,0.1);
Pd=Optimize("ATR Periods",5,1,20,1);
Up=(H+L)/2+(Factor*ATR(Pd));
Dn=(H+L)/2-(Factor*ATR(Pd));
iATR=ATR(Pd);
TrendUp=TrendDown=Null;
trend[0]=1;
changeOfTrend=0;
flag=flagh=0;

for (i = 1; i <BarCount; i++) {
TrendUp[i] = Null;
TrendDown[i] = Null;

trend[i]=1;


if (Close[i]>Up[i-1]) {
trend[i]=1;
if (trend[i-1] == -1) changeOfTrend = 1;

}
else if (Close[i]<Dn[i-1]) {
trend[i]=-1;
if (trend[i-1] == 1) changeOfTrend = 1;
}
else if (trend[i-1]==1) {
trend[i]=1;
changeOfTrend = 0;
}
else if (trend[i-1]==-1) {
trend[i]=-1;
changeOfTrend = 0;
}

if (trend[i]<0 && trend[i-1]>0) {
flag=1;
}
else {
flag=0;
}

if (trend[i]>0 && trend[i-1]<0) {
flagh=1;
}
else {
flagh=0;
}

if (trend[i]>0 && Dn[i]<Dn[i-1]){
Dn[i]=Dn[i-1];
}

if (trend[i]<0 && Up[i]>Up[i-1])
{ Up[i]=Up[i-1];
}

if (flag==1)
{ Up[i]=(H[i]+L[i])/2+(Factor*iATR[i]);;
}
if (flagh==1)
{ Dn[i]=(H[i]+L[i])/2-(Factor*iATR[i]);;
}
if (trend[i]==1) {
TrendUp[i]=Dn[i];
if (changeOfTrend == 1) {
TrendUp[i-1] = TrendDown[i-1];
changeOfTrend = 0;
}
}
else if (trend[i]==-1) {
TrendDown[i]=Up[i];
if (changeOfTrend == 1) {
TrendDown[i-1] = TrendUp[i-1];
changeOfTrend = 0;
}
}
}

Plot(TrendUp,"Trend",colorBlue);
Plot(TrendDown,"Down",colorRed);


/*================================================= ================================================== ================================================== ===================*/
/*================================================= ================================================== ================================================== ===================*/
/*================================================= ================================================== ================================================== ===================*/

TrendMode = ParamToggle("TrendMode","Off|On",1);
Factor1=Optimize("Factor1",2,5,10,2);
Pd1=Optimize("ATR Periods1",5,1,10,1);
Up1=(H+L)/2+(Factor1*ATR(Pd1));
Dn1=(H+L)/2-(Factor1*ATR(Pd1));
iATR1=ATR(Pd1);
TrendUp1=TrendDown1=Null;
trend1[0]=1;
changeOfTrend1=0;
flag1=flagh1=0;

for (i = 1; i <BarCount; i++) {
TrendUp1[i] = Null;
TrendDown1[i] = Null;

trend1[i]=1;


if (Close[i]>Up1[i-1]) {
trend1[i]=1;
if (trend1[i-1] == -1) changeOfTrend1 = 1;

}
else if (Close[i]<Dn1[i-1]) {
trend1[i]=-1;
if (trend1[i-1] == 1) changeOfTrend1 = 1;
}
else if (trend1[i-1]==1) {
trend1[i]=1;
changeOfTrend1 = 0;
}
else if (trend1[i-1]==-1) {
trend1[i]=-1;
changeOfTrend1 = 0;
}

if (trend1[i]<0 && trend1[i-1]>0) {
flag1=1;
}
else {
flag1=0;
}

if (trend1[i]>0 && trend1[i-1]<0) {
flagh1=1;
}
else {
flagh1=0;
}

if (trend1[i]>0 && Dn1[i]<Dn1[i-1]){
Dn1[i]=Dn1[i-1];
}

if (trend1[i]<0 && Up1[i]>Up1[i-1])
{ Up1[i]=Up1[i-1];
}

if (flag1==1)
{ Up1[i]=(H[i]+L[i])/2+(Factor1*iATR1[i]);;
}
if (flagh1==1)
{ Dn1[i]=(H[i]+L[i])/2-(Factor1*iATR1[i]);;
}
if (trend1[i]==1) {
TrendUp1[i]=Dn1[i];
if (changeOfTrend1 == 1) {
TrendUp1[i-1] = TrendDown1[i-1];
changeOfTrend1 = 0;
}
}
else if (trend1[i]==-1) {
TrendDown1[i]=Up1[i];
if (changeOfTrend1 == 1) {
TrendDown1[i-1] = TrendUp1[i-1];
changeOfTrend1 = 0;
}
}
}

Plot(TrendUp1,"Trend",colorWhite);
Plot(TrendDown1,"Down",colorWhite);


/*================================================= ================================================== ================================================== ===================*/
/*================================================= ================================================== ================================================== ===================*/
/*================================================= ================================================== ================================================== ===================*/

Buy = trend==1 AND trend1==1 ;
Short=trend==-1 AND trend1==-1;
Sell=trend1==-1;
Cover=trend1==1;

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



BuyPrice=ValueWhen(Buy,C);
SellPrice=ValueWhen(Sell,C);
ShortPrice=ValueWhen(Short,C);
CoverPrice=ValueWhen(Cover,C);














RequestTimedRefresh( 1 ); 
ibc = GetTradingInterface("IB"); 
Reset = ParamTrigger("Reset All","RESET"); 
//Price=NumToStr(C,8.3,True);
AT = ParamToggle("AutoTrade","No,Yes");
Quantity=50;
LastTrade = StaticVarGetText("LastTrade"); 
AplliedQuantity=IIf(LastTrade == "",Quantity,Quantity);
RefNumber = Nz(StaticVarGet("RefNumber"));
Checkdt=Nz(StaticVarGet("lastdt"));
dt = LastValue( DateTime() );
Cond=LastValue(Buy) OR LastValue(Sell) OR LastValue(Short) OR LastValue(Cover);



if(AT)
{

if(Cond AND Checkdt != dt )
{

if(LastValue(Buy))
{
if( LastTrade != "Buy" OR LastTrade == "" )
{
ibc.PlaceOrder( Name(), "BUY", AplliedQuantity, "MKT", 0, 0, "Day", True);  
StaticVarSetText("LastTrade", "Buy");
}
}

if(LastValue(Sell))
{
if( LastTrade != "Sell" OR LastTrade == "" )
{
ibc.PlaceOrder( Name(), "SELL", AplliedQuantity, "MKT", 0, 0, "Day", True);   
StaticVarSetText("LastTrade", "Sell");
}
}


if(LastValue(Cover))
{
if( LastTrade != "Cover" OR LastTrade == "" )
{
ibc.PlaceOrder( Name(), "BUY", AplliedQuantity, "MKT", 0, 0, "Day", True);  
StaticVarSetText("LastTrade", "Cover");
}
}

if(LastValue(Short))
{
if( LastTrade != "Short" OR LastTrade == "" )
{
ibc.PlaceOrder( Name(), "SELL", AplliedQuantity, "MKT", 0, 0, "Day", True);   
StaticVarSetText("LastTrade", "Short");
}
}




StaticVarSet("RefNumber",RefNumber+1);
StaticVarSet("lastdt",dt );

}
 
if( Reset ) 
{ 
ibc.CloseAllOpenPositions(); 
ibc.cancelallpendingorders();
StaticVarSetText("LastTrade", "");
} 


}














Title = EncodeColor(colorWhite)+ "Super Trend AFL code from www.marketcalls.in" + " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
" - " + Date() +" - "+"\n" +EncodeColor(colorRed) +"Op-"+O+" "+"Hi-"+H+" "+"Lo-"+L+" "+
"Cl-"+C+" "+ "Vol= "+ WriteVal(V)+"\n"+
EncodeColor(colorLime)+
WriteIf (Buy , " GO LONG / Reverse Signal at "+C+" ","")+
WriteIf (Sell , " EXIT LONG / Reverse Signal at "+C+" ","")+"\n"+EncodeColor(colorYellow)+
WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+
WriteIf(Buy , "Total Profit/Loss for the Last trade Rs."+(SellPrice-C)+"","");

PlotShapes(IIf(Buy==1, shapeUpArrow , shapeNone), colorGreen, 0,Low, Offset=-50);
PlotShapes(IIf(Sell==1, shapeStar, shapeNone), colorRed, 0,High, Offset=30);
PlotShapes(IIf(Short==1, shapeDownArrow, shapeNone), colorRed, 0,High, Offset=-50);
PlotShapes(IIf(Cover==1, shapeStar, shapeNone), colorGreen, 0,Low, Offset=-30);


_SECTION_END();



P = ParamField("Price field",-1);
Periods = Param("Periods", 9, 2, 300, 1, 10 );
Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );

_SECTION_BEGIN("supp");
("Price");
RSIperiod = 15; // Param("RSI p",3,14,30,1);
Percent = 5; // Param("ZIG %",8,9,15,1);
EMAperiod = 5; //Param("EMA p",4,5,10,1);
HHVperiod = 8; //Param("HHV p",3,5,10,1);
NumLine = 2; //Param("Num Lines",3,1,20,1);

Base = DEMA(RSI(RSIperiod),EMAperiod);

GraphXSpace=0.5;


for( i = 1; i <= numline; i++ )
{
ResBase = LastValue(Peak(Base,Percent,i));
SupBase = LastValue(Trough(Base,Percent,i));
Plot(ValueWhen( ResBase==Base, HHV(H,HHVperiod) ), "Resist Level", colorRed, styleLine);
Plot(ValueWhen( supbase==Base, LLV(L,HHVperiod) ), "Support Level", colorGreen, styleLine);
}

_SECTION_END();
Hi bait, the parameters are in amibroker or IB to set? thanks
 

Similar threads