教授小編您好
我在台指日盤下面寫法可以停損然後隔日再進場
但如果在夜盤不知道是不卡換日問題,不管怎麼修改停損後都會立即進場
我需要的是跟日盤一樣,在夜盤過程中如果停損就停止進場隔天夜盤開啟再進場
能不能給我個範本或建議去調整
var: intrabarpersist grid_started(false);
var: intrabarpersist grid_base(0);
var: intrabarpersist grid_current_base(0);
var: intrabarpersist grid_current_ord(0);
var: intrabarpersist allow_grid_today(false);
var: intrabarpersist stoploss_date(0); // ★ 記錄停損發生日
{========================
初始化(只跑一次)
========================}
if not grid_started and GetInfo("TradeMode") = 1 then begin
grid_started = true;
if Position > 0 then
grid_base = FilledAvgPrice
else
grid_base = Close;
grid_current_base = grid_base;
grid_current_ord = 0;
allow_grid_today = true;
stoploss_date = 0;
end;
{========================
每個交易日都重新判斷是否允許進場
========================}
if Date <> stoploss_date then begin
if Position <= 0
then allow_grid_today = true
else allow_grid_today = false;
end
else begin
allow_grid_today = false;
end;
{========================
停損(只影響當天) ← ★ 用平均成本停損
========================}
if Position > 0 and Close <= FilledAvgPrice - stoploss_point then begin
SetPosition(0, Market, label:="停損");
stoploss_date = Date;
end;
if time < timein then begin
if Position = 0 and allow_grid_today then begin
SetPosition(1, Market, label:="空手進場");
grid_base = Close;
grid_current_base = Close;
grid_current_ord = 0;
end;
6 評論