Journy to algo trading

c.trader

Active Member
#1
Hi
In this forum i really impressed by mechtrader and other seniors for algo trading
from today i discuss what i am doing/search to start algo trading
please help if i am going wrong
1)ALGO TRADING PLATFORMS
i)Symphony pesto
ii)MT
iii)ROBOTRADER ETC
2)BROKER
i)COMPOSITEDGE
ii)MASTERTRUST
iii)OTHER DISCOUNT BROKERS
3)VPS
i) webappzlive
4)ASSET
i)EQUITY
ii)FUTURE
iii)COMMODITY
5)INITIAL CAPITAL
i)1lk
ii)2lk
iii)5lk
6)STRATEGY SELECTION
i)AR TRADING SYSTEM
ii)SUPERTREND 4
7)ENTRY EXIT RULES
i)AS BUY /SELL SIGNAL TO SIGNAL
ii)AS BUY /SELL PROFIT 1% STOPLOSS 0.5%
ii)AS BUY/SELL PROFIT TRAILING SL
lets start
each and every point discus in detail
 
Last edited:

pkgmtnl

Well-Known Member
#2
Hi
In this forum i really impressed by mechtrader and other seniors for algo trading
from today i discuss what i am doing/search to start algo trading
please help if i am going wrong
1)ALGO TRADING PLATFORMS
i)Symphony pesto
ii)MT
iii)ROBOTRADER ETC
2)BROKER
i)COMPOSITEDGE
ii)MASTERTRUST
iii)OTHER DISCOUNT BROKERS
3)VPS
i) webappzlive
4)ASSET
i)EQUITY
ii)FUTURE
iii)COMMODITY
5)INITIAL CAPITAL
i)1lk
ii)2lk
iii)5lk
6)STRATEGY SELECTION
i)AR TRADING SYSTEM
ii)SUPERTREND 4
7)ENTRY EXIT RULES
i)AS BUY /SELL SIGNAL TO SIGNAL
ii)AS BUY /SELL PROFIT 1% STOPLOSS 0.5%
ii)AS BUY/SELL PROFIT TRAILING SL
lets start
each and every point discus in detail
1)ALGO TRADING PLATFORMS can also be:
a) RCRT.COM;
b) vBiz;
c) AUTOTRADING.IN;
d) FINMAS.IN;
PLZ SUGGEST MORE TO USERS.
 

c.trader

Active Member
#3
1)ALGO TRADING PLATFORMS can also be:
a) RCRT.COM;
b) vBiz;
c) AUTOTRADING.IN;
d) FINMAS.IN;
PLZ SUGGEST MORE TO USERS.
AS per my openion and some suggestions from autotrader .algo trading software
1)symphony-1)discount with it 10000 rs for 6 months
2)having setting to face any type of condition in market
3)trailling stoploss,fixed stoploss and profit
4)smart order execution strategy
5)work well on vps
6)multiple setting options
7)setting for sudden spike in market
8)data from gdfl good and reliable
9)by opening account with its joint broker compositedge
40%discont on gdfl data
2)mt3 1)inbuilt data
2)ambibroker+mt3 only for trading
3)1000rs per month with data for all segment
4)max profit max loss setting
5)no trailling stoploss inbuilt setting
6)order execution strategy with order execution in range u dicided
 

c.trader

Active Member
#4
LETS START FROM MODIFICATION ,BACK TESTING AND EXPLORATION OF STRATEGY
BELOW IS A AR SYSTEM AFL BROUGHT FROM THIS FORUM
PLEASE HELP ME TO MODIFY IT FOR BACK TESTING AND EXPLORATION
AS PER MY VIEW ALL AFL ARE NEARLY 40 TO 50% SUCCESSFUL SO I STOP HUNTING AFL
MOST IMPORTANT THIN WILL BE MONEY MANAGEMENT

_SECTION_BEGIN("ooa");

GfxSetBkMode(1);

nol=27;

sk=((C-MA(C,nol))/MA(C,nol))*100;
Graph0=sk;
Graph0BarColor=IIf(sk>0,5,4);

_SECTION_BEGIN("hmw");


