聚沙成塔ING

MarketPosition  只能顯示多單 無單 和空單  沒辦法顯示現況內有幾口
MarketPosition  =1 有多單
MarketPosition  =0 無單
MarketPosition  =-1 有多單

CurrentContracts  只能顯示有幾口單,沒辦法顯示多單還是空單
CurrentContracts  =10 表示有10口單.但不知道是多單憨是空單
所以有時在程式中要作加減碼動作的時候,就必須知道此時倉內有幾口多單還是空單 ?
舉的例子 :
//假設條件一買進,二 成立時加碼買進

if MarketPosition  =0 and condition1 then 
buy("Buy1") next bar on market
end if
if MarketPosition  *  CurrentContracts  >=1 and condition2 then
buy("Buy2") next bar on market
end if

//假設條件三成立時 出一口多單 , 條件四成立時出掉全部

if MarketPosition  *  CurrentContracts  >0 and condition1 then 
exitlong("ExitBuy") next bar on market
end if
if MarketPosition  *  CurrentContracts  >0 and condition2 then
exitlong("AllExit") all contracts next bar at market
end if

其實重點是在於,將MarketPosition  *  CurrentContracts   這樣就可以知道倉內現在有幾口多單,
還是幾口空單了!

Posted by Picasa
arrow
arrow
    全站熱搜

    阿唐 發表在 痞客邦 留言(0) 人氣()