Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

2 Day Break Out for Amibroker (AFL)

Rating:
4 / 5 (Votes 4)
Tags:
trading system, amibroker

This uses two day break out system including the current day. The breakout is warned before the actual breakout and traders can position accordingly. Date to scan can be configured through parameters so that the symbols which dont have live feeds will not be reflected in the current days scan.

Similar Indicators / Formulas

All in One
Submitted by Nahid over 14 years ago
Kase Peak Osc. V2 batu
Submitted by batu1453 over 10 years ago
Kase CD V2batu
Submitted by batu1453 over 10 years ago
Ichimoku
Submitted by prashantrdx over 10 years ago
Arvind' System
Submitted by akdabc over 14 years ago
Miftha remix for dse
Submitted by coolpace over 14 years ago

Indicator / Formula

Copy & Paste Friendly
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
_SECTION_BEGIN("Shiv2daybrkOut");
 
SetChartOptions(0,chartShowArrows|chartShowDates);
 
 
LClose = Close;
 
// Calculations for Buy and Sell Signals
 
DC1=TimeFrameGetPrice( "C", inDaily, -1);
DC2=TimeFrameGetPrice( "C", inDaily, -2);
DH1=TimeFrameGetPrice( "H", inDaily, -1);
DH2=TimeFrameGetPrice( "H", inDaily, -2);
DL1=TimeFrameGetPrice( "L", inDaily, -1);
DL2=TimeFrameGetPrice( "L", inDaily, -2);
DO1=TimeFrameGetPrice( "O", inDaily, -1);
DO2=TimeFrameGetPrice( "O", inDaily, -2);
MaxH=Max(DH1,DH2);
MinL=Min(DL1,DL2);
 
Plot(MaxH,"2 Day High",colorGreen,styleLine);
Plot(MinL,"2 Day Low",colorRed,styleLine);
 
Plot_Range1 = (TimeNum() >= 091500 AND TimeNum()<= 153000) AND (DateNum()==LastValue(DateNum()));
 
mf = Param("Percentage",0.5,0.1,5,0.1);
 
wDay = Param("Scan Day",LastValue(Day()),1,31,1);
 
ORhigh = MaxH*(1-mf/100);
ORlow = MinL*(1+mf/100);
 
BreakOut = IIf(LClose>=ORhigh, LClose, 0);
breakDown = IIf(LClose<=ORlow, LClose, 0);
 
COL=IIf(BreakOut,colorGreen,IIf(breakDOWN,colorRed,Null));
Plot(C,"",COL,64);
 
//_SECTION_BEGIN("Volume");
Plot( Volume, _DEFAULT_NAME(), ParamColor("Color", colorLavender ), styleNoTitle | ParamStyle( "Style", styleHistogram | styleOwnScale | styleThick | styleNoLabel, maskHistogram  ), 2 );
//_SECTION_END();
 
 
//vr=ParamToggle("Plot Daily High/Low","Yes|No" ,1);
//if(VR  == 0)
//{
//Plot(FourDayHigh,"High Breakout", ParamColor("Hi Color",colorBlue));
//Plot(FourDayLow,"Low Breakout", ParamColor("Low Color",colorRed));
//Plot(ORHigh,"ORH", ParamColor("ORHi Color",colorBlue),32);
//Plot(ORLow,"ORL", ParamColor("ORLow Color",colorRed),32);
//Plot(P,"PIVOT", ParamColor("P Color",colorTan),8);
//Plot(R1,"", ParamColor("R1 Color",colorGreen),1);
//Plot(R2,"", ParamColor("R2 Color",colorGreen),1);
//Plot(S1,"", ParamColor("S1 Color",colorLightOrange),1);
//Plot(S2,"", ParamColor("S2 Color",colorLightOrange),1);
//}
 
//Bprice=IIf(Buy,LClose,0); //Buying Price
//Sprice=IIf(Sell,LClose,0); //Selling Price
 
// Output of Exploration results and Alert of Buy and Sell Signals and Plotting of breakout and breakdown levels
//AddColumn(Bprice,"Buy price");
//AddColumn(BTarget1,"BT 1");
//AddColumn(BTarget2,"BT 2");
//AddColumn(sprice,"Sell price");
//AddColumn(STarget1,"ST 1");
//AddColumn(STarget2,"ST 2");
 
