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

divergence 85% success rate Avg profit 1.45% for Amibroker (AFL)

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
// ********************************************
// INDICATOR    :DIVERGENCE
// DATE     :07-30-04
// PROGRAMMER   :M.Lauronen
// COPYRIGHTS   :Public Domain
// ********************************************
 
// --------------------------------------------
// Recommended AmiBroker indicator settings:
//      Level 0
//      Percent
//      Middle
//      Scaling: Custom 0 - 100
// --------------------------------------------
 
// Adjust the following parameters to suit your needs
// Adjust the following parameters to suit your needs
 
//period = Param("% change",0.4,0.1,25,0.1);
//period    = 5;
uplimit=2;
uplimit=IIf(Interval()==in15Minute,4,IIf(Interval()==inHourly,8,
                                IIf(Interval()==inDaily,12,uplimit)));
i=uplimit;
globalTitile=" ";
BuyCond  =ShortCond=False;
divergenceCount=0;
highCount=0.0;
 
for(;i>=0.2;){
numChg = i ;
i=i-0.1;
// --------------------------------------------
// Divergence for LONG
// --------------------------------------------
 
trendMom    = RSI(5);
 
periods = 5;
Ksmooth = 3;
trendStoch=StochK( periods , Ksmooth); 
 
bull=High - EMA(Close,13);
bear=Low - EMA(Close,13);
bb=bull+bear;
 
 
Hist=MACD(12,26)-Signal(12,26,9);
 
FI = (Close - Ref(Close, -1)) * V;
 
 
trendZig    = Zig(L, numChg);
 
 
f   = trendZig > Ref(trendZig, -1) AND Ref(trendZig, -1) < Ref(trendZig, -2);
 
p1  = ValueWhen(f, Ref(trendZig, -1), 1);
p2  = ValueWhen(f, Ref(trendZig, -1), 2);
r1  = ValueWhen(f, Ref(trendMom,-1), 1);
r2  = ValueWhen(f, Ref(trendMom,-1), 2);
stockUp1= ValueWhen(f, Ref(trendStoch,-1), 1);
stockUp2= ValueWhen(f, Ref(trendStoch,-1), 2);
bbUP1= ValueWhen(f, Ref(bb,-1), 1);
bbUP2= ValueWhen(f, Ref(bb,-1), 2);
HistUP1= ValueWhen(f, Ref(Hist,-1), 1);
HistUP2= ValueWhen(f, Ref(Hist,-1), 2);
FIUP1= ValueWhen(f, Ref(FI,-1), 1);
FIUP2= ValueWhen(f, Ref(FI,-1), 2);
 
 
f   = r1 > r2 AND p1 < p2;
fStoch=stockUp1 > stockUp2 AND p1 < p2;
fbb=bbUP1> bbUP2 AND p1 < p2;
HistUP=HistUP1> HistUP2 AND p1 < p2;
FIUP= FIUP1 > FIUP2 AND p1 < p2;
 
sigRSI  = f AND NOT Ref(f, -1) AND trendMom > Ref(trendMom, -1);
sigStockUp  = fStoch AND NOT Ref(fStoch, -1) AND trendStoch > Ref(trendStoch, -1);
sigbbUp = fbb AND NOT Ref(fbb, -1) AND bb> Ref(bb, -1);
HistSigUP   = HistUP AND NOT Ref(HistUP , -1) AND Hist> Ref(Hist, -1);
FISigUP     = FIUP AND NOT Ref(FIUP, -1) AND FI> Ref(FI, -1);
 
//_N(str = "(" + period + ")");
///Plot(trendMom, "RSI" + str, colorWhite);
Plot(trendZig, "zig", colorBlack,styleOwnScale);
Plot(sigRSI* 100, "RsiSigUp", colorGreen, styleHistogram + styleThick + styleNoLabel);
Plot(sigStockUp* 100, "StockSigUp", colorGreen, styleHistogram + styleThick + styleNoLabel);
Plot(sigbbUp* 100, "bbUp", colorGreen, styleHistogram + styleThick + styleNoLabel);
Plot(HistSigUP * 100, "MACDUp", colorGreen, styleHistogram + styleThick + styleNoLabel);
Plot(FISigUP * 100, "FIUP", colorGreen, styleHistogram + styleThick + styleNoLabel);
 
 
 
// --------------------------------------------
// Divergence for SHORT
// --------------------------------------------
 
trendZig2   = Zig(H, numChg);
 
f   = trendZig2 < Ref(trendZig2, -1) AND Ref(trendZig2, -1) > Ref(trendZig2, -2);
 
p1  = ValueWhen(f, Ref(trendZig2, -1), 1);
p2  = ValueWhen(f, Ref(trendZig2, -1), 2);
r1  = ValueWhen(f, Ref(trendMom,-1), 1);
r2  = ValueWhen(f, Ref(trendMom,-1), 2);
stockDown1= ValueWhen(f, Ref(trendStoch,-1), 1);
stockDown2= ValueWhen(f, Ref(trendStoch,-1), 2);
bbDown1= ValueWhen(f, Ref(bb,-1), 1);
bbDown2= ValueWhen(f, Ref(bb,-1), 2);
HistDown1= ValueWhen(f, Ref(Hist,-1), 1);
HistDown2= ValueWhen(f, Ref(Hist,-1), 2);
FIDown1= ValueWhen(f, Ref(FI,-1), 1);
FIDown2= ValueWhen(f, Ref(FI,-1), 2);
 
 
 
f   = r1 < r2 AND p1 > p2;
fStoch=stockDown1 < stockDown2 AND p1 > p2;
fbb=bbDown1 < bbDown2 AND p1 > p2;
HistDown=HistDown1< HistDown2 AND p1 > p2;
FIDown= FIDown1 < FIDown2 AND p1 > p2;
 
sigRSIDown  = f AND NOT Ref(f, -1) AND trendMom < Ref(trendMom, -1);
sigStock    = fStoch AND NOT Ref(fStoch, -1) AND trendStoch < Ref(trendStoch, -1);
sigbbDown   = fbb AND NOT Ref(fbb, -1) AND bb < Ref(bb, -1);
HistSigDown     = HistDown AND NOT Ref(HistDown , -1) AND Hist< Ref(Hist, -1);
FISigDown   = FIDown AND NOT Ref(FIDown, -1) AND FI< Ref(FI, -1);
 
//_N(str = "(" + period + ")");
Plot(sigRSIDown* 100, "rsiSigDown", colorRed, styleHistogram + styleThick + styleNoLabel);
Plot(sigStock* 100, "StockSigDown", colorRed, styleHistogram + styleThick + styleNoLabel);
Plot(sigbbDown* 100, "bbDown", colorRed, styleHistogram + styleThick + styleNoLabel);
Plot(HistSigDown * 100, "MAcdDown", colorRed, styleHistogram + styleThick + styleNoLabel);
Plot(FISigDown* 100, "FIDown", colorRed, styleHistogram + styleThick + styleNoLabel);
 
 
divergenceCount+=IIf(sigRSI,1,0) + IIf(FISigUP,1,0)+
                     IIf(sigStockUp ,1,0)+ IIf(sigbbUp ,1,0)+  IIf(HistSigUp ,1,0);
 
divergenceCount+=IIf(sigRSIDown ,1,0) + IIf(sigStock ,1,0)+
                     IIf(sigbbDown ,1,0)+ IIf(HistSigDown ,1,0)+  IIf(FISigDown,1,0);
 
 
 
BuyCondTmp=sigRSI OR sigStockUp OR  sigbbUp OR HistSigUp OR  FISigUP;
ShortCondTmp=sigRSIDown OR sigStock OR sigbbDown OR HistSigDown OR FISigDown;
highCount+=IIf(BuyCondTmp OR ShortCondTmp,numChg,0.0);
 
BuyCond = BuyCond OR BuyCondTmp ;
BuyCond=BuyCond AND (highCount>10);
ShortCond= ShortCond OR ShortCondTmp;
ShortCond=ShortCond AND (highCount>10); 
 
 
 
globalTitile+=WriteIf(BuyCondTmp OR ShortCondTmp ,""+i,"")+
 
        WriteIf(sigRSI,"rsiup ","")+WriteIf(sigStockUp,"stochup ","")+WriteIf(sigbbUp,"bbup ","")
        +WriteIf(HistSigUP ,"macdup ","")+ WriteIf(FISigUP,"FIUP ","")
 
 
 
        +WriteIf(sigRSIDown ,"rsiDown ","")+WriteIf(sigStock ,"stochDown ","")+WriteIf(sigbbDown,"bbDown ","")
        +WriteIf(HistSigDown ,"macdDown ","")+ WriteIf(FISigDown,"FIDown ","")
        + WriteIf(BuyCondTmp OR ShortCondTmp ,"\n","");
         
 
 
 
 
 
} //for
 