_SECTION_BEGIN("ema");
Lk = EMA(Close,22);
Plot (lk," ",colorBrightGreen,styleDots);


GfxSelectFont("tohomabold", Status("pxheight")/16);
GfxSetTextAlign( 6 );
GfxSetTextColor(ColorRGB(10,250,250));
GfxSetBkMode(0);
GfxTextOut( Name(), Status("pxwidth")/2, Status("pxheight")/10 );

cx=Param("cxposn",1085,0,1200,1);
cy=Param("cyposn",16,0,1000,1);
GfxSetBkColor(ColorRGB(200,50,100));
GfxSelectFont( "tohomabold",20,98, False);
GfxSetTextColor( colorYellow);
GfxSetTextColor( ColorHSB( 100, 10, 400) );
GfxTextOut("LTP. "+C+" ", cx, cy );

_SECTION_END();

_SECTION_BEGIN("Title");

DDayO = TimeFrameGetPrice("O", inDaily);
DHiDay = TimeFrameGetPrice("H", inDaily);
DLoDay = TimeFrameGetPrice("L", inDaily);
gfr = TimeFrameGetPrice("C", inDaily, -1);//close


Title = EncodeColor(colorWhite)+" * AR TRADING SYSTEM * "+EncodeColor(ColorRGB(220,10,150)) +" "+ Interval(2) + " " + Date() +
EncodeColor(ColorRGB(200,150,120)) + " \n Open " + O +
", High : " + H +
", Low : " + L+ EncodeColor(colorGreen) +
" * Prevvious Day Close : " + EncodeColor(colorGreen) + gfr +EncodeColor(colorYellow)+
"\n ToDay Open : " +DDayO + " High : " +DHiDay + " Low : "+ DLoDay;
_SECTION_END();

SetChartOptions(0,chartShowArrows|chartShowDates);
SetBarFillColor(IIf(C>O,ParamColor("Candle UP Color", colorBlack),IIf(C<=O,ParamColor("Candle Down Color", colorRed),colorLightGrey)));

Plot(C,"\nPrice",IIf(C>O,ParamColor("Wick UP Color", colorGreen),IIf(C<=O,ParamColor("Wick Down Color", colorRed),colorLightGrey)),64,0,0,0,0);



_SECTION_END();




_SECTION_BEGIN("Background Color");

BKswitch = ParamToggle("Background Color","On,Off");

OUTcolor = ParamColor("Outer Panel Color",colorBlack);
INUPcolor = ParamColor("Inner Panel Upper",colorGrey40);
INDNcolor = ParamColor("Inner Panel Lower",colorBlack);
TitleColor = ParamColor("Title Color ",colorBlack);

if (NOT BKswitch)
{
SetChartBkColor(OUTcolor); // color of outer border
SetChartBkGradientFill(INUPcolor,INDNcolor,TitleColor); // color of inner panel
}
_SECTION_END();
_SECTION_BEGIN("");




SetBarsRequired(100000,0);
GraphXSpace = 15;

ea = EMA (C,10);
eb = EMA (C,20);
SetBarFillColor( IIf( ea > eb, colorGreen, colorRed ) );

Buy = ea > eb AND TimeNum() > 092000 AND TimeNum() < 150000;
Sell = eb > ea OR TimeNum() > 150000;
Short = 0;
Cover = 0;
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Short = ExRem(Short,Cover);
Cover = ExRem(Cover,Short);


SetTradeDelays(1,1,1,1);

Factor=Param("Factor",4,1,10,1);
Pd=Param("ATR Periods",10,1,100,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 = Null;
TrendDown = Null;

trend=1;


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

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

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

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

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

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

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



Buy = trend==1;
Sell=trend==-1;

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


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




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),colorWhite, 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),colorWhite, 0,H, Offset=-45);

TrendSL=IIf(trend==1,TrendUp,TrendDown);

