condition1=value2>=差值 and h[0]>=h[1](這部分過前一高加上value2滿足我的條件)
condition2=value1<=-差值 and l[0]<=l[1](低前低加上value1滿足條件)
if time>=開始時間 and time<=停止時間 then
if marketposition=0 then
if condition1 then buy this bar at market end if
if condition2 then sell this bar at market end if
end if
if marketposition=1 then
if condition2 then sell 2 contracts this bar at market end if
end if
if marketposition=-1 then
if condition1 then buy 2 contracts this bar at market end if
end if
If MarketPosition = 1 Then StopLossAmount = 停損 + Commission_B OrderPrice = Entryprice(0) - (StopLossAmount / PointValue) ExitLong ("多停損") this Bar at OrderPrice Stop
End if
If MarketPosition = -1 Then StopLossAmount = 停損 + Commission_S OrderPrice = EntryPrice(0) + (StopLossAmount/ PointValue) ExitShort ("空停損") this Bar at OrderPrice Stop
End if
If MarketPosition = 1 Then StoplossAmount = 停利 + Commission_B OrderPrice = Entryprice(0) + (StoplossAmount / PointValue) ExitLong ("多停利") this Bar OrderPrice limit End if
If MarketPosition = -1 Then StoplossAmount = 停利 + Commission_S OrderPrice = EntryPrice(0) - (StoplossAmount/ PointValue) ExitShort ("空停利") this Bar OrderPrice limit End if
end if
if time>=終止時間 then
if marketposition <> 0 then
exitlong next bar at market exitshort next bar at market
end if end if
if LastBarOnChart and MOD(Q_Time, 2) <> 0 then FileDelete("C:\HTS_TEMP\cur_cmd.txt") FileAppend("C:\HTS_TEMP\cur_cmd.txt", cdate(date) + " " + ctime(time)+" 1 F TXF 0 "+ NumToStr(CurrentContracts,0) +" "+NumToStr(close,0)) end if