有沒有高手可以幫忙把這個自動交易(多單)邏輯改(空單)呢?
//下單數量
input: _quantity(1,"單次下單數量");
//--------------------------------------------
//規則
//--------------------------------------------
if close[3] > open[3] and close[2] > open[2] and close[1] < open[1]
then begin
condition1= true;
end;
//--------------------------------------------
//進出場
//--------------------------------------------
var: red_low(0); //進場紅K開盤價
var:red_low_time(0);
//多單
if position = 0 and Filled = 0 //and GetInfo("IsRealTime") = 1
and condition1 = true
and close > open
then begin
SetPosition( _quantity*1, MARKET,label:="多單進場") ;
red_low = open ;
red_low_time = time;
Print(file("C:\SysJust\XQLite\XS\Print\"),NumToStr(date,0),NumToStr(time,0),"《",SymbolName,"》","多單進場","成本",NumToStr(FilledAvgPrice,0),"部位",NumToStr(position,0),"filledfilled",filled);
print(file("C:\SysJust\XQLite\XS\Print\"),"時間:",NumToStr(time,0),"《",SymbolName,"》","進場紅K開盤價",red_low,"red_low_time",red_low_time);
end;
//--------------------------------------------
//停損
//--------------------------------------------
input: loss_out(1, "是否啟動自動停損", inputkind:= Dict(["是",1], ["否",0]));
//多單停損
if red_low > 0
and position > 0 and filled > 0
and close < red_low
and loss_out = 1
then begin
SetPosition( 0, market,label:="多單市價停損") ;
Print(file("C:\SysJust\XQLite\XS\Print\"),NumToStr(date,0),NumToStr(time,0),"《",SymbolName,"》","多單市價停損","成本",NumToStr(FilledAvgPrice,0),"filledfilled",filled);
//condition1= false ;
end;
//-------------------------------------------------
//變數歸0
//-------------------------------------------------
if filledAvgPrice = 0
then begin
condition1= false ;
//red_low = 0;
//red_low_time = 0;
end;
//-------------------------------------------------
//測試LOG
//-------------------------------------------------
{
print(date,time,condition1,"部位",NumToStr(position,0),"Filled",Filled,"red_low",red_low);
1.jpg?width=690&upscale=false)
5 評論