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

Ekeko price chart for Amibroker (AFL)

Rating:
3 / 5 (Votes 4)
Tags:
amibroker, exploration, sar

More opt for 5 minute scalping

Screenshots

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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
//////////////////// PRECIO //////////////////////////////////////////////
 
Plot(C,"",colorBlack,styleCandle|styleNoLabel);
 
Filter = Close > 10;
AddColumn(Close,"Close");
 
PositionSize = 100;
 
/////////////////////// MEDIAS MOVILES///////////////////
 
slope = Param("slope",2,2,100,1);
Color20= IIf(LinRegSlope(MA(C,20),slope)<0,colorRed,colorBrightGreen);
event1= LinRegSlope(MA(C,20),slope)<0;
Plot( MA( C,  20), "",Color20 , styleLine);
//Plot( event1, "", colorRose, styleArea|styleOwnScale);
Color50= IIf(LinRegSlope(MA(C,50),slope)<0,colorRed,colorBlue);
Plot( MA( C, 50), "",Color50  , styleLine);
Color100= IIf(LinRegSlope(MA(C,100),slope)<0,colorRed,colorYellow);
Plot( MA( C,  100), "",Color100 , styleLine);
Color150= IIf(LinRegSlope(MA(C,150),slope)<0,colorRed,10);
Plot( MA( C, 150), "",Color150  , styleLine);
 
event1=Cross(MA(C,20),MA(C,50));
PlotShapes( IIf(event1 ,shapeDigit1,0) ,5, 0, L,-30);
 
event2=Cross(MA(C,50),MA(C,100));
PlotShapes( IIf(event2 ,shapeDigit2,0) ,6, 0, L,-30);
 
event3=Cross(MA(C,100),MA(C,150));
PlotShapes( IIf(event3 ,shapeDigit3,0) ,7, 0, L,-30);
 
event4=Cross(MA(C,50),MA(C,20));
PlotShapes( IIf(event4 ,shapeDigit4,0) ,5, 0, H,30);
 
event5=Cross(MA(C,100),MA(C,50));
PlotShapes( IIf(event5 ,shapeDigit5,0) ,6, 0, H,30);
 
event6=Cross(MA(C,150),MA(C,100));
PlotShapes( IIf(event6 ,shapeDigit6,0) ,7, 0, H,30);
 
event7=Cross(MA(C,5),MA(C,20));
PlotShapes( IIf(event7 ,shapeDigit7,0) ,9, 0, L,-30);
 
 
//////////////////////////////////MACD///////////////////////////////////
 
MACDRequired=1;
FAST = Param("FAST",12,0,100,1);
SLOW = Param("SLOW",26,0,100,1);
SIG  = Param("SIG",9,0,100,1);
 
MACDLine   = MACD(FAST,SLOW);
MACDSignal = Signal(FAST,SLOW,SIG);
MACDHisto  = MACDLine - MACDSignal;
 
MIN10=   Param("X MACD10", 5,1,30,step=0.1);
MIN60=   Param("X MACD60",10,1,30,step=0.1);
MACDBACKBARS=Param("Lookback MACD",1,1,30,step=1);
 
MinDir=      Param("DirChange",0.6,-5,5,step=0.01);
NOEXCESS=    Param("Remove Excess Signals",1,0,1,step=1);
 
if(Interval() <= 600 ) MACDRequired=MIN10;  // 10 minute +/-5 extreme
if(Interval() >= 3600) MACDRequired=MIN60;  // 60 minute +/- 10
 
/////////////////// HISTOGRAMA ////////////////////////////////
 
MACDHisto  = MACDLine - MACDSignal;
 
HistDivUp = Cross(LinRegSlope(MACDHisto,3),0);
HistDivDn = Cross(0,LinRegSlope(MACDHisto,3));
 
HBuy  = HistDivUp ;
HSell = HistDivDn ;
 
 
PlotShapes( IIf(HBuy ,3,0) ,colorBlue, 0,Graph0,-22 );
PlotShapes( IIf(HSell,4,0) ,colorYellow, 0,Graph0,-22);
 
 
//////////////////////       AROON       //////////////////////////////////
 
Period = Param("Aroon Period",14,1,100,1);
LLVBarsSince = LLVBars(L, Period) + 1;
HHVBarsSince = HHVBars(H, Period) + 1;
 
AD = 100 * (Period - LLVBarsSince) / (Period - 1);
AU   = 100 * (Period - HHVBarsSince) / (Period - 1);
AO  = AU - AD;
 