for(i=BarCount-1;i>1;i--)
{
if(Buy == 1)
{
entry = C;
sig = "BUY";
sl = TrendSL;
tar1 = entry + (entry * .0050);
tar2 = entry + (entry * .0092);
tar3 = entry + (entry * .0179);

bars = i;
i = 0;
}
if(Sell == 1)
{
sig = "SELL";
entry = C;
sl = TrendSL;
tar1 = entry - (entry * .0050);
tar2 = entry - (entry * .0112);
tar3 = entry - (entry * .0212);


bars = i;
i = 0;
}
}
Offset = 20;
Clr = IIf(sig == "BUY", colorLime, colorRed);
ssl = IIf(bars == BarCount-1, TrendSL[BarCount-1], Ref(TrendSL, -1));
sl = ssl[BarCount-1];

Plot(LineArray(bars-Offset, tar1, BarCount, tar1,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar2, BarCount, tar2,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar3, BarCount, tar3,1), "", Clr, styleLine|styleDots, Null, Null, Offset);

Plot(LineArray(bars-Offset, sl, BarCount, sl,1), "", colorDarkRed, styleLine|styleLine, Null, Null, Offset);
//Plot(LineArray(bars-Offset, entry, BarCount, entry,1), "", colorGreen, styleLine|styleLine, Null, Null, Offset);

for (i=bars; i <BarCount;i++)
{
PlotText(""+sig+"@"+entry, BarCount+1,entry,Null,colorBlue);
PlotText("T1@"+tar1,BarCount+3,tar1,Null,Clr);PlotText("T2@"+tar2,BarCount+3,tar2,Null,Clr);PlotText ("T3@"+tar3,BarCount+3,tar3,Null,Clr);

}

messageboard = ParamToggle("Message Board","Show|Hide",1);
if (messageboard == 1 )
{
GfxSelectFont( "Tahoma", 13, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );

if ( sig =="BUY")
{
GfxSelectSolidBrush( colorGreen ); // this is the box background color
}
else
{
GfxSelectSolidBrush( colorRed ); // this is the box background color
}
pxHeight = Status( "pxchartheight" ) ;
xx = Status( "pxchartwidth");
Left = 1100;
width = 310;
x = 5;
x2 = 290;

y = pxHeight;

GfxSelectPen( colorWhite, 4); // broader color
GfxRoundRect( x, y - 165, x2, y , 160, 90 ) ;
GfxTextOut( ( "* AR TRADING SYSTEM * "),141,y-160);
GfxTextOut( (" "),130,y-160);
GfxTextOut( ("Last " + sig + " Signal came " + (BarCount-bars-1) * Interval()/60 + " mins ago"), 148, y-140) ; // The text format location
GfxTextOut( ("" + WriteIf(sig =="BUY",sig + " @ ",sig + " @") + " : " + entry), 130, y-120);
GfxTextOut( ("STOP LOSS : " + sl + " (" + WriteVal(IIf(sig == "SELL",entry-sl,sl-entry), 2.2) + ")"), 130, y-100);
GfxTextOut( ("TGT:1 : " + tar1), 130, y -80);
GfxTextOut( ("TGT:2 : " + tar2), 130,y-60);
GfxTextOut( ("TGT:3 : " + tar3), 130,y-40);
GfxTextOut( ("Current P/L * : " + WriteVal(IIf(sig == "BUY",(C-entry),(entry-C)),2.2)), 130, y-22);;

}
_SECTION_END();




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

shape = Buy * shapeUpArrow + Sell * shapeDownArrow ;

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),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
//PlotShapes( shape, IIf( Buy, colorGreen, colorRed ),0, IIf( Buy, Low, High ) );
dist = 2.5*ATR(5);
for( i = 0; i < BarCount; i++ ) {
if( Buy ) PlotText( "Buy\n@" + Close, i, Low - dist, colorWhite );
if( Sell ) PlotText( "sell\n@" + Close, i, Low + dist, colorWhite );
}


_SECTION_BEGIN("ema");
P = ParamField("Field");
Type = ParamList("Type", "Weighted,Simple,Exponential,Double Exponential,Tripple Exponential,Wilders");

Periods89 = Param("Periods180", 180, 2, 300 );
Displacement2 = Param("Displacement2", 2, -50, 50 );
Plot( EMA( P, Periods89 ),
_DEFAULT_NAME(), colorWhite, styleDots, 0, 0, Displacement2 );