/*AddColumn(LClose,"CMP");
AddColumn(TwoDayHigh,"New High",1.2,colorDefault,colorDefault,90);
AddColumn(TwoDayLow,"New Low",1.2,colorDefault,colorDefault,90);
AddColumn(TodayHigh,"Today High",1.2,colorDefault,colorDefault,90);
AddColumn(TodayLow,"Today Low",1.2,colorDefault,colorDefault,90);
AddColumn(P,"Pivot",1.2,colorDefault,colorDefault,90);
AddColumn(ORHigh,"OR High",1.2,colorDefault,colorDefault,90);
AddColumn(ORLow,"OR Low",1.2,colorDefault,colorDefault,90);
AddColumn(Now(format=4),"Time Now",1.2,colorDefault,colorDefault,90);
AddColumn(TimeNum(),"Time Then",1.2,colorDefault,colorDefault,90);
AddColumn(Now(format=4)-TimeNum(),"Diff",1.2,colorDefault,colorDefault,90);*/
 
//AlertIf(Buy,"","Buy " + Name() + " above " + FourDayHigh + ", CMP: " + C + ", SL " + Prec(P,2) + ", Targets " + Prec(BTarget1,2) +","+Prec(BTarget2,2) + "," +Prec(BTarget3,2), 1);
//AlertIf(Sell,"","Sell " + Name() + " below " + FourDayLow + ", CMP: " + C + ", SL " + Prec(P,2) + ", Targets " + Prec(STarget1,2) +","+Prec(STarget2,2) + "," +Prec(STarget3,2), 2);
 
//Title = EncodeColor(colorBlue)+ "Two Day BreakOut( "+mf+")%" + " - " +  Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorBlue) +
// "  - " + Date() +" - "+"\n" +EncodeColor(colorGreen) +"Op-"+O+"  "+"Hi-"+H+"  "+"Lo-"+L+"  "+
//"Cl-"+C+"  "+ "Vol= "+ WriteVal(V)+"\n"+EncodeColor(colorDarkRed) +"-----------------------------system says----------------------------------------"+"\n";
//EncodeColor(colorDarkGreen)+
//WriteIf (Buy , "GO LONG / cover  at ="+C+"\n"+EncodeColor(colorRed) +"Stop- toadys low ="+DL+"\n"+
//EncodeColor(colorDarkRed));
//WriteIf (Short ,"EXIT LONG / short  at "+C+"\n"+EncodeColor(colorRed) +"Stop-todays high "+DH+"\n");
_SECTION_END();
 
 
//**************************************************************************************************************************************//
 
_SECTION_BEGIN("ATR Intraday Swing Trade");
 
period = Param("Period", 20, 1, 240, 1);
mult = Param("Multiplier",3.3 , 1, 240, 0.1);
 
 
// ATR Trading for 5 Minutes //
 
TimeFrameSet(in5Minute);
 
f=ATR(period);
 
VS[0] = Close[0];
trend[0] = 0;
HighC[0]=0;
Lowc[0]=0;
 
for( i = period+1; i < BarCount; i++ )
{
 
vs[i] = vs[i-1];
trend[i] = trend[i-1];
highC[i] = HighC[i-1];
lowc[i] = lowc[i-1];
 
if ((trend[i]>=0) && ( C[i] <VS[i] ))
{
trend[i] =-1;
HighC[i] = C[i];
lowc[i] = C[i];
}
 
if ((trend[i]<=0) && (C[i] >VS[i]))
{
trend[i]=1;
HighC[i] = C[i];
lowc[i] = C[i];
}
 
if (trend[i]==-1)
{
if (C[i]<lowc[i]) lowc[i] = C[i];
VS[i]= lowc[i]+ (mult*f[i]);
}
 
 
if (trend[i]==1)
{
if (C[i]>HighC[i]) HighC[i] = C[i];
VS[i]= HighC[i]-(mult*f[i]);
}
 
}
 
TimeFrameRestore();
 
 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
_SECTION_BEGIN("default");
TimeFrameSet(inHourly);
HaClose =EMA((O+H+L+C)/4,6);
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
TimeFrameRestore();
HAopenf=TimeFrameExpand( Haopen, inHourly); 
Haclosef=TimeFrameExpand( Haclose, inHourly);
HaHighf=TimeFrameExpand( Hahigh, inHourly);
HaLowf=TimeFrameExpand( Halow, inHourly);
Color = IIf( Haopenf > Haclosef,4, IIf( Haopenf == Haclosef,colorYellow, 6));
_SECTION_END();
 