MINAROONOSC= Param("AO  ",45,0,100,step=0.1);
MINAROONSIG= Param("AV ",99.9,0,100,step=0.1);
 
MINAROONOSC= Optimize("Aroon Osc  ",MINAROONOSC,0,100,step=1);
MINAROONSIG= Optimize("Aroon Value",MINAROONSIG,0,100,step=1);
 
event1 =Cross(MINAROONSIG,AD) AND AO <= -MINAROONOSC;
event2=Cross(MINAROONSIG,AU)   AND AO >=  MINAROONOSC;
 
// Include MACD / Signal Cross
AroonMACD=MACD() >= Signal();
event3=Cross(MINAROONSIG,AU)   AND AO >=  MINAROONOSC AND AroonMACD > 0;
event4 =Cross(MINAROONSIG,AD) AND AO <= -MINAROONOSC ;
//if(AroonBuy[BarCount-1]) PlotShapes( ( AroonBuy OR AroonSell )+5 ,IIf( AroonBuy, colorPaleGreen, colorPink ), 0 );
event5=Cross(AO,0);
event6= Cross(0,AO);
 
event7=Cross(AO,-50);
event8= Cross(0,AO);
 
event9= Cross(AU,AD);
event10=Cross(AD,AU);
 
//Plot(AU  ,"AU" ,colorBrightGreen,styleLine);
//Plot(AD,"AD" ,colorRed  ,styleLine);
//Plot(AO ,"Osc",colorBlack,styleLine+styleOwnScale);
 
AroonBuy= event9;
AroonSell=event10;
 
PlotShapes( IIf(AroonBuy ,5,0) ,colorBlue, 0,L);
PlotShapes( IIf(AroonSell,6,0) ,colorYellow, 0,H);
 
 
////////////////////////////////   DMI //////////////////////////////////
 
MACDLine   = MACD(FAST,SLOW);
 
range=Param("R ADX ",14,1,50,step=1);
//Prefs(49);
 
MINADX=      Param("X ADX ",30,1,50,step=0.1);
ADXBACKBARS= Param("LB ADX",3,1,30,step=1);
 
 
// Find the direction of ADX
ADXTipDirA  = LinRegSlope(ADX(range),2);  // Short term direction change
ADXTipDir   = LinRegSlope(ADXTipDirA*4,3);    // Short term direction change
ADXFastDir = LinRegSlope(ADX(range),3);  // Medium
ADXSlowDir = LinRegSlope(ADX(range),6);  // Longer
 
// Direction *CHANGE* of ADX at the 'extremes'
ADXSlopeUp = Cross(ADXTipDir,0) AND ADX(range)<20;
ADXSlopeDn = Cross(0,ADXTipDir) AND ADX(range)>MINADX;
ADXHistory = ADX(range);
 
ADXBuy1 =  ADXFastDir >0 AND ADX(range)> 20 AND ( PDI(range)>MDI(range)) AND MACDLine > 0;//TrendUp
 
ADXSell2 =  ADXFastDir >0 AND ADX(range)> 20 AND ( MDI(range)>PDI(range)) AND MACDLine < 0; //TrendDown
 
ADXBuy3=  ADXSlowDir >0; //AND ADX(range)< 20 AND ( PDI(range)>MDI(range));//WarnUp
 
ADXSell4=  ADXSlowDir >0; //AND ADX(range)< 20 AND ( MDI(range)>PDI(range));//WarnDn 
 
 
ADXBuy5=ADX(range)>MDI(range) AND MDI(range)>30;//MDIX
ADXSell6=ADX(range)>PDI(range) AND PDI(range)>30;//PDIX
 
ADXBuy7  = BarsSince(ADXTipDir<MinDIR)<BarsSince(ADXBuy1)+ADXBACKBARS AND ADX(range)>MINADX;
ADXSell8 = BarsSince(ADXTipDir<MinDIR)<BarsSince(ADXSell6)+ADXBACKBARS AND ADX(range)>MINADX;
 
ADXBuy9  = BarsSince(MACDLine < -MACDRequired)<MACDBACKBARS ;  // AND HistDivUp;
ADXSell10 = BarsSince(MACDLine >  MACDRequired)<MACDBACKBARS;  //  AND HistDivDn;
 
ADXBuy11  = ADXBuy5 AND ADXSlopeDn;
ADXSell12 = ADXSell6 AND ADXSlopeDn;
 
