-
Notifications
You must be signed in to change notification settings - Fork 4
/
Strat_London_Breakout.c
62 lines (51 loc) · 1.58 KB
/
Strat_London_Breakout.c
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
function run()
{
StartDate = 20170101;
EndDate = 20181231;
BarPeriod = 10;
LookBack = 100;
asset("EUR/USD");
vars Price = series(price());
vars Highs = series(priceHigh());
vars Lows = series(priceLow());
int fracTime = 7; //short term ...
var fHigh = FractalHigh(Highs, fracTime); // ... highs and ...
var fLow = FractalLow(Lows, fracTime); // ... lows
static var longEntry, shortEntry; // Static is important
if(fHigh != 0 or fLow != 0)
{
shortEntry = Lows[0];
longEntry = Highs[0];
}
MaxLong = MaxShort = 1;
Spread = Commission = Slippage = RollLong = RollShort = 0;
EntryTime = 3;
ExitTime = 12;
Stop = 4*ATR(40);
Trail = Stop;
static var fHighCurrent, fLowCurrent; // Static is important
if(fHigh != 0) fHighCurrent = fHigh;
if(fLow != 0) fLowCurrent = fLow;
vars trendFilter = series(LowPass(Price, 100));
if(lhour(WET) >= 8 and lhour(WET) <= 17 // London Session
and between(priceClose(0), fLowCurrent, fHighCurrent))
{
if (Price[0] > trendFilter[0])
{
Entry = longEntry; // go long on recent high
enterLong();
}
if (Price[0] < trendFilter[0])
{
Entry = shortEntry;
enterShort();
}
}
set(PLOTNOW);
setf(PlotMode, PL_FINE);
PlotBars = 400; // number of bars to plot in the chart. Default - all
ColorDD = ColorEquity = 0; // don't plot Equty and drawdowns
plot("Recent High", fHighCurrent, MAIN|DOT, BLUE);
plot("Recent Low", fLowCurrent, MAIN|DOT, RED);
plot("LowPass", trendFilter, MAIN, GREEN);
}