You are on page 1of 8

_SECTION_BEGIN("PTA");

_SECTION_BEGIN("Target");
_SECTION_BEGIN
( "SingleMA" );
SetChartOptions( 0, chartShowArrows | chartShowDates | chartWrapTitle );
SetChartBkColor( ParamColor( "Outer Panel", colorLightGrey ) );
SetChartBkGradientFill( ParamColor( "Upper Chart", colorLightGrey ), ParamColor(
"Lower Chart", colorDarkGrey ) );
Type =

ParamList( "Average Type", "Wilders,SMA,EMA" );

P =

Param( "Averaging Period", 20, 3, 100, 1 );

Q =

Param( "%Change", 1, 0.1, 10, 0.1 );

BP =

Param( "BB Period", 20, 3, 100 );

BW =

Param( "BB Width", 2, 0.5, 10, 0.5 );

BBOption =
Report =

ParamToggle( "Plot BB", "No I Yes" );


ParamList( "Trigs or Update or Tgt-SL?", "Triggers|Update|Tgt-SL" );

messageboard = ParamToggle("Message Board","Show|Hide",0);


showsl = ParamToggle("Stop Loss Line", "Show|Hide", 0);
SetChartBkColor(ParamColor("BackGround Color", colorLightGrey));
pShowtradeLines = ParamToggle("Show Trade Lines", "No|Yes", 1);
pShowMarkers = ParamToggle("Show Markers", "No|Yes", 1);
synch=ParamToggle("Synchronize buy/short with foreign index", "No|Yes", 1);
Volmin=Param("Volume minimum",5000,0,10000000,50);
Volmax=Param("Volume maximum",1000000,0,10000000,50);
priceRL=Param("Price Range Min",150,1,20000,1);
priceRH=Param("Price Range Max",3000,1,20000,1);
PercChangemin=Param("Percentage Change Min set", -25, -100, 100, 0.1);
PercChangemax=Param("Percentage Change Max set", 25, -100, 100, 0.1);
PerctakeProfit=Param("Take Profit Percent Set",0.6,0.3,30,0.1);
PercStoploss=Param("StopLoss Percent Set",0.25,0.2,5,0.1);
k = Optimize("K",Param("K",1.75,1,5,0.25),1,5,0.25);
Per= Optimize("atr",Param("atr",10,3,30,1),3,30,1);
accel = Param("Acceleration", 0.02, 0, 1, 0.001);
mx = Param("Max. acceleration", 0.2, 0, 1, 0.001);
PlotOHLC(Open,High,Low,Close,"",colorWhite,styleCandle);
Bars = 0;
xpdh = 90;
{
Plot_Range = (TimeNum() >= 85500 AND TimeNum()<= 153500) AND (DateNum()==LastVal

ue(DateNum()));
FH_Range = (TimeNum() >= 085500 AND TimeNum()<= 093000) AND (DateNum()==LastVa
lue(DateNum()));
FH_Prices = High * FH_Range;
FH_Marker = BarsSince(FH_Range>0);
Num_Bars

= 36000 / Interval(1);

TimeFrameSet(inDaily);
TOP_
= Open;
PDH_
= Ref(High,-1);
PDL_
= Ref(Low,-1);
PDO_
= Ref(Open,-1);
PDC_
= Ref(Close,-1);
PDM_
= (PDH_+PDL_)/2;
TimeFrameRestore();
isAll = True;
isRth = TimeNum() >= 085400 AND TimeNum() <= 093000;
isdRth = TimeNum() >= 085400 AND TimeNum() <= 160000;
aRthL = IIf(isRth, L, 1000000);
aRthH = IIf(isdRth, H, Null);
aRthLd = IIf(isdRth, L, 1000000);
TOP
= TimeFrameExpand(TOP_,inDaily,expandFirst);
PDH
= TimeFrameExpand(PDH_,inDaily,expandFirst);
PDL
= TimeFrameExpand(PDL_,inDaily,expandFirst);
PDO
= TimeFrameExpand(PDO_,inDaily,expandFirst);
PDC
= TimeFrameExpand(PDC_,inDaily,expandFirst);
PDM
= TimeFrameExpand(PDM_,inDaily,expandFirst);
FHH
= Ref(HHV(High*FH_Range,Num_Bars),-FH_Marker);
FHL = TimeFrameCompress( aRthL, inDaily, compressLow );
FHL = TimeFrameExpand( FHL, inDaily, expandFirst );
DayH = TimeFrameCompress( aRthH, inDaily, compressHigh );
DayH = TimeFrameExpand( DayH, inDaily, expandFirst );
DayL = TimeFrameCompress( aRthLd, inDaily, compressLow );
DayL = TimeFrameExpand( DayL, inDaily, expandFirst );
rt=PTA_Intra();
BBTop =
BBandTop( C, BP, BW );
BBBot =
BBandBot( C, BP, BW );
if( Status( "action" ) == actionIndicator )
{
Ttl =
EncodeColor( colorTurquoise ) + "profittradesoft.com" + "\n"
+
WriteIf( Buy1, EncodeColor( colorGreen ) + "Buy Triggered Today, Buy th
is stock Tomorrow.", "" )
+
WriteIf( Sell1, EncodeColor( colorRed ) + "Sell Triggered Today, Sell T
his stock Tomorrow.", "" )
+
EncodeColor( colorTan ) + WriteIf( Bought AND NOT Buy1, "Bought @ " + B
uyPrice + ". "
+
"Target Price = " + NextTgt + ", Sto
p Loss = " + SL + ".\n"
+

WriteIf( TgtReached, "Target Reached


. Next Target = " + Ref( NextTgt, 1 ) + ".\n", "" )
+
EncodeColor( colorGold ) + "Profit /
Loss so far = " + Prec( 100 * ( C - BuyPrice ) / BuyPrice, 2 ) + "%", "" )
+
WriteIf( Sold AND NOT Sell1, "Sold @ " + SellPrice + "\nProfit / Loss i
n Previous Trade = " + Prec( 100 * ( SellPrice - BuyPrice ) / BuyPrice, 2 ) + "%
", "" );
_N( Title = StrFormat( "{{NAME}} ({{INTERVAL}}), {{DATE}} ; {{OHLCX}}, V=%1.
0f\n {{VALUES}}\n\n", V ) + Ttl );
ChartStyle =
ParamStyle( "Chart Type", styleCandle, maskAll );
PlotOHLC( O, H, L, C, "", colorWhite, ChartStyle );
Plot( A, Type + "(" + P + ")", colorYellow, styleLine | styleThick );
Plot( IIf( Bought, NextTgt, Null ), "Target", colorDarkTeal, styleLine | sty
leThick );
//Plot( SL, "Trail SL", colorWhite, styleLine );
PlotShapes(
-20 );
PlotShapes(
30 );
PlotShapes(
-25 );
PlotShapes(
0 );
PlotShapes(
= 30 );
PlotShapes(
t = -25 );

IIf( Buy1, shapeSquare, shapeNone ), colorGreen, 0, L, Offset =


IIf( Buy1, shapeSquare, shapeNone ), colorLime, 0, L, Offset = IIf( Buy1, shapeUpArrow, shapeNone ), colorWhite, 0, L, Offset =
IIf( Sell1, shapeSquare, shapeNone ), colorRed, 0, H, Offset = 2
IIf( Sell1, shapeSquare, shapeNone ), colorOrange, 0, H, Offset
IIf( Sell1, shapeDownArrow, shapeNone ), colorWhite, 0, H, Offse

if ( BBOption )
Plot( BBtop, "BB-Top", colorPink, styleLine );
if ( BBOption )
Plot( BBBot, "BB-Bot", colorPink, styleLine );
{
// AlertIf( Buy , "SOUND C:\\Windows\\Media\\Raga\\Windows Notify.wav", "
Audio alert", 2 );
//AlertIf( Sell , "SOUND C:\\Windows\\Media\\Raga\\Windows Notify.wav",
"Audio alert", 2 );
}
}

if( ( Status( "action" ) == actionExplore ) AND Report == "Triggers" )


{
Filter = Buy1 OR Sell1;
SetOption( "NoDefaultColumns", True );

AddTextColumn( Name(), "Symbol", 77, colorDefault, colorDefault, 120 );


AddColumn( DateTime(), "Trigger Date", formatDateTime );
AddColumn( IIf( Buy1, 66, 83 ), "Signal", formatChar, colorYellow, IIf( Buy1
, colorGreen, colorRed ) );
AddColumn( C, "C. M. P.", 6.2 );
AddColumn( IIf( Buy1 OR Bought, NextTgt, Null ), "Target", 6.2 );
AddColumn( IIf( Buy1 OR Bought, SL, Null ), "StopLoss", 6.2 );
}

if( ( Status( "action" ) == actionExplore ) AND Report == "Update" )


{
Filter = True;

SetOption( "NoDefaultColumns", True );


AddColumn( DateTime(), "Updated On", formatDateTime, colorDefault, colorDefa
ult, 96 );
AddTextColumn( Name(), "Symbol", 77, colorDefault, colorDefault, 120 );
AddColumn( BuyDate, "Buy Date", formatDateTime, colorDefault, colorDefault,
96 );
AddColumn( BuyPrice, "Buy Price", 6.2 );
AddColumn( NextTgt, "Target", 6.2 );
AddColumn( SL, "StopLoss", 6.2 );
AddColumn( C, "CMP", 6.2, colorDefault, colorDefault, 96 );
}

if( ( Status( "action" ) == actionExplore ) AND Report == "Tgt-SL" )


{
Filter = TgtReached OR SLHit;
SetOption( "NoDefaultColumns", True );
AddColumn( DateTime(), "Updated On", formatDateTime, colorDefault, colorDefa
ult, 96 );
AddTextColumn( Name(), "Symbol", 77, colorDefault, colorDefault, 120 );
AddColumn( BuyDate, "Buy Date", formatDateTime, colorDefault, colorDefault,
96 );
AddColumn( BuyPrice, "Buy Price", 6.2 );
AddColumn( NextTgt, "Target", 6.2 );
AddColumn( SL, "StopLoss", 6.2 );
AddColumn( C, "CMP", 6.2, colorDefault, colorDefault, 96 );
AddColumn( IIf( TgtReached, 89, 32 ), "Tgt Hit?", formatChar, colorYellow, I
If( TgtReached, colorGreen, colorDefault ) );
AddColumn( IIf( TgtReached, 2 * H - SL, Null ), "Next Tgt", 1.2 );
AddColumn( IIf( SLHit, 89, 32 ), "SL-Hit", formatChar, colorYellow, IIf( SLH
it, colorRed, colorDefault ) );
}
AlertIf( Buy, "", "BUY @ " + C, 1 );
AlertIf( Sell, "", "SELL @ " + C, 2 );

Offset = 20;
Clr = IIf(sig == "BUY", colorLime, colorRed);
ssl = IIf(bars == BarCount-1, s5d[BarCount-1], Ref(s5d, -1));
sl = ssl[BarCount-1];
Plot(LineArray(bars-Offset, tar1, BarCount, tar1,1), "", Clr, styleLine|styleDot
s, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar2, BarCount, tar2,1), "", Clr, styleLine|styleDot
s, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar3, BarCount, tar3,1), "", Clr, styleLine|styleDot
s, Null, Null, Offset);
Plot(LineArray(bars-Offset, sl, BarCount, sl,1), "", colorDarkRed, styleLine|sty
leLine, Null, Null, Offset);
Plot(LineArray(bars-Offset, entry, BarCount, entry,1), "", colorBlue, 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,tar
2,Null,Clr);PlotText ("T3@"+tar3,BarCount+3,tar3,Null,Clr);
}

_SECTION_BEGIN("Trading");
//SetChartBkColor(ParamColor("Outer panel color ",colorLightYellow));
//foreign
_SECTION_BEGIN ("foreign Index bar graph");
Vr=ParamList("Index",List = "^NSEI,^NSEBANK,^CNXIT,^NSMIDCP,RELIANCE.NS,SBIN.NS"
,0);
SetForeign(Vr);
HaC =(O+H+L+C)/4;
HaO = AMA( Ref( HaC, -1 ), 0.5 );
HaH = Max( H, Max( HaC, HaO) );
HaL = Min( L, Min( HaC, HaO) );
BG3=HHV(LLV(HaL,4)+ATR(4),8);
BR3=LLV(HHV(HaH ,4)-ATR(4),8);
co = IIf(Hac>BG3 ,colorBrightGreen,IIf(Hac < BR3,colorRed,colorGrey50));
Plot(4, "", Co,styleArea+styleOwnScale | styleNoLabel, -1, 100);
RestorePriceArrays();
_SECTION_END();

BuyPrice1=(DayL+AF);
BuyTP1=(BuyPrice1+(BuyPrice1*(PerctakeProfit/100)));
BuyTP2=(C>=BuyTP1);
SellPrice1=(DayH-AF);
SellTP1=(SellPrice1-(SellPrice1*(PerctakeProfit/100)));
SellTP2=(C<=SellTP1);
percchange=(((C-TOP)/TOP)*100);
Vol=(V>=Volmin AND V<=Volmax);
Percentage=(percchange>=PercChangemin AND percchange<=PercChangemax);
prc=(C>=priceRL AND C<=priceRH);

BuyStop1=(BuyPrice1-(BuyPrice1*(PercStoploss/100)));
BuyStop2=IIf((BuyStop1<=SellPrice1) AND SellPrice1<=BuyPrice1,SellPrice1,BuyStop
1);
SellStop1=(SellPrice1+(SellPrice1*(PercStoploss/100)));
SellStop2=IIf((SellStop1>=BuyPrice1) AND SellPrice<=BuyPrice1, BuyPrice1,SellSto
p1);
BuyStop=IIf((Buy AND NOT BuyTP2),BuyStop2,Null);
BuyTP=IIf(Buy AND NOT BuyStop,BuyTP2,Null);
Bars
= BarsSince(TimeNum() >= 85400 AND TimeNum() < 092900);
x0
= BarCount-LastValue(Bars);
x1
= BarCount-1;
TOP_Line = LineArray(x0,LastValue(TOP),x1,LastValue(TOP),0);
PDH_Line = LineArray(x0,LastValue(PDH),x1,LastValue(PDH),0);
PDL_Line = LineArray(x0,LastValue(PDL),x1,LastValue(PDL),0);
PDC_Line = LineArray(x0,LastValue(PDC),x1,LastValue(PDC),0);
PDM_Line = LineArray(x0,LastValue(PDM),x1,LastValue(PDM),0);
FHH_Line = LineArray(x0,LastValue(FHH),x1,LastValue(FHH),0);
FHL_Line = LineArray(x0,LastValue(FHL),x1,LastValue(FHL),0);
BuyPriceline=LineArray(x0,LastValue(BuyPrice1),x1,LastValue(BuyPrice1),0);
BuyStopline=LineArray(x0,LastValue(BuyStop2),x1,LastValue(BuyStop2),0);
BuyTPline=LineArray(x0,LastValue(BuyTP1),x1,LastValue(BuyTP1),0);
SellPriceline=LineArray(x0,LastValue(SellPrice1),x1,LastValue(SellPrice1),0);
SellStopline=LineArray(x0,LastValue(SellStop2),x1,LastValue(SellStop2),0);
SellTPline=LineArray(x0,LastValue(SellTP1),x1,LastValue(SellTP1),0);
DayHline=LineArray(x0,LastValue(DayH),x1,LastValue(DayH),0);
DayLline=LineArray(x0,LastValue(DayL),x1,LastValue(DayL),0);
Plot(IIf(pShowtradeLines,BuyStopline,Null),"BuyStop",colorBrightGreen,styleDots|
styleNoRescale| styleNoLine);
Plot(IIf(pShowtradeLines,SellPriceline,Null),"Short Here",colorRed,styleDots|sty
leNoRescale);
//PlotShapes(IIf(pShowMarkers AND Buy, shapeHollowUpArrow, Null), colorDarkGreen
, 0,L,Offset=-30);
if( Status("action") == actionIndicator )
(
Title = EncodeColor(colorWhite)+ "Trading System" + " - " + Name() + " - " + En
codeColor(colorYellow)+ Interval(2) + EncodeColor(colorYellow) +
" - " + Date() +" - "+ EncodeColor(colorYellow) + "-Open="+WriteVal(O,1) + Enc
odeColor(colorYellow) + "- High= "+ WriteVal(H,1)+ EncodeColor(colorYellow) + "Low= "+ WriteVal(L,1)+ EncodeColor(colorYellow) + "- Close= "+ WriteVal(C,1)+ E
ncodeColor(colorYellow) + "- Vol= "+ WriteVal(V,1)+("\n")
+WriteIf(Percchange, " % Change = "+(Percchange)+" ","")+" Previous DayHigh="
+WriteVal(PDH,1)+", Previous DayLow="+WriteVal(PDL,1)+", Today High="+WriteVal(D
ayH,1)+", Todays Low="+WriteVal(DayL,1)+
WriteIf(Hac>BG3,EncodeColor(colorBrightGreen)+"+Up",
WriteIf(Hac<BR3,EncodeColor(colorRed)+"-Down",EncodeColor(colorLightYellow)+"< F
lat >")));
}

_SECTION_BEGIN("short signal");
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 ) );
BG2=HHV(LLV(Low,4)+ATR(4),8);
BR2=LLV(HHV(High,4)-ATR(4),8);
SetBarFillColor( IIf(O <C, colorSeaGreen,colorOrange) );
Plot(NW, "", IIf(Trend == 1, 6, 4), 4);
PlotShapes(IIf(Buy3, shapeUpArrow, shapeNone),colorWhite, 0,halow,-30);
PlotShapes(IIf(Sell3, shapeHollowDownTriangle, shapeNone),colorWhite, 0,hahigh,15);
PlotShapes(IIf(Cover3, shapeHollowUpTriangle, shapeNone),colorWhite, 0,halow,-15
);
PlotShapes(IIf(Short3, shapeDownArrow, shapeNone),colorWhite, 0,hahigh,-30);
//-----------end--------------

_SECTION_END();
_SECTION_END();
_SECTION_END();
//--------------------------------------------------------------//
//-------------------------------------------------------------SetBarsRequired( 800, 0 );
GraphXSpace = 7;
SetChartOptions( 0, chartShowArrows | chartShowDates );
SellPrice3 = ValueWhen( Sell5, C, 1 );
BuyPrice3 = ValueWhen( Buy5, C, 1 );
// set criteria to scan for big stock only;
//BigStock = MA( V, 10 ) * MA( C, 10 ) > 1000000;
//============== Plot price ==============
n = 15;
a = C > ( MA( H, n ) + MA( L, n ) ) / 2;// then Buy next bar at market;
b = C < ( MA( H, n ) + MA( L, n ) ) / 2;// then Sell Short next bar at market;
state = IIf( BarsSince( a ) < BarsSince( b ), 1, 0 );
Longs = state == 1;
shorts = state == 0;
//Chart
Colorbar = IIf( Longs, colorGreen, IIf( Shorts, colorRed, colorGrey40 ) );
Plot( C, "Close", colorbar, styleCandle = 64 | styleNoTitle );
//============== Plot Shape ==============
_SECTION_END();

_SECTION_BEGIN("Support and Resistance");


LB= Param("Look Back Periods",10,1,30,1);
rt=SR();
Color=IIf(O>C,colorBlack,colorGreen);
Plot (R,"Resz",22,8+16);
Plot (s,"Supp",19,8+16);
Plot (C,"Close",color,64,32);
GraphXSpace=4;
PlotShapes ( IIf(PivotHigh, shapeSmallCircle, shapeNone), colorCustom12,0,H, 5);
PlotShapes( IIf(PivotLow, shapeSmallCircle, shapeNone), colorBlue,0, L, -5);
_SECTION_END();

You might also like