_SECTION_END();
rjl=Cross(Lk,tar1);
gol=Cross(tar1,Lk );

PlotShapes(shapeHollowStar*rjl,colorAqua,0,H,-20);
PlotShapes(shapeHollowStar*gol,colorViolet,0,L,20) ;
_SECTION_END();

jl = EMA(Close,13);





rfw=Cross(Lk,jl);
bve=Cross(jl,Lk);



dist =1.2*ATR(5);

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

if( bve ) PlotText( "AB\n" , i, L[ i ]-dist, colorWhite,colorDarkBlue );
if( rfw ) PlotText( "AS\n" , i, H[ i ]+dist, colorWhite, colorRed );
}

PlotShapes(shapeStar*bve,colorWhite,0,H,-90);
PlotShapes(shapeStar*rfw,colorWhite,0,L,20);

_SECTION_BEGIN("day");
TimeFrameSet( inDaily ); // switch now to dayily

Oo=EMA(C,3);

TimeFrameRestore(); // restore time frame to original

tb=EMA(gfr,3);



Plot( TimeFrameExpand( Oo, inDaily),"", colorYellow,10+30+4| styleNoLabel);


_SECTION_END();


_SECTION_BEGIN("Volume");

cx = Param("cxposn",476,0,1200,1);
cy = Param("cyposn", 500,0,1000,10 );

GfxSelectFont( " Arial ", 14, 98, False );
GfxSetTextColor(ColorRGB(10,250,250));

GfxTextOut("Volume : " +Volume+ "", cx +20,cy +50);





_SECTION_END( );




_SECTION_BEGIN("tom");
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",99,0,1000,1);
y=Param("yposn",40,0,1000,1);
//GfxRoundRect( x+615, y+530, x+738, y+499, 0,0 );
//GfxSelectSolidBrush( ColorRGB( 230, 230, 230 ) );
//GfxSelectPen( ColorRGB( 203, 25, 23 ), 3 );
if ( NewPeriod )
{
//GfxSelectSolidBrush( colorYellow );
//GfxSelectPen( colorYellow, 2 );
//Say( "New period" );
}

GfxSetBkMode(1);
GfxSelectFont( "Arial", 13, 800, False );
GfxSetTextColor(ColorRGB(220,10,150) );
GfxTextOut( "Timeleft"+" : "+NumToStr( SecsToGo, 1.0 ), x+674, y+507 );

_SECTION_END( );




_SECTION_BEGIN("sys");

x=Param("xposn",315,0,1000,1);
y=Param("yposn",576,0,1000,1);

GfxSetTextColor(ColorRGB(10,250,250));
GfxTextOut( ( " Develop By "),1150,y-45);
GfxSetTextColor(ColorRGB(10,250,250));
GfxTextOut( ( "Fu2 Trading SYSTEM * "),1150,y-25);






_SECTION_END();



_SECTION_BEGIN("Ribbon");
uptrend=PDI()>MDI()AND Signal()<MACD();
downtrend=MDI()>PDI()AND Signal()>MACD();
Plot( 1, /*efines the height of the ribbon in percent of pane width */"ribbon",
IIf( uptrend, colorLime, IIf( downtrend, colorRed,IIf(Signal()<MACD(), colorLightGrey, colorLightGrey ))), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -.05,50 );
_SECTION_END();
 

jagankris

Well-Known Member
#5
PLEASE HELP ME TO MODIFY IT FOR BACK TESTING AND EXPLORATION
Modified the AFL.

_SECTION_BEGIN("ooa");

GfxSetBkMode(1);

nol=27;

sk=((C-MA(C,nol))/MA(C,nol))*100;
Graph0=sk;
Graph0BarColor=IIf(sk>0,5,4);

_SECTION_BEGIN("hmw");


_SECTION_BEGIN("ema");
Lk = EMA(Close,22);
Plot (lk," ",colorBrightGreen,styleDots);


GfxSelectFont("tohomabold", Status("pxheight")/16);
GfxSetTextAlign( 6 );
GfxSetTextColor(ColorRGB(10,250,250));
GfxSetBkMode(0);
GfxTextOut( Name(), Status("pxwidth")/2, Status("pxheight")/10 );