ADXBuy13  = ADXBuy5 AND ADXTipDir<0 AND Peak(ADXHistory,0.5,1)>ADX(range); //AND ADXSlopeDn;
ADXSell14 = ADXSell6 AND ADXTipDir<0 AND Peak(ADXHistory,0.5,1)>ADX(range); //AND ADXSlopeDn;
 
ADXBuy15  = ADXBuy5 AND ADXTipDir<0 AND ADXHistory[BarCount-10]<ADX(range); //AND ADXSlopeDn;
ADXSell16 = ADXSell6 AND ADXTipDir<0 AND ADXHistory[BarCount-10]<ADX(range); //AND ADXSlopeDn;
 
ADXBuy17  = ADXBuy5 AND ADXSlopeDn;
 
ADXBuy18=Cross(PDI(range),MDI(range));
ADXSell19=Cross(MDI(range),PDI(range));
 
ADXBuy=ADXBuy18;
ADXSell=ADXSell19;
 
// Remove excess Buy/Sell Signals from ADX Based Signals
if(NOEXCESS) ADXBuy  = ExRemSpan( ADXBuy, 5);
if(NOEXCESS) ADXSell = ExRemSpan( ADXSell, 5);
 
 
PlotShapes( IIf(ADXBuy ,5,0) ,colorBlack, 0);
PlotShapes( IIf(ADXSell,6,0) ,colorWhite, 0);
 
 
//////////////////////  BOLLINGER BANDS ///////////////////////
 
TopBand = BBandTop(Close, 20, 2);
LowBand = BBandBot(Close, 20, 2);
 
dirup= (BarsSince(Low<LowBand)<5);
dirdn= (BarsSince(High>TopBand)<5);
 
BBBuy=0;
BBSell=0;
 
///////////////////// ORDEN DE COMPRA ////////////////////////////////////
 
//Buy = AroonBuy;
//Sell = AroonSell;
 
// Remove excess Buy/Sell Signals
 
//Short = Sell;
//Cover = Buy;
 
//if(NOEXCESS) Buy  = ExRemSpan( Buy, 1 );
//if(NOEXCESS) Sell = ExRemSpan( Sell, 1 );
 
//PlotShapes( IIf(Buy ,1,0) ,colorBlue, 0,Graph0,-18 );
//PlotShapes( IIf(Sell,2,0) ,colorYellow, 0,Graph0,-18 );
 
//////////////////REGRESION LINEAL ///////////////////////////////////
 
LookBack=Param("Lookback (RegressionChannel)",72,1,300);
 
NH = LastValue(HHVBars(High,LookBack));   // lookback period  - can be set by the user if necessary
NL = LastValue(LLVBars(Low ,LookBack));   // lookback period  - can be set by the user if necessary
 
N=0;
if(NL>NH) { N=NL; } else { N=NH; }
  
Start = 1;
 
X = Cum(Start);    // Set up the x cordinate array of the Linear Regression Line
Y = Close;         // Set the y co-ordinate of the Linear Regression line   
 
/* Calculate the slope (bconst) and the y intercept (aconst) of the line */
 
SUMX    = LastValue(Sum(X,N));
SUMY    = LastValue(Sum(Y,N));
SUMXY   = LastValue(Sum(X*Y,N));
SUMXSqd = LastValue(Sum(X*X,N));
SUMSqdX = LastValue(SUMX * SUMX);
 
bconst  = (N * SUMXY - SUMX * SUMY)/(N * SUMXSqd - SUMSqdX);
aconst  = (SUMY - bconst * (SUMX))/N;
 
/* Force the x value to be very negative so the graph does not apear before the
lookback period */
 
Domain =  IIf ( X > LastValue(X) - N, 1 , -1e10);  
Xvar = X * Domain;
 
/* Linear Regression Line */
 
Yvar = aconst + bconst * Xvar;
 
Plot(Yvar + LastValue(HHV(High - Yvar,N)),"Upper Channel",colorWhite,styleLine|styleNoLabel);
Plot(Yvar,"Middle Channel",colorWhite,styleLine|styleNoLabel);
Plot(Yvar - LastValue(HHV(Yvar - Low ,N)),"Lower Channel",colorWhite,styleLine|styleNoLabel);
 
 
 
/////////////////   SAR ////////////////////////////////////////////////
 
IAF = 0.02;       // acceleration factor
MaxAF = 0.2;     // max acceleration
 
