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

Guupy MMA with pullback entries for Amibroker (AFL)
bambebo
about 11 years ago
Amibroker (AFL)

Rating:
3 / 5 (Votes 2)
Tags:
amibroker, stop loss, GMMA

This system uses Guppy MMAs and Connors RSI to identify pullbacks in an up/down trend. The exits are based on tightening stops based on specified targets. The Idea is to tighten the trailing stop once the profit target are achieved. The system is giving great results with EOD data. Target and Max Stop Optimization will be required for proper results in any type of Market and time frame.

Similar Indicators / Formulas

DODA BAND BUY SELL
Submitted by saas almost 12 years ago
JMA Stoploss
Submitted by kuzukapama over 13 years ago
TSL & HL & New
Submitted by morgen almost 13 years ago
Stop Loss Indicator
Submitted by nabcha almost 15 years ago
Profit Trailing Stoploss
Submitted by drpragnesh40 almost 12 years ago
ABKP Benchmark Bar
Submitted by amitabh almost 15 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
317
318
319
320
321
322
323
324
325
326
327
function ConnorsRSI(lenRSI, lenUD, lenROC)
{
      upDays = BarsSince(C <= Ref(C,-1));
      downDays = BarsSince(C >= Ref(C,-1));
      updownDays = IIf(upDays > 0, upDays, IIf(downDays > 0, -downDays, 0));
      crsi = ( PercentRank(ROC(C,1), lenROC) + RSIa(updownDays,lenUD) +
RSI(lenRSI))/3;
      return crsi;
}
 
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
ECw= EncodeColor(colorWhite);
ECy= EncodeColor(colorYellow);
_N(Title = ECw+ "Guppy MMA " +ECy+ StrFormat("- {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
ChikouPeriod = Param("Chikou Span Period",25,1,30,1);
Chikou=Ref(C,(-1 * ChikouPeriod));
Plot( C, "", IIf(Close > Open, colorBrightGreen, colorRed), styleCandle);
 Plot(Chikou,"Chikou Snan",colorViolet,styleLine);
_SECTION_END();
 
 
_SECTION_BEGIN("Fast Periods");
P1 = EMA(C,3);
P2 = EMA(C,5);
P3 = EMA(C,8);
P4 = EMA(C,10);
P5 = EMA(C,12);
P6 = EMA(C,15);
_SECTION_END();
 
_SECTION_BEGIN("Slow Periods");
P7 = EMA(C,30);
P8 = EMA(C,35);
P9 = EMA(C,40);
P10 = EMA(C,45);
P11 = EMA(C,50);
P12 = EMA(C,55);
P13 = EMA(C,60);
_SECTION_END();
 
_SECTION_BEGIN("Guppy MMA");
Plot(P7,"",colorOrange,styleDashed = 32);
Plot(P8,"",colorOrange,styleDashed = 32);
Plot(P9,"",colorOrange,styleDashed = 32);
Plot(P10,"",colorOrange,styleDashed = 32);
Plot(P11,"",colorOrange,styleDashed = 32);
Plot(P12,"",colorOrange,styleDashed = 32);
Plot(P13,"",colorOrange,styleDashed = 32);
 
Plot(P1,"",colorLightGrey,styleDashed = 32);
Plot(P2,"",colorLightGrey,styleDashed = 32);
Plot(P3,"",colorLightGrey,styleDashed = 32);
Plot(P4,"",colorLightGrey,styleDashed = 32);
Plot(P5,"",colorLightGrey,styleDashed = 32);
Plot(P6,"",colorLightGrey,styleDashed = 32);
_SECTION_END();
 
 
_SECTION_BEGIN("Signals");
crsi = ConnorsRSI(3,2,100);
Buy = p1 > p13 AND p13 > Ref(p13,-14) AND crsi < 20 AND C > Chikou;
Short = p1 < p13 AND p13 < Ref(p13,-14) AND crsi > 80 AND C < Chikou;
_SECTION_END();
 
 
_SECTION_BEGIN( "Exit Section" );
 
firstProfitTarget = Optimize("First Profit Target",2,0,10,1);
 
secondProfitTarget = Optimize("Second Profit Target",5,0,20,1);
 
MaxStop = Optimize("Max Stop",4,0,20,1);
 
Sell = 0;
Cover = 0;
 
stopLineColor = Null;
 
 
Multiple = Param( "Multiple", 3 ,1, 8, 1 ); // How many ATR’s to be allowed below the highest high since latest "buy" bar
ATRPeriods = Param( "ATR Periods", 11, 1, 50, 5 ); // How many periods to use for the ATR
 
Multiple1 = Param( "Multiple1", 1.1, 1, 6, 1 ); // How many ATR’s to be allowed below the highest high since latest "buy" bar
ATRPeriods1 = Param( "ATR Periods1", 11, 1, 50, 5 );
 
Multiple2 = Param( "Multiple2", 1, 0, 4, 1 ); // How many ATR’s to be allowed below the highest high since latest "buy" bar
ATRPeriods2 = Param( "ATR Periods2", 11, 1, 50, 5 );
Showtarget = ParamList ("Show Target Milestones ","Yes|No");
 
 
 
target2 = secondProfitTarget ;
 
target1 = firstProfitTarget ;
 
stopArray = Null;
stopArray1 = Null;
stopArray2 = Null;
atrArray = ATR( ATRPeriods );
atrArray1 = ATR( ATRPeriods1 );
atrArray2 = ATR( ATRPeriods2 );
HHArray = Null;
LLArray = Null;
exitArray = Null;
trendDirection = 0;
ShortPr = 0;
 
BuyPriceArr = 0;
ShortPriceArr = 0;
 
 
BuyPr = 0;
CancelBuy = False;
 
for ( i = 0; i < BarCount; i++ )
{
 
 ShortPriceArr[i] = ShortPr;
BuyPriceArr[i] = BuyPr;
 
    if ( Short[i] AND ShortPr ==0 )
    {
        // we just triggered a short trade. Set up starting values
        stopArray[i] = Low[i] + ( Multiple * atrArray[i] );
        LLArray[i] = C[i]; // initialize the lowest low array
        trendDirection = 0 - 1; // going short. Base bar.' 
         ShortPr = C[i];
         
    } else if(Short[i]) {
            Short[i] = 0;
        }
 
 if ( Buy[i] AND Buypr ==0)
    {
        // we just triggered a long trade. Set up starting values
        stopArray[i] = High[i] - ( Multiple * atrArray[i] );
 
        HHArray[i] = C[i]; // initialize the highest high array
        trendDirection = 1; // going long. Base bar flag is now set.
            Buypr = C[i];
    } else if(Buy[i]) {
        Buy[i] =0;
    }
 
 
    exitArray[i] = 0;
 
    if ( trendDirection > 0 )
    {
        // keep track of the highest high, highest close, highest low, etc..
        if ( trendDirection > 1 )
        {
            // We are in the trade (2nd day or later)
            if ( (C[i] <= stopArray[i-1] AND (C[i] >=  BuyPr)) OR C[i] <= BuyPr * (1-MaxStop/100))
            {
                //stop got hit. Reset the trade.
                trendDirection = 0; // OK. wait until we trigger another trade.
                    Buypr = 0;
                    FIRstTargetHit = 0;
                exitArray[i] = 1;
                    Sell[i] = 1;
            }
            else
            {
                // keep track of the HHV since trade was entered.
                if ( C[i] > HHArray[i-1] )
                    HHArray[i] = C[i];
                else
                    HHArray[i] = HHArray[i-1];
 
                // Compute the stop based on the HHV.
            if(HHArray[i] >=  (target2/100 + 1) * BuyPr) {
                stopArray[i] = HHArray[i] - ( Multiple2 * atrArray2[i] );
                stopLineColor[i]=colorBlue;
            } else if(HHArray[i] >=  (target1/100 + 1) * BuyPr) {
                stopArray[i] = HHArray[i] - ( Multiple1 * atrArray1[i] );
                stopLineColor[i]=colorYellow;
                FIRstTargetHit = 1;
            } else {
                stopArray[i] = HHArray[i] - ( Multiple * atrArray[i] );
                stopLineColor[i] = colorRed;
            }
         }
        }
 
        trendDirection = trendDirection + 1;
    }
 
    if ( trendDirection < 0 )
    {
        // keep track of the lowest low, lowest close, lowest high, etc..
        if ( trendDirection < 0 - 1 )
        {
            // We are in the trade (2nd day or later)
            if ( (C[i] > stopArray[i-1] AND (C[i] <=  ShortPr  )) OR C[i] >= ShortPr * (1+MaxStop/100))
            {
                // our stop got hit. Reset the trade.
                trendDirection = 0;
                    Shortpr = 0;
                    FIRstTargetHit = 0;
                exitArray[i] = 0 - 1;
                    Cover[i] = 1;
            }
            else
            {
                // keep track of the LLV since trade was entered.
                if ( C[i] < LLArray[i-1] )
                    LLArray[i] = C[i];
                else
                    LLArray[i] = LLArray[i-1];
 
// Compute the stop based on the LLV.
              
        if(LLArray[i] <=  (1 - target2/100) * ShortPr) {
            stopArray[i] = LLArray[i] + ( Multiple2 * atrArray2[i] );
            stopLineColor[i]=colorBlue;
            FIRstTargetHit = 1;
 
        } else if(LLArray[i] <=  (1 - target1/100) * ShortPr) {
            stopArray[i] = LLArray[i] + ( Multiple1 * atrArray1[i] );
            FIRstTargetHit = 1;
            stopLineColor[i]=colorYellow;
 
        } else {
            stopArray[i] = LLArray[i] + ( Multiple * atrArray[i] );
            stopLineColor[i] = colorRed;
        }
 
            }
        }
 
        trendDirection = trendDirection - 1;
    }
 
    if ( trendDirection == 0 )
    {
CancelBuy = False;
FIRstTargetHit = 0;
        stopArray[i] = 0;
        LLArray[i] = 0;
        HHArray[i] = 0;
Buypr=0;
ShortPr = 0;
    }
 
 
}
 
 
 
printf("------values-----");
printf("\nBuy Price = " + BuyPriceArr);
printf("\nShort Price = " + ShortPriceArr);
PlotShapes( abs( exitArray )*shapeHollowCircle, colorYellow, 0, ValueWhen( stopArray, stopArray, 1 ), 0 );
Plot( stopArray, "StopLine", stopLineColor, styleNoRescale + styleThick);
 
r = Hour();
e = Minute();
timestr = NumToStr( r, 1.0, False ) + ":" + NumToStr(e,1.0,False);
 
bp = ValueWhen(Buy,C,1);
sp = ValueWhen(Sell,C,1);
bh = ValueWhen(Buy,r,1);
bm = ValueWhen(Buy,e,1);
sh = ValueWhen(Sell,r,1);
sm = ValueWhen(Sell,e,1);
 
ShortPr = ValueWhen(Short,C,1);
CoverPr = ValueWhen(Cover,C,1);
ShortH =  ValueWhen(Short,r,1);
ShortM = ValueWhen(Short,e,1);
CoverH = ValueWhen(Cover,r,1);
CoverM = ValueWhen(Cover,e,1);
 
 
 
 
Hd = sh - bh;
md = (hd*60) + (sm - bm);
 
shd = Shorth - Coverh;
smd = (shd*60) + (shortm - Coverm);
 
 
timestr = NumToStr( r, 1.0, False ) + ":" + NumToStr(e,1.0,False);
 
 
pf = sp - bp;
spf = ShortPr - CoverPr;
 
buyMsg = "BUY " + Name() + " on " + Date()  + " for price " + NumToStr(bp, 1.2 );
SellMsg = "SELL " + Name() + " on " + Date()  + " for price " + NumToStr(sp, 1.2 )+ ". Profit in last trade is " + NumToStr(pf,1.2) + ". Total trade time was " + md + " minutes";
ShortMsg = "Short " + Name() + " on " + Date()  + " for price " + NumToStr(ShortPr, 1.2 );
CoverMsg = "Cover " + Name() + " on " + Date()  + " for price " + NumToStr(CoverPr, 1.2 )+ ". Profit in last trade is " + NumToStr(spf,1.2) + ". Total trade time was " + smd + " minutes";
sendNotf = ParamToggle("Send Notifications","NO|YES",0);
 
 
for (i=1;i<BarCount;i++)
{
if(Sell[i]) {
PlotText(WriteVal(pf[i]),i,H[i]+2*ATRarray[i],colorYellow);
}  
else if(Cover[i]) {
PlotText(WriteVal(spf[i]),i,L[i]+2*ATRarray[i],colorYellow);
}
}
 
PlotShapes( Buy*shapeUpArrow, colorBrightGreen, 0, Low );
PlotShapes( Sell*shapeDownArrow, colorRed, 0, High );
 
 
PlotShapes( Short*shapeDownTriangle, colorBrightGreen, 0, High );
PlotShapes( Cover*shapeUpTriangle, colorRed, 0, Low );
 
/*
 
if(sendNotf) {
AlertIf( Buy, "EXEC C:\\Misc\\pushbullet\\pyPushBullet-master\\pyPushBullet-master\\push.bat", BuyMsg, 1,1+2+4+8);
AlertIf( Sell, "EXEC C:\\Misc\\pushbullet\\pyPushBullet-master\\pyPushBullet-master\\push.bat", SellMsg, 2,1+2+4+8 );
AlertIf( Short, "EXEC C:\\Misc\\pushbullet\\pyPushBullet-master\\pyPushBullet-master\\push.bat", ShortMsg, 3,1+2+4+8);
AlertIf( Cover, "EXEC C:\\Misc\\pushbullet\\pyPushBullet-master\\pyPushBullet-master\\push.bat", CoverMsg, 4,1+2+4+8 );
}
 
*/
 
_SECTION_END();

1 comments

1. alcatrank

Error

Leave Comment

Please login here to leave a comment.

Back