cx=Param("cxposn",1085,0,1200,1);
cy=Param("cyposn",16,0,1000,1);
GfxSetBkColor(ColorRGB(200,50,100));
GfxSelectFont( "tohomabold",20,98, False);
GfxSetTextColor( colorYellow);
GfxSetTextColor( ColorHSB( 100, 10, 400) );
GfxTextOut("LTP. "+C+" ", cx, cy );

_SECTION_END();

_SECTION_BEGIN("Title");

DDayO = TimeFrameGetPrice("O", inDaily);
DHiDay = TimeFrameGetPrice("H", inDaily);
DLoDay = TimeFrameGetPrice("L", inDaily);
gfr = TimeFrameGetPrice("C", inDaily, -1);//close


Title = EncodeColor(colorWhite)+" * AR TRADING SYSTEM * "+EncodeColor(ColorRGB(220,10,150)) +" "+ Interval(2) + " " + Date() +
EncodeColor(ColorRGB(200,150,120)) + " \n Open " + O +
", High : " + H +
", Low : " + L+ EncodeColor(colorGreen) +
" * Prevvious Day Close : " + EncodeColor(colorGreen) + gfr +EncodeColor(colorYellow)+
"\n ToDay Open : " +DDayO + " High : " +DHiDay + " Low : "+ DLoDay;
_SECTION_END();

SetChartOptions(0,chartShowArrows|chartShowDates);
SetBarFillColor(IIf(C>O,ParamColor("Candle UP Color", colorBlack),IIf(C<=O,ParamColor("Candle Down Color", colorRed),colorLightGrey)));

Plot(C,"\nPrice",IIf(C>O,ParamColor("Wick UP Color", colorGreen),IIf(C<=O,ParamColor("Wick Down Color", colorRed),colorLightGrey)),64,0,0,0,0);



_SECTION_END();




_SECTION_BEGIN("Background Color");

BKswitch = ParamToggle("Background Color","On,Off");

OUTcolor = ParamColor("Outer Panel Color",colorBlack);
INUPcolor = ParamColor("Inner Panel Upper",colorGrey40);
INDNcolor = ParamColor("Inner Panel Lower",colorBlack);
TitleColor = ParamColor("Title Color ",colorBlack);

if (NOT BKswitch)
{
SetChartBkColor(OUTcolor); // color of outer border
SetChartBkGradientFill(INUPcolor,INDNcolor,TitleColor); // color of inner panel
}
_SECTION_END();
_SECTION_BEGIN("");




SetBarsRequired(100000,0);
GraphXSpace = 15;

ea = EMA (C,10);
eb = EMA (C,20);
SetBarFillColor( IIf( ea > eb, colorGreen, colorRed ) );

Buy = ea > eb AND TimeNum() > 092000 AND TimeNum() < 150000;
Sell = eb > ea OR TimeNum() > 150000;
Short = 0;
Cover = 0;
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Short = ExRem(Short,Cover);
Cover = ExRem(Cover,Short);


SetTradeDelays(1,1,1,1);

Factor=Param("Factor",4,1,10,1);
Pd=Param("ATR Periods",10,1,100,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 = Null;
TrendDown = Null;

trend=1;


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

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

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

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

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

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

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



Buy = trend==1;
Sell=trend==-1;

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


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




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),colorWhite, 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),colorWhite, 0,H, Offset=-45);

TrendSL=IIf(trend==1,TrendUp,TrendDown);

tar1 = 0;
tar2 = 0;
tar3 = 0;
bars = 0;
i = 0;
entry = 0;
sig = "";

for(i=BarCount-1;i>1;i--)
{
if(Buy == 1)
{
entry = C;
sig = "BUY";
sl = TrendSL;
tar1 = entry + (entry * .0050);
tar2 = entry + (entry * .0092);
tar3 = entry + (entry * .0179);

bars = i;
i = 0;
}
sig = "";
if(Sell == 1)
{
sig = "SELL";
entry = C;
sl = TrendSL;
tar1 = entry - (entry * .0050);
tar2 = entry - (entry * .0112);
tar3 = entry - (entry * .0212);
sig = "";

bars = i;
i = 0;
}
}
Offset = 20;
Clr = IIf(sig == "BUY", colorLime, colorRed);
ssl = IIf(bars == BarCount-1, TrendSL[BarCount-1], Ref(TrendSL, -1));
sl = ssl[BarCount-1];

