-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathStrat_Luxor.c
72 lines (61 loc) · 2.17 KB
/
Strat_Luxor.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
63
64
65
66
67
68
69
70
71
72
#define SYMBOLS "AUD/USD","USD/JPY","USD/CAD","GBP/USD","EUR/USD"
function run()
{
//StartDate = 2004;
// set(PARAMETERS+FACTORS);
NumYears = 2;
BarPeriod = 15;
LookBack = 80*4*24;
Capital = 50000;
//Margin = OptimalF * (Capital + sqrt(ProfitClosed));
// Margin = 0.02*(Capital + sqrt(ProfitClosed));
Margin = 0.02*Capital;
while(asset(loop(SYMBOLS)))
while(algo(loop("H1","H4")))
{
if(is(INITRUN)){
AlgoVar[0]=0;
AlgoVar[1]=0;
AlgoVar[2]=0;
AlgoVar[3]=0;
}
TimeFrame = 1;
if(Algo == "H1") TimeFrame = 4;
else if(Algo == "H4") TimeFrame = 4*4;
vars Price = series(priceClose());
var dFast=2;//optimize(2,1,10);
var dSlow=18;//optimize(18,18,60);
var dMulF=2;//optimize(2,1,10);
var dMulS=5;//optimize(4,4,16);
var dSignal=19;//optimize(9,9,27);
vars Fast = series(MACD(Price,dFast,dFast*dMulF,dSignal));
vars Slow = series(MACD(Price,dSlow,dSlow*dMulS,dSignal));
var BuyLimit=AlgoVar[0], SellLimit=AlgoVar[1], BuyStop=AlgoVar[2], SellStop=AlgoVar[3];
var dStop=2;//optimize(1.5,1,5);
var dLimit=3;//optimize(3,2,10);
if(crossOver(Fast,Slow)) {
BuyStop = priceHigh() + 1*PIP;
// BuyStop = priceHigh() + dStop*ATRS(9);
BuyLimit = priceHigh() + 5*PIP;
// BuyLimit = priceHigh() + dLimit*ATRS(27);
}
if(crossUnder(Fast,Slow)) {
SellStop = priceLow() - 1*PIP;
// SellStop = priceLow() - dStop*ATRS(9);
SellLimit = priceLow() - 5*PIP;
// SellLimit = priceLow() - dLimit*ATRS(27);
}
TakeProfit = ATRS(90); // *optimize(3,3,10)
Stop = ATRS(60); // *optimize(3,3,10)
if(!NumOpenLong && Fast[0] > Slow[0] && Price[0] < BuyLimit )
enterLong(0,BuyStop);
if(!NumOpenShort && Fast[0] < Slow[0] && Price[0] > SellLimit )
enterShort(0,SellStop);
AlgoVar[0]=BuyLimit;
AlgoVar[1]=SellLimit;
AlgoVar[2]=BuyStop;
AlgoVar[3]=SellStop;
}
//PlotWidth = 1000;
//set(PLOTNOW);
}