Part 2 :
DefinedPatterns = AscT | DscT | ST | ET | RW | FW | UT | DT; Filter = BarIndex() == LastValue( BarIndex() ) AND NOT GroupID() == 253; Filter = Filter AND ( AscT AND AscTs ) | ( DscT AND DscTs ) | ( ST AND STs ) | ( ET AND ETs ) | ( RW AND RWs ) | ( FW AND FWs ) | ( UT AND UTs ) | ( DT AND DTs ) | ( Range AND Ranges ) | ( SupSignals AND NonDefinedPatterns AND NOT DefinedPatterns ) | ( ResSignals AND NonDefinedPatterns AND NOT DefinedPatterns ); // | PLLSignals | PHLSignals | Trade Variables Red = C < O; Green = C > O; Buy = FW | UT; //Buy=Buy1 & !Ref(Buy1,-1); Short = RW | DT; //Short = Short1 & !Ref(Short1,-1); Buy1 = BarsSince( Buy ); Short1 = BarsSince( Short ); BuyPrice = ( round( ValueWhen( Buy, C ) * 10 ) ) / 10; ShortPrice = ( round( ValueWhen( Short, C ) * 10 ) ) / 10; Buystop = ( round( ( BuyPrice - ( BuyPrice * 0.5 / 100 ) ) * 10 ) ) / 10; Shortstop = ( round( ( ShortPrice + ( ShortPrice * 0.5 / 100 ) ) * 10 ) ) / 10; Buystop1 = ( ( Cross( Buystop, C ) OR Cross( Buystop, L ) ) AND since ) ; Shortstop1 = ( ( Cross( H, Shortstop ) OR Cross( C, Shortstop ) ) AND since ); Sell1 = ( Buy1 > 0 AND ( ( CCI( 14 ) < Ref( CCI( 14 ), -1 ) AND Red ) OR ( x == xd & NOT AnZ ) ) AND since ); Sell = Sell1 AND NOT Ref( Sell1, -1 ); Cover1 = ( Short1 > 0 AND ( ( CCI( 14 ) > Ref( CCI( 14 ), -1 ) AND Green ) OR ( x == xb & NOT AnZ ) ) AND since ); Cover = Cover1 AND NOT Ref( Cover1, -1 ); SellPrice = ( round( ValueWhen( Sell, C ) * 10 ) ) / 10; CoverPrice = ( round( ValueWhen( Cover, C ) * 10 ) ) / 10; Buy11 = Cum( Buy ); Short11 = Cum( Short ); //Indicator if ( Status( "action" ) == actionIndicator ) ( Title = EncodeColor( colorLightBlue ) + "Patterns Trading System - Conceived, developed and Property of Vinod K. Iyer - " + "\n" + EncodeColor( colorYellow ) + Name() + " - " + EncodeColor( colorYellow ) + Interval( 2 ) + EncodeColor( colorWhite ) + " - " + Date() + " - " + EncodeColor( colorYellow ) + " TurnOver= Rs. " + EncodeColor( colorWhite ) + WriteVal( ( ( ( V * C ) / 100000 ) ), 1.2 ) + " Lakhs - " + "\n" + WriteIf( LastValue( AscT ), "Ascending Triangle - bullish formation that usually forms during an uptrend as a continuation pattern" + "", "" ) + WriteIf( LastValue( DscT ), "Decending Triangle - bearish formation that usually forms during a downtrend as a continuation pattern." + "", "" ) + WriteIf( LastValue( ST ), "Symmetrical Triangle - mark important trend reversals, they more often mark a continuation of the current trend - direction of the next major move can only be determined after a valid breakout." + "", "" ) + WriteIf( LastValue( ET ), "Expanding Triangle - The expanding triangle is said to be a good indicator of a reversal pattern" + "", "" ) + WriteIf( LastValue( RW ), "Rising Wedge - rising wedges definitely slope up and have a bearish bias" + "", "" ) + WriteIf( LastValue( FW ), "Falling Wedge - falling wedges definitely slope down and have a bullish bias." + " ", "" ) + WriteIf( LastValue( UT ), "Up Channel - Bullish Trend" + "", "" ) + WriteIf( LastValue( DT ), "Down Channel - Bearish Trend" + "", "" ) + "\n" + WriteIf( Sup_pricejustabove, EncodeColor( colorBrightGreen ) + "Price just above Support", WriteIf( Sup_confirmed, EncodeColor( colorBrightGreen ) + "Support Confirmed", EncodeColor( colorWhite ) + "" ) ) + WriteIf( Sup_break, EncodeColor( colorRed ) + "Support Break" + "", "" ) + "\n" + WriteIf( Res_pricejustbelow, EncodeColor( colorRed ) + "Price just below Resistance", WriteIf( Res_confirmed, EncodeColor( colorRed ) + "Resistance Confirmed", EncodeColor( colorWhite ) + "" ) ) + WriteIf( Res_break, EncodeColor( colorBrightGreen ) + "Resistance Break" + "", "" ) + "\n" + EncodeColor( colorBrightGreen ) + WriteIf( BuyPrice, "BUY: " + ( BuyPrice ) + " ", "" ) + WriteIf( BuyStop, " - BUY SL: " + ( BuyStop ), "" ) + WriteIf( SellPrice , " - BUY TP: " + ( SellPrice ) + " ", "" ) + "\n" + EncodeColor( colorRed ) + WriteIf( ShortPrice, "SHORT: " + ( ShortPrice ) + " ", "" ) + WriteIf( ShortStop, "- SHORT SL: " + ( ShortStop ) + " ", "" ) + WriteIf( CoverPrice, " - SHORT TP: " + ( CoverPrice ) + " ", "" ) + "\n" + "\n" + WriteIf( Range, "Range", "Not defined" ) ); //Shapes if ( PlotP1P2 ) { PlotShapes( IIf( x == xa & NOT AnZ, P1Shape, shapeNone ), Color_SL, 0, SL, -13 ); PlotShapes( IIf( Buy, shapeUpArrow, shapeNone ), Color_SL, 0, SL, -25 ); PlotShapes( IIf( x == xc & NOT AnZ, P1Shape, shapeNone ), Color_RL, 0, H, 13 ); PlotShapes( IIf( Short, shapeDownArrow, shapeNone ), Color_RL, 0, H, -25 ); } PlotShapes( IIf( Buystop1, shapeCircle, shapeNone ), Color_SL, 0, SL, -13 ); PlotShapes( IIf( Cover, shapeUpTriangle, shapeNone ), Color_RL, 0, SL, -45 ); PlotShapes( IIf( Shortstop1, shapeCircle, shapeNone ), Color_RL, 0, H, -13 ); PlotShapes( IIf( Sell, shapeDownTriangle, shapeNone ), Color_SL, 0, H, -45 ); //money management lotSizeb = round( ( riskAmount / ( BuyPrice - BuyStop ) ) ); lotSizes = round( ( riskAmount / ( ShortStop - ShortPrice ) ) ); //Explorer AddColumn( IIf( Buy, 66, IIf( Short, 83, 01 ) ), "GO", formatChar, colorWhite, bkcolor = IIf( Short, colorDarkRed, colorDarkGreen ) ); AddColumn( IIf( Sell, 80, IIf( Cover, 80, 01 ) ), "PR", formatChar, colorWhite, bkcolor = IIf( Cover , colorDarkRed, colorDarkGreen ) ); AddColumn( IIf( buystop1, 76, IIf( shortstop1, 76, 01 ) ), "SL", formatChar, colorWhite, bkcolor = IIf( shortstop1 , colorDarkRed, colorDarkGreen ) ); AddColumn( IIf( Buy OR Buystop1 OR Sell, BuyPrice, IIf( Short OR shortstop1 OR Cover, ShortPrice, 01 ) ), "ENTRY@", 1.2, colorWhite, bkcolor = IIf( Short OR Shortstop1 OR Cover, colorDarkRed, colorDarkGreen ) ); AddColumn( IIf( Buy OR Buystop1 OR Sell, BuyStop, IIf( Short OR Shortstop1 OR Cover, ShortStop, 01 ) ), "STPLS@", 1.2, colorWhite, bkcolor = IIf( Short OR Shortstop1 OR Cover, colorDarkRed, colorDarkGreen ) ); AddColumn( IIf( Buy OR Buystop1 OR Sell, SellPrice, IIf( Short OR Shortstop1 OR Cover, CoverPrice, 01 ) ), "PR@", 1.2, colorWhite, bkcolor = IIf( Short OR Shortstop1 OR Cover, colorDarkRed, colorDarkGreen ) ); AddColumn( IIf( Buy OR Buystop1 OR Sell, Lotsizeb, IIf( Short OR Shortstop1 OR Cover, Lotsizes, 01 ) ), "QTY", 1.0, colorWhite, bkcolor = IIf( Short OR Shortstop1 OR Cover, colorDarkRed, colorDarkGreen ) ); AddTextColumn( WriteIf( Sup_pricejustabove, "Price just above", WriteIf( Sup_confirmed, "Confirmed", WriteIf( Sup_break, "Break", "" ) ) ), "Support Line", 1.2, IIf( Sup_pricejustabove OR sup_confirmed, colorGreen, colorRed ) ); AddTextColumn( WriteIf( Res_pricejustbelow, "Price just below", WriteIf( Res_confirmed, "Confirmed", WriteIf( Res_break, "Break", "" ) ) ), "Resistance Line", 1.2, IIf( Res_pricejustbelow OR Res_confirmed, colorRed, colorGreen ) ); patterncolor = IIf( AscT | FW | UT, colorGreen, IIf( DscT | RW | DT, colorRed, IIf( ST | ET | Range, colorBlue, colorBlack ) ) ); AddTextColumn( PatternText, "Pattern", 0, patterncolor ); AddTextColumn( FullName(), "Full name" ); AddTextColumn( WriteIf( PLL_pricejustabove, "price just above", WriteIf( PLL_confirmed, "confirmed", WriteIf( PLL_break, "break", "" ) ) ), "Parallel support line" ); AddTextColumn( WriteIf( PHL_pricejustbelow, "price just below", WriteIf( PHL_confirmed, "confirmed", WriteIf( PHL_break, "break", "" ) ) ), "Parallel resistance line" ); //Alerts AlertIf( Buy, "SOUND C:\\Windows\\Media\\Windows XP Startup.wav", "Buy", 2 ); AlertIf( Short, "SOUND C:\\Windows\\Media\\Windows XP Startup.wav", "Short", 2 ); AlertIf( BuyStop1, "SOUND C:\\Windows\\Media\\Ringin.wav", "BuyStop Hit", 2 ); AlertIf( Sell, "SOUND C:\\Windows\\Media\\Ringin.wav", "Buy Take Profit", 2 ); AlertIf( ShortStop1, "SOUND C:\\Windows\\Media\\Ringin.wav", "Short Stop Hit", 2 ); AlertIf( Cover , "SOUND C:\\Windows\\Media\\Ringin.wav", "Short Take Profit", 2 ); /* Export intraday AND EOD data to TXT files In the first line insert the directory you want to save them to, make sure the directory exists Select the timeframe period you want to save as using the AA "Settings" */ if ( IsEmpty( StaticVarGet( "SendSignal" + Name() ) ) ) { StaticVarSet( "SendSignal" + Name(), 1 ); } if ( ( StaticVarGet( "SendSignal" + Name() ) == 1 ) & LastValue( Buy ) ) { fh = fopen( "C:\\BTT_Exe\\config\\order" + ".SAV", "awr" ); if ( fh ) { fputs( "NSECM|Buy|CLI|VYV118|" + Name() + "|" + BuyPrice + "|" + Lotsizeb + "|" + "SL|" + ( round( ( BuyPrice - ( BuyPrice*0.02 / 100 ) )*10 ) ) / 10 + "|" + "-|-|NL|Margin|08067|N|DAY|Long at|-|-|-|-|-|" + "\n", fh ); fputs( "NSECM|Sell|CLI|VYV118|" + Name() + "|" + BuyStop + "|" + Lotsizeb + "|" + "SL|" + ( round( ( BuyStop + ( BuyStop*0.03 / 100 ) )*10 ) ) / 10 + "|" + "-|-|NL|Margin|08067|N|DAY|BuyStop|-|-|-|-|-|" + "\n", fh ); fputs( "" + "\n", fh ); StaticVarSet( "SendSignal" + Name() , 0 ); fclose( fh ); } } if ( IsEmpty( StaticVarGet( "SendSignal1" + Name() ) ) ) { StaticVarSet( "SendSignal1" + Name(), 1 ); } if ( ( StaticVarGet( "SendSignal1" + Name() ) == 1 ) & LastValue( Short ) ) { fh = fopen( "C:\\BTT_Exe\\config\\order" + ".SAV", "awr" ); if ( fh ) { fputs( "NSECM|Short Sell|CLI|VYV118|" + Name() + "|" + ShortPrice + "|" + Lotsizes + "|" + "SL|" + ( round( ( ShortPrice + ( ShortPrice*0.02 / 100 ) )*10 ) ) / 10 + "|" + "-|-|NL|Margin|08067|N|DAY|Short at|-|-|-|-|-|" + "\n", fh ); fputs( "NSECM|Buy to Cover|CLI|VYV118|" + Name() + "|" + shortStop + "|" + Lotsizes + "|" + "SL|" + ( round( ( Shortstop - ( ShortStop*0.03 / 100 ) )*10 ) ) / 10 + "|" + "-|-|NL|Margin|08067|N|DAY|ShortStop|-|-|-|-|-|" + "\n", fh ); fputs( "" + "\n", fh ); StaticVarSet( "SendSignal1" + Name() , 0 ); fclose( fh ); } } if ( IsEmpty( StaticVarGet( "SendSignal2" + Name() ) ) ) { StaticVarSet( "SendSignal2" + Name(), 1 ); } if ( ( StaticVarGet( "SendSignal2" + Name() ) == 1 ) & LastValue ( Buy11 ) & LastValue( Buy ) ) { fh = fopen( "C:\\BTT_Exe\\config\\order" + ".SAV", "awr" ); if ( fh ) { fputs( "NSECM|Buy|CLI|VYV118|" + Name() + "|" + BuyPrice + "|" + Lotsizeb + "|" + "SL|" + ( round( ( BuyPrice - ( BuyPrice*0.02 / 100 ) )*10 ) ) / 10 + "|" + "-|-|NL|Margin|08067|N|DAY|Long at|-|-|-|-|-|" + "\n", fh ); fputs( "NSECM|Sell|CLI|VYV118|" + Name() + "|" + BuyStop + "|" + Lotsizeb + "|" + "SL|" + ( round( ( BuyStop + ( BuyStop*0.03 / 100 ) )*10 ) ) / 10 + "|" + "-|-|NL|Margin|08067|N|DAY|BuyStop|-|-|-|-|-|" + "\n", fh ); fputs( "" + "\n", fh ); StaticVarSet( "SendSignal2" + Name() , 0 ); fclose( fh ); } } if ( IsEmpty( StaticVarGet( "SendSignal3" + Name() ) ) ) { StaticVarSet( "SendSignal3" + Name(), 1 ); } if ( ( StaticVarGet( "SendSignal3" + Name() ) == 1 ) & LastValue( Short11 ) & LastValue( Short ) ) { fh = fopen( "C:\\BTT_Exe\\config\\order" + ".SAV", "awr" ); if ( fh ) { fputs( "NSECM|Short Sell|CLI|VYV118|" + Name() + "|" + ShortPrice + "|" + Lotsizes + "|" + "SL|" + ( round( ( ShortPrice + ( ShortPrice*0.02 / 100 ) )*10 ) ) / 10 + "|" + "-|-|NL|Margin|08067|N|DAY|Short at|-|-|-|-|-|" + "\n", fh ); fputs( "NSECM|Buy to Cover|CLI|VYV118|" + Name() + "|" + shortStop + "|" + Lotsizes + "|" + "SL|" + ( round( ( Shortstop - ( ShortStop*0.03 / 100 ) )*10 ) ) / 10 + "|" + "-|-|NL|Margin|08067|N|DAY|ShortStop|-|-|-|-|-|" + "\n", fh ); fputs( "" + "\n", fh ); StaticVarSet( "SendSignal3" + Name() , 0 ); fclose( fh ); } } if ( IsEmpty( StaticVarGet( "SendSignal4" + Name() ) ) ) { StaticVarSet( "SendSignal4" + Name(), 1 ); } if ( ( StaticVarGet( "SendSignal4" + Name() ) == 1 ) & LastValue( Short11 ) & LastValue( Buy ) ) { fh = fopen( "C:\\BTT_Exe\\config\\order" + ".SAV", "awr" ); if ( fh ) { fputs( "NSECM|Buy|CLI|VYV118|" + Name() + "|" + BuyPrice + "|" + Lotsizeb + "|" + "SL|" + ( round( ( BuyPrice - ( BuyPrice*0.02 / 100 ) )*10 ) ) / 10 + "|" + "-|-|NL|Margin|08067|N|DAY|Long at|-|-|-|-|-|" + "\n", fh ); fputs( "NSECM|Sell|CLI|VYV118|" + Name() + "|" + BuyStop + "|" + Lotsizeb + "|" + "SL|" + ( round( ( BuyStop + ( BuyStop*0.03 / 100 ) )*10 ) ) / 10 + "|" + "-|-|NL|Margin|08067|N|DAY|BuyStop|-|-|-|-|-|" + "\n", fh ); fputs( "" + "\n", fh ); StaticVarSet( "SendSignal4" + Name() , 0 ); fclose( fh ); } } if ( IsEmpty( StaticVarGet( "SendSignal5" + Name() ) ) ) { StaticVarSet( "SendSignal5" + Name(), 1 ); } if ( ( StaticVarGet( "SendSignal5" + Name() ) == 1 ) & LastValue( Buy11 ) & LastValue( Short ) ) { fh = fopen( "C:\\BTT_Exe\\config\\order" + ".SAV", "awr" ); if ( fh ) { fputs( "NSECM|Short Sell|CLI|VYV118|" + Name() + "|" + ShortPrice + "|" + Lotsizes + "|" + "SL|" + ( round( ( ShortPrice + ( ShortPrice*0.02 / 100 ) )*10 ) ) / 10 + "|" + "-|-|NL|Margin|08067|N|DAY|Short at|-|-|-|-|-|" + "\n", fh ); fputs( "NSECM|Buy to Cover|CLI|VYV118|" + Name() + "|" + shortStop + "|" + Lotsizes + "|" + "SL|" + ( round( ( Shortstop - ( ShortStop*0.03 / 100 ) )*10 ) ) / 10 + "|" + "-|-|NL|Margin|08067|N|DAY|ShortStop|-|-|-|-|-|" + "\n", fh ); fputs( "" + "\n", fh ); StaticVarSet( "SendSignal5" + Name() , 0 ); fclose( fh ); } } //Filters Filter = Buy OR Short OR Buystop1 OR Shortstop1 OR Sell OR Cover;