Plot(LineArray(bars-Offset, tar1, BarCount, tar1,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar2, BarCount, tar2,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar3, BarCount, tar3,1), "", Clr, styleLine|styleDots, Null, Null, Offset);

Plot(LineArray(bars-Offset, sl, BarCount, sl,1), "", colorDarkRed, styleLine|styleLine, Null, Null, Offset);
//Plot(LineArray(bars-Offset, entry, BarCount, entry,1), "", colorGreen, styleLine|styleLine, Null, Null, Offset);

for (i=bars; i <BarCount;i++)
{
PlotText(""+sig+"@"+entry, BarCount+1,entry,Null,colorBlue);
PlotText("T1@"+tar1,BarCount+3,tar1,Null,Clr);PlotText("T2@"+tar2,BarCount+3,tar2,Null,Clr);PlotText ("T3@"+tar3,BarCount+3,tar3,Null,Clr);

}

messageboard = ParamToggle("Message Board","Show|Hide",1);
if (messageboard == 1 )
{
GfxSelectFont( "Tahoma", 13, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
sig = "";
if ( sig =="BUY")
{
GfxSelectSolidBrush( colorGreen ); // this is the box background color
}
else
{
GfxSelectSolidBrush( colorRed ); // this is the box background color
}
pxHeight = Status( "pxchartheight" ) ;
xx = Status( "pxchartwidth");
Left = 1100;
width = 310;
x = 5;
x2 = 290;

y = pxHeight;

GfxSelectPen( colorWhite, 4); // broader color
GfxRoundRect( x, y - 165, x2, y , 160, 90 ) ;
GfxTextOut( ( "* AR TRADING SYSTEM * "),141,y-160);
GfxTextOut( (" "),130,y-160);
GfxTextOut( ("Last " + sig + " Signal came " + (BarCount-bars-1) * Interval()/60 + " mins ago"), 148, y-140) ; // The text format location
GfxTextOut( ("" + WriteIf(sig =="BUY",sig + " @ ",sig + " @") + " : " + entry), 130, y-120);
GfxTextOut( ("STOP LOSS : " + sl + " (" + WriteVal(IIf(sig == "SELL",entry-sl,sl-entry), 2.2) + ")"), 130, y-100);
GfxTextOut( ("TGT:1 : " + tar1), 130, y -80);
GfxTextOut( ("TGT:2 : " + tar2), 130,y-60);
GfxTextOut( ("TGT:3 : " + tar3), 130,y-40);
GfxTextOut( ("Current P/L * : " + WriteVal(IIf(sig == "BUY",(C-entry),(entry-C)),2.2)), 130, y-22);;

}
_SECTION_END();

SetTradeDelays( 1, 1, 1, 1 ); //set trade delays at 1 bar open
RoundLotSize = 50; // Define Round Lot Size of the Trading Instrument
SetPositionSize ( 100,spsShares); // Define Fixed Trading Size
SetOption( "InitialEquity", 200000 );
SetOption( "MinShares", 1 );
SetOption( "MinPosValue", 1 ); // Enable Futures Mode
SetOption( "FuturesMode", True );
SetOption( "AllowPositionShrinking", True );
SetOption( "ActivateStopsImmediately", False );
SetOption( "ReverseSignalForcesExit", False );
SetOption( "AllowSameBarExit", False );
SetOption( "CommissionMode", 2 ); // Fixed Brokerage Commissions (Per Trade)
SetOption( "CommissionAmount", 100 ); // Rs 100/Leg Commisions
SetOption( "InterestRate", 0 );
SetOption( "MarginRequirement", 10 ); //Define Margin Requirement
SetOption("AccountMargin", 10 ); //Define Account Margin


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

shape = Buy * shapeUpArrow + Sell * shapeDownArrow ;

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),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
//PlotShapes( shape, IIf( Buy, colorGreen, colorRed ),0, IIf( Buy, Low, High ) );
dist = 2.5*ATR(5);
for( i = 0; i < BarCount; i++ ) {
if( Buy ) PlotText( "Buy\n@" + Close, i, Low - dist, colorWhite );
if( Sell ) PlotText( "sell\n@" + Close, i, Low + dist, colorWhite );
}