Title=globalTitile;
 
 
 
FirstTradeTime = 091500;                // Earliest time to take a trade
LastTradeTime = 151500;                 // Latest time to take new trades
ExitAllPositionsTime = 151500; 
//change = Param("% change",0.1,0.1,25,0.1);
z = Zig(Close, 0.8 );
 
Buy=(BuyCond )  ;//AND (TimeNum() >= FirstTradeTime AND TimeNum() <= LastTradeTime );
Sell = IIf(z < Ref(z, -1), 1, 0) ;//  OR TimeNum() > ExitAllPositionsTime;
Short=(ShortCond ) ;//AND (TimeNum() >= FirstTradeTime AND TimeNum() <= LastTradeTime );
Cover = IIf(z > Ref(z, -1), 1, 0) ;//OR   TimeNum() > ExitAllPositionsTime;
  
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);
 
 
Filter=BuyCond OR ShortCond;
//Filter=Filter AND (TimeNum()>091500 AND TimeNum()<100000);
 
 
AddColumn(BuyCond,"DiverBuy");
AddColumn(ShortCond,"DiverSell");
AddColumn(divergenceCount,"no of diver");
AddColumn(highCount,"high");
//AddTextColumn(globalTitile,"indicators");
//AddColumn(StrLen(globalTitile),"StrLen",1);
 
 
        
Back