psar = Close;       // initialize
long = 1;        // assume long for initial conditions
af = IAF;         // init acelleration factor
ep = Low[ 0 ];   // init extreme point
hp = High [ 0 ];
lp = Low [ 0 ];
 
for( i = 2; i < BarCount; i++ )
{
    if ( long )
    {
        psar [ i ] = psar [ i-1 ] + af * ( hp - psar [ i-1 ] );
    }
    else
    {
        psar [ i ] = psar [ i-1 ] + af * ( lp - psar [ i-1 ] );
    }
 
    reverse =  0;
    //check for reversal
    if ( long )
    {
        if ( Low [ i ] < psar [ i ]  )
        {
            long = 0; reverse = 1; // reverse position to Short
            psar [ i ] =  hp;       // SAR is High point in prev trade
            lp = Low [ i ];
            af = IAF;
        }
    }
    else
    {
        if ( High [ i ] > psar [ i ]  )
        {
            long = 1; reverse = 1;        //reverse position to long
            psar [ i ] =  lp;
            hp = High [ i ];
            af = IAF;
        }
    }
 
    if ( reverse == 0 )
    {
        if ( long )
        {
            if ( High [ i ] > hp )
            {
                hp = High [ i ];
                af = af + IAF;
                if( af > MaxAF ) af = MaxAF;
            }
              
            if( Low[ i - 1 ] < psar[ i ] ) psar[ i ] = Low[ i - 1 ];
            if( Low[ i - 2 ] < psar[ i ] ) psar[ i ] = Low[ i - 2 ];
        }
       else
        {
            if ( Low [ i ] < lp ) 
            {
                lp = Low [ i ];
                af = af + IAF;
                if( af > MaxAF ) af = MaxAF;
            }  
                 
            if( High[ i - 1 ] > psar[ i ] ) psar[ i ] = High[ i - 1 ];
            if( High[ i - 2 ] > psar[ i ] ) psar[ i ] = High[ i - 2 ];
 
        }
    }
}
 
Plot( psar, "SAR", colorSkyblue, styleDots | styleNoLine | styleThick );
 
 
 
 
///////////// COMENTARIOS DE INTERPRETACION ///////////////////
 
if( SelectedValue(ADXBuy1) OR SelectedValue(ADXSell2))
{
 if( SelectedValue(ADXBuy1)) { printf("We're in a uptrend."); };
 if( SelectedValue(ADXSell2)) { printf("We're in a downtrend."); };
}
else
{
 printf("Falling ADX - watch for MACD Histogram Divergence");
 if(SelectedValue(HistDivUp)) printf("(currently UP)");
 if(SelectedValue(HistDivDn)) printf("(currently DOWN)");
}
 
if( SelectedValue(ADXFastDir)>0 )
{
 if(SelectedValue(ADXBuy5)) printf("Wait for retest of low, and then ADX turn down");
 if(SelectedValue(ADXSell6)) printf("Wait for retest of high, and then ADX turn down");
}
 
 
WriteIf( BBBuy   ,"Bollinger Buy Signal  (usually good until 20EMA)","");
WriteIf( BBSell  ,"Bollinger Sell Signal (usually good until 20EMA)","");
 
WriteIf( ADXBuy3 ,"Watch out - could be a beginning uptrend.","");
WriteIf( ADXSell4 ,"Watch out - could be a beginning downtrend.","");
 
WriteIf( ADXBuy1 AND MACDLine <  1 AND HistDivDn, "*WARNING* Trend could fail to begin !","");
WriteIf( ADXSell2 AND MACDLine > -1 AND HistDivUp, "*WARNING* Trend could fail to begin !","");
 
 
WriteIf( ADX(range) < 20 , "Trading range, weak direction - watch for Histogram Divergences","");
 
 
WriteIf( True ," ------- DEBUG -------","");
WriteIf( HistDivUp  ,"Histogram divergence up  ","Hup wait");
WriteIf( HistDivDn  ,"Histogram divergence down","Hdn wait");
WriteIf( ADXSlopeUp  ,"ADX Up ","Aup wait");
WriteIf( ADXSlopeDn  ,"ADX Dn ","Adn wait");
WriteIf( MDI(range)>30  ,"MDI","DMI wait");
WriteIf( PDI(range)>30  ,"PDI","DMI wait");
WriteIf( ADXBuy5 ,"MDI-X","DMI wait");
WriteIf( ADXSell6 ,"PDI-X","DMI wait");

1 comments

1. herlinamanalu

error..

Leave Comment

Please login here to leave a comment.

Back