_SECTION_BEGIN("ema");
P = ParamField("Field");
Type = ParamList("Type", "Weighted,Simple,Exponential,Double Exponential,Tripple Exponential,Wilders");

Periods89 = Param("Periods180", 180, 2, 300 );
Displacement2 = Param("Displacement2", 2, -50, 50 );
Plot( EMA( P, Periods89 ),
_DEFAULT_NAME(), colorWhite, styleDots, 0, 0, Displacement2 );

_SECTION_END();
rjl=Cross(Lk,tar1);
gol=Cross(tar1,Lk );

PlotShapes(shapeHollowStar*rjl,colorAqua,0,H,-20);
PlotShapes(shapeHollowStar*gol,colorViolet,0,L,20) ;
_SECTION_END();

jl = EMA(Close,13);





rfw=Cross(Lk,jl);
bve=Cross(jl,Lk);



dist =1.2*ATR(5);

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

if( bve ) PlotText( "AB\n" , i, L[ i ]-dist, colorWhite,colorDarkBlue );
if( rfw ) PlotText( "AS\n" , i, H[ i ]+dist, colorWhite, colorRed );
}

PlotShapes(shapeStar*bve,colorWhite,0,H,-90);
PlotShapes(shapeStar*rfw,colorWhite,0,L,20);

_SECTION_BEGIN("day");
TimeFrameSet( inDaily ); // switch now to dayily

Oo=EMA(C,3);

TimeFrameRestore(); // restore time frame to original

tb=EMA(gfr,3);



Plot( TimeFrameExpand( Oo, inDaily),"", colorYellow,10+30+4| styleNoLabel);


_SECTION_END();


_SECTION_BEGIN("Volume");

cx = Param("cxposn",476,0,1200,1);
cy = Param("cyposn", 500,0,1000,10 );

GfxSelectFont( " Arial ", 14, 98, False );
GfxSetTextColor(ColorRGB(10,250,250));

GfxTextOut("Volume : " +Volume+ "", cx +20,cy +50);





_SECTION_END( );




_SECTION_BEGIN("tom");
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",99,0,1000,1);
y=Param("yposn",40,0,1000,1);
//GfxRoundRect( x+615, y+530, x+738, y+499, 0,0 );
//GfxSelectSolidBrush( ColorRGB( 230, 230, 230 ) );
//GfxSelectPen( ColorRGB( 203, 25, 23 ), 3 );
if ( NewPeriod )
{
//GfxSelectSolidBrush( colorYellow );
//GfxSelectPen( colorYellow, 2 );
//Say( "New period" );
}

GfxSetBkMode(1);
GfxSelectFont( "Arial", 13, 800, False );
GfxSetTextColor(ColorRGB(220,10,150) );
GfxTextOut( "Timeleft"+" : "+NumToStr( SecsToGo, 1.0 ), x+674, y+507 );

_SECTION_END( );




_SECTION_BEGIN("sys");

x=Param("xposn",315,0,1000,1);
y=Param("yposn",576,0,1000,1);

GfxSetTextColor(ColorRGB(10,250,250));
GfxTextOut( ( " Develop By "),1150,y-45);
GfxSetTextColor(ColorRGB(10,250,250));
GfxTextOut( ( "Fu2 Trading SYSTEM * "),1150,y-25);


_SECTION_END();



_SECTION_BEGIN("Ribbon");
uptrend=PDI()>MDI()AND Signal()<MACD();
downtrend=MDI()>PDI()AND Signal()>MACD();
Plot( 1, /*efines the height of the ribbon in percent of pane width */"ribbon",
IIf( uptrend, colorLime, IIf( downtrend, colorRed,IIf(Signal()<MACD(), colorLightGrey, colorLightGrey ))), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -.05,50 );
_SECTION_END();