請問XQ小幫手,
同根K棒內 進場, 停利出場後 , 如何控制同根K棒不再進場
input: profit_point(30, "停利(點)"),loss_point(30, "停損(點)"), Length1(6), Length2(12);
var: long_condition(false),short_condition(false);
value1=RSI(Close, Length1);
value2=RSI(Close, Length2);
long_condition = value1 cross Above value2 ;
short_condition = value1 cross under value2 ;
if (position <= 0 and filled <= 0) and long_condition then begin
SetPosition(1, MARKET,label:="穿越作多");{ 以市價買進 }
end;
{ 依照成本價格設定停損/停利 }
if position > 0 and filled > 0 then begin
if profit_point > 0 and Close >= FilledAvgPrice + profit_point then begin
{ 停利 }
SetPosition(0, MARKET,label:="多單停利");
end else if loss_point > 0 and Close <= FilledAvgPrice - loss_point then begin
{ 停損 }
SetPosition(0, MARKET,label:="多單停損");
end;
end;
if ( position >= 0 and filled >= 0) and short_condition then begin
SetPosition(-1, MARKET,label:="跌破作空");{ 以市價賣出 }
end;
{ 依照成本價格設定停損/停利: 請注意當作空時, 判斷是否獲利的方向要改變 }
if position < 0 and filled < 0 then begin
if profit_point > 0 and Close <= FilledAvgPrice - profit_point then begin
{ 停利 }
SetPosition(0, MARKET,label:="空單停利");
end else if loss_point > 0 and Close >= FilledAvgPrice + loss_point then begin
{ 停損 }
SetPosition(0, MARKET,label:="空單停損");
end;
end;
1 評論