void main() { Sleep(10000); Log(exchange.GetAccount()); while (1) { if (exchange.IO("status") == 1) { exchange.SetContractType(Symbol); auto ticker = exchange.GetTicker(); auto position = exchange.GetPosition(); auto orders = exchange.GetOrders(); if ((position.size() > 0) && !(orders.size() > 0)) { if (!position[0].Type) { if (position[0].Profit > 200 || position[0].Profit < -70) { exchange.SetContractType(Symbol); exchange.SetDirection("closebuy_today"); exchange.Sell(ticker.Buy - 10, 1); Sleep(500); } } if (position[0].Type) { if (position[0].Profit > 200 || position[0].Profit < -70) { exchange.SetContractType(Symbol); exchange.SetDirection("closesell_today"); exchange.Buy(ticker.Sell + 10, 1); Sleep(500); } } } else if(!(orders.size() > 0)) { auto records = exchange.GetRecords(60 * 20); auto records1 = exchange.GetRecords(60 * 20 * 5); auto r = exchange.GetRecords(60); auto ma = TA.MA(r, 20); auto a = ma[ma.size() - 1]; auto r1 = exchange.GetRecords(60); auto ma1 = TA.MA(r1, 120); auto c = ma1[ma1.size() - 1]; /* double a = 0, b = 0; int c = 0; a = records[records.size() - 1].High - records[records.size() - 1].Low; b = records1[records1.size() - 1].High - records1[records1.size() - 1].Low; c = (int)(a * 100 / b); */ if (a > c && ticker.Sell > records[records.size() - 1].High - 3) { exchange.SetContractType(Symbol); exchange.SetDirection("buy"); exchange.Buy((ticker.Buy + 10), 1); Sleep(500); } else if (a < c && ticker.Buy < (records[records.size() - 1].Low + 3)) { exchange.SetContractType(Symbol); exchange.SetDirection("sell"); exchange.Sell((ticker.Sell - 10), 1); Sleep(500); } } } else { LogStatus(_D(), "未连接CTP !"); Sleep(1000); } } }
孟大壮 有实盘吗