_SECTION_BEGIN("4");
Compress4= Param("Compression4",6,1,12,1);
TimeFrameSet(Compress4* Interval());
HaClose4 =EMA((O+H+L+C)/4,6);
HaOpen4 = AMA( Ref( HaClose4, -1 ), 0.5 );
HaHigh4 = Max( H, Max( HaClose4, HaOpen4 ) );
HaLow4 = Min( L, Min( HaClose4, HaOpen4 ) );
TimeFrameRestore();
HAopen4f=TimeFrameExpand( Haopen4, Compress4* Interval()); 
Haclose4f=TimeFrameExpand( Haclose4, Compress4* Interval());
HaHigh4f=TimeFrameExpand( Hahigh4, Compress4* Interval());
HaLow4f=TimeFrameExpand( Halow4, Compress4* Interval());
Color4 = IIf( Haopen4f > Haclose4f,4, IIf( Haopen4f == Haclose4f ,colorYellow, 6));
_SECTION_END();
 
_SECTION_BEGIN("5minute");
TimeFrameSet(in5Minute);
HaClose5 =EMA((O+H+L+C)/4,6);
HaOpen5 = AMA( Ref( HaClose5, -1 ), 0.5 );
HaHigh5 = Max( H, Max( HaClose5, HaOpen5 ) );
HaLow5 = Min( L, Min( HaClose5, HaOpen5 ) );
TimeFrameRestore();
HAopen5f=TimeFrameExpand( Haopen5, in5Minute); 
Haclose5f=TimeFrameExpand( Haclose5, in5Minute);
HaHigh5f=TimeFrameExpand( Hahigh5, in5Minute);
HaLow5f=TimeFrameExpand( Halow5, in5Minute);
Color5 = IIf( Haopen5f > Haclose5f,colorRed, IIf( Haopen5f == Haclose5f,colorYellow, colorGreen));
_SECTION_END();
 
Plot(VS, "Stop Loss",IIf(trend==1,10,11 ),styleThick);
 
mkol = IIf( Trend==1, colorGreen, colorRed);
 
Plot(2,"", Color5, styleOwnScale|styleArea|styleNoLabel, -0.5, 100);
Plot(2,"", Color4, styleHistogram+styleThick|styleOwnScale|styleNoLabel, -2, 100 );
Plot(2,"", Color,  styleOwnScale|styleArea|styleNoLabel, -4, 100 );
 
//Title = EncodeColor(colorBlue)+"Shiv Intraday ATR Trading System :-"+"  "+ Name() + "  "+ EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorBlue) +
// " - " + Date() + "    MACD : "+ MACD() + ",   Signal : " + Signal() + "Current : " + LongExit +"," + ShortExit +"\n" +
//"Buy : "+ValueWhen(Buy,Close,1)+"   Sell : "+ValueWhen(Short,Close,1) +"  Signals : " + LongPrice + "  " + ShrtPrice +
//EncodeColor(colorRed)+
//WriteIf (Buy , " GO LONG at "+C+"  ","")+
//WriteIf (Sell , " EXIT LONG / Reverse Signal at "+C+"  ","")+
//WriteIf (Short , " GO SHORT at "+C+"  ","")+
//WriteIf (Cover , " EXIT SHORT / Reverse Signal at "+C+"  ","")+"\n"+EncodeColor(colorBlue)+
//WriteIf(Buy , "Total Profit/Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+
//WriteIf(Short  , "Total Profit/Loss for the Last trade Rs."+(ShortPrice-C)+"","")+
//WriteIf(Long AND NOT Buy, "Trade : Long - Entry price Rs."+(BuyPrice),"")+
//WriteIf(shrt AND NOT Short, "Trade : Short - Entry price Rs."+(ShortPrice),"")+"\n"+
//WriteIf(Long AND NOT Buy, "Current Profit/Loss Rs."+(C-BuyPrice)+"","")+
//WriteIf(Shrt AND NOT Short, "Current Profit/Loss Rs."+(ShortPrice-C)+"","");
_SECTION_END();
 
/////////////////////////////////           Trend Indicator on Background  ////////////////////////////////////////
 
