策略:做空1口 停損20 停利40,移動停損停利3次,但是第3層一直平不了倉,所以我加了print,發現1~12除了6和12皆可以正常平倉,為什麼6和12沒辦法平呢? 已苦惱2星期!
input: profit_point(40, "停利(點)");
input: loss_point(20, "停損(點)");
input: profit_point60(60, "停利(點)");
input: profit_point80(80, "停利(點)");
input: profit_point120(120, "停利(點)");
value1=1;
value2=2;
value3=3;
value4=4;
value5=5;
value6=6;
value7=7;
value8=8;
value9=9;
value10=10;
value11=11;
value12=12;
SetPosition(-1, MARKET); { 以市價買進 }
if Position = -1 then
begin print("",value1);
{ 依照成本價格設定停損/停利 }
if Close <= FilledAvgPrice - profit_point then //賺40點
begin print("",value2);
if Close <= FilledAvgPrice - profit_point80 then //第一筆賺40點後又賺40點
begin print("",value3);
if Close <= FilledAvgPrice - profit_point60 or Close <= FilledAvgPrice - profit_point120 then//再賺停利60、120。
begin print("",value4);
SetPosition(0);
end;
end
else if Close >= FilledAvgPrice - loss_point then //第一筆賺40點後虧20點
begin
print("",value5);
if Close <= FilledAvgPrice - profit_point60 or Close >= FilledAvgPrice then //停利60停損0
begin
SetPosition(0); print("",value6);
end;
end;
end
else
begin print("",value7);
if Close >= FilledAvgPrice + loss_point then //虧20點
begin print("",value8);
if Close >= FilledAvgPrice + profit_point then //第一筆虧20點再虧20點
begin print("",value9);
if Close >= FilledAvgPrice + profit_point60 or Close <= FilledAvgPrice then //停損-60停損0
begin print("",value10);
SetPosition(0);
end;
end
else if Close <= FilledAvgPrice - loss_point then//虧20點後賺40點
begin print("",value11);
if Close <= FilledAvgPrice - profit_point60 or Close >= FilledAvgPrice then //停利60停損0
begin
SetPosition(0); print("",value12);
end;
end;
end;
end;
end;
4 評論