-
Notifications
You must be signed in to change notification settings - Fork 0
/
explorer_onefile.afl
95 lines (83 loc) · 3.17 KB
/
explorer_onefile.afl
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
// user parameters
liquidityMinLimit = 1000000;
rsiRange = 14;
zigzagReverse = 12;
fastMAPeriod = 5;
slowMAPeriod = 10;
// filter by liquidity
liquidity = MA(Close * Volume, 21);
Filter = liquidity >= liquidityMinLimit;
// show tickers with 4-week high and 4-week low price
daysInFourWeeks = 28;
fourWeeksPriceExtremum = 0;
fourWeeksPriceExtremum = IIf(High >= HHV(High, daysInFourWeeks), 1, fourWeeksPriceExtremum);
fourWeeksPriceExtremum = IIf(Low <= LLV(Low, daysInFourWeeks), -1, fourWeeksPriceExtremum);
AddColumn(fourWeeksPriceExtremum, "4w Price Ext", 1.0);
// show tickers with 4-week high and 4-week low volume
fourWeeksVolumeExtremum = 0;
fourWeeksVolumeExtremum = IIf(Volume >= HHV(Volume, daysInFourWeeks), 1, fourWeeksVolumeExtremum);
fourWeeksVolumeExtremum = IIf(Volume <= LLV(Volume, daysInFourWeeks), -1, fourWeeksVolumeExtremum);
AddColumn(fourWeeksVolumeExtremum, "4w Volume Ext", 1.0);
// show tickers with all-time high and all-time low price
allTimePriceExtremum = 0;
allTimePriceExtremum = IIf(High >= Highest(High), 1, allTimePriceExtremum);
allTimePriceExtremum = IIf(Low <= Lowest(Low), -1, allTimePriceExtremum);
AddColumn(allTimePriceExtremum, "AllTime Price Ext", 1.0);
// show tickers with all-time high and all-time low volume
allTimeVolumeExtremum = 0;
allTimeVolumeExtremum = IIf(Volume >= Highest(Volume), 1, allTimeVolumeExtremum);
allTimeVolumeExtremum = IIf(Volume <= Lowest(Volume), -1, allTimeVolumeExtremum);
AddColumn(allTimeVolumeExtremum, "AllTime Volume Ext", 1.0);
// show tickers with RSI divergence
function Divrg(price, indicator, zigzagParam)
{
zigZags = Zig(indicator, zigzagParam);
peaks = Peak(indicator, zigzagParam, 1);
troughs = Trough(indicator, zigzagParam, 1);
peaksCounter = 0;
troughsCounter = 0;
zigzagPeaks[0] = zigZags[0];
zigzagTroughs[0] = zigZags[0];
priceAtPeaks[0] = price[0];
priceAtTroughs[0] = price[0];
ret = 0;
for (i = 0; i < BarCount; i++)
{
if(zigZags[i] == peaks[i])
{
peaksCounter++;
zigzagPeaks[peaksCounter] = zigZags[i];
priceAtPeaks[peaksCounter] = price[i];
if(priceAtPeaks[peaksCounter] > priceAtPeaks[peaksCounter-1] AND zigzagPeaks[peaksCounter] < zigzagPeaks[peaksCounter-1]) // bearish divergence
{
ret[i] = -1;
continue;
}
}
if(zigZags[i] == troughs[i])
{
troughsCounter++;
zigzagTroughs[troughsCounter] = zigZags[i];
priceAtTroughs[troughsCounter] = price[i];
if(priceAtTroughs[troughsCounter] < priceAtTroughs[troughsCounter-1] AND zigzagTroughs[troughsCounter] > zigzagTroughs[troughsCounter-1]) // bullish divergence
{
ret[i] = 1;
continue;
}
}
ret[i] = 0;
}
return ret;
}
indicatorName = "RSI";
indicatorValues = RSI(rsiRange);
indicatorZigZags = Zig(indicatorValues, zigzagReverse);
divrgs = Divrg(Close, indicatorValues, zigzagReverse);
AddColumn(divrgs, indicatorName + " Div", 1.0);
// show tickers with price between fast MA and slow MA
fastMA = MA(Close, fastMAPeriod);
slowMA = MA(Close, slowMAPeriod);
priceInValueArea = 0;
priceInValueArea = IIf(Close >= slowMA AND Close <= fastMA, 1, priceInValueArea);
priceInValueArea = IIf(Close <= slowMA AND Close >= fastMA, -1, priceInValueArea);
AddColumn(priceInValueArea, "Price Between MA", 1.0);