function ZeroLagTEMA( array, period )
{
 TMA1 = TEMA( array, period );
 TMA2 = TEMA( TMA1, period );
 Diff = TMA1 - TMA2;
 return TMA1 + Diff ;
}
  
/////////////////////
// Heikin-Ashi code
HaClose = (O+H+L+C)/4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
  
avp = Param("Up TEMA avg", 34, 1, 100 );
avpdn = Param("Dn TEMA avg", 34, 1, 100 );
  
// Velvoort is using not original, but modified Heikin-Ashi close
HaClose = ( HaClose + HaOpen + Max( H, HaOpen ) + Min( L, HaOpen ) )/4;
  
// up average
ZlHa = ZeroLagTEMA( HaClose, avp );
ZlCl = ZeroLagTEMA( ( H + L ) / 2, avp );
ZlDif = ZlCl - ZlHa;
  
keep1 = Hold( HaClose >= HaOpen, 2 );
keep2 = ZlDif >= 0;
keeping = keep1 OR keep2;
keepall = keeping OR ( Ref( keeping, -1 ) AND ( C > O ) OR C >= Ref( C, -1 ) );
keep3 = abs( C - O ) < ( H - L ) * 0.35 AND H >= Ref( L, -1 );
utr = keepall OR ( Ref( keepall, -1 ) AND keep3 );
  
// dn average
ZlHa = ZeroLagTEMA( HaClose, avpdn );
ZlCl = ZeroLagTEMA( ( H + L ) / 2, avpdn );
ZlDif = ZlCl - ZlHa;
  
keep1 = Hold( HaClose < HaOpen, 2 );
keep2 = ZlDif < 0;
keeping = keep1 OR keep2;
keepall = keeping OR ( Ref( keeping, -1 ) AND ( C < O ) OR C < Ref( C, -1 ) );
keep3 = abs( C - O ) < ( H - L ) * 0.35 AND L <= Ref( H, -1 );
dtr = keepall OR ( Ref( keepall, -1 ) AND keep3 );
  
upw = dtr == 0 AND Ref( dtr, -1 ) AND utr;
dnw = utr == 0 AND Ref( utr, -1 ) AND dtr;
  
Haco = Flip( upw, dnw );
 
if( ParamToggle("Trend Indicator in Background ?", "Yes / No"))
{
if( ParamToggle("Chart Type", "Price with color back|HACO wave" ) )
{
 Plot( Haco, "Haco", colorRed );
}
else
{
 //Plot( C, "Close", colorBlack,
   //    ParamStyle( "Style", styleCandle, maskPrice ) );
 Plot( 1, "", IIf( Haco , colorPaleGreen, colorRose ),styleArea | styleOwnScale, 0, 1 );
}
}
else
{
Plot( C, "Close", colorBlack,ParamStyle( "Style", styleCandle, maskPrice ) );
}
 
// ****************************************************       Buy & Sell           *************************************
 
Buy = (LClose >= MaxH) AND (LClose > VS) AND LastValue(Day())==wDay;
Short =(LClose <= MinL) AND (LClose < VS) AND LastValue(Day())==wDay;
 
// Calculation of Stop Loss and Exit points
BuyPrice=ValueWhen(Buy,C,1);
ShortPrice=ValueWhen(Short,C,1);
BuyExit=BuyPrice*(1-1/100);
ShortExit=ShortPrice*(1+1/100);
 
Sell = (LClose < VS);
Cover = (LClose > VS);
 
Buy=ExRem(Buy, Sell);
Sell=ExRem(Sell, Buy);
Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);
 
PlotShapes(Buy*shapeUpArrow,5,0,L,-15);
PlotShapes(Sell*shapeHollowDownArrow,5,0,H,-15);
PlotShapes(Short*shapeDownArrow,4,0,H,-15);
PlotShapes(Cover*shapeHollowUpArrow,4,0,L,-15);
 
Filter=Buy OR Short OR Sell OR Cover;
AddColumn(IIf(Buy,66,43),"New Trade Bar", formatChar, colorWhite, bkcolor =IIf(Buy, colorGreen,2));
AddColumn(IIf(Short,83,43),"New Trade Bar", formatChar, colorWhite, bkcolor =IIf(Short, colorRed,2));

1 comments

1. bishwajit

plz show the screen shot

Leave Comment

Please login here to leave a comment.

Back