- 策略广场
- 随机指标
随机指标
Author:
量价时空, Date: 2020-07-19 22:24:25
Tags:
void main() {
Sleep(10000);
Log(exchange.GetAccount());
while (1) {
if (exchange.IO("status") == 1) {
exchange.SetContractType(Symbol);
auto r = exchange.GetRecords(300);
auto kdj = TA.KDJ(r, 9, 3, 3);
auto a1 = kdj[0][kdj[0].size() - 2];
auto a2 = kdj[0][kdj[0].size() - 3];
auto b1 = kdj[1][kdj[1].size() - 2];
auto b2 = kdj[1][kdj[1].size() - 3];
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 >l || position[0].Profit<-k ){
exchange.SetContractType(Symbol);
exchange.SetDirection("closebuy_today");
exchange.Sell(ticker.Sell - 100, 1);
}
}
if (position[0].Type) {
if(position[0].Profit >l || position[0].Profit<-k){
exchange.SetContractType(Symbol);
exchange.SetDirection("closesell_today");
exchange.Buy(ticker.Buy + 100, 1);
}
}
} else if( !(orders.size() > 0)) {
auto position1 = exchange.GetPosition();
auto ticker = exchange.GetTicker();
if (!(position1.size() > 0)){
if (b1>a1 && b2<a2 ) {
exchange.SetContractType(Symbol);
exchange.SetDirection("sell");
exchange.Sell(ticker.Sell - 100, 1);
continue;
} else if (b1<a1 && b2>a2 ) {
exchange.SetContractType(Symbol);
exchange.SetDirection("buy");
exchange.Buy(ticker.Buy + 100, 1);
continue;
}
}
}
} else {
LogStatus(_D(), "未连接CTP !");
Sleep(1000);
}
}
}
template: strategy.tpl:40:21: executing "strategy.tpl" at <.api.GetStrategyListByName>: wrong number of args for GetStrategyListByName: want 7 got 6