-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTrading-Algo.c
45 lines (37 loc) · 976 Bytes
/
Trading-Algo.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
function run()
{
StartDate = 20220101;
EndDate = 20230101;
LookBack = 300;
asset("EUR/USD");
set(LOGFILE, PLOTNOW);
vars Prices = series(priceClose());
vars slowma = series(MovingAverage(Prices, 200, MAType_SMA));
vars fastma = series(MovingAverage(Prices, 50, MAType_SMA));
vars TrendIndicator = series(LowPass(Prices, 300));
vars MMI_Indicator_Raw = series(MMI(Prices, 300));
vars MMI_Indicator_Smooth = series(LowPass(MMI_Indicator_Raw, 300));
if(valley(TrendIndicator))
{
enterLong();
}
else if(peak(TrendIndicator))
{
enterShort();
}
if(crossOver(fastma, slowma))
{
enterLong();
}
else if(crossUnder(fastma, slowma))
{
enterShort();
}
PlotWidth = 1200;
PlotScale = 10;
plot("Fast MA", fastma, LINE, RED);
plot("slowma MA", slowma, LINE, BLUE);
plot("Low pass", TrendIndicator, LINE + NEW, ORANGE);
plot("MMI Raw data", MMI_Indicator_Raw, LINE + NEW, GREY);
plot("MMI overall trend", MMI_Indicator_Smooth, LINE, GREEN);
}