本帖最後由 JimmyHK 於 15-10-24 13:00 編輯
先謝謝大家幫忙!現打算用上述布林值語法寫個比較複雜的策略,舉個例,如果收市價跌破10MA那麼不執行原先的Trigger,到收市價升破10MA才執行,應該寫成:
inputs: Price(Close), Length( 10 ),......................;
variables: var0( 0 ),var1( false ) ,.........................;
var0 = AverageFC( Price,Length ) ; ................................................;
if Close < var0 then var1 = false else if Close > var0 then var1 = true;
condition1 = var1 and................................... ; if condition1 then
Sellshort ( "MASE" ) next bar at market ;
不過再加上如果收市價跌破20MA那麼那麼不執行原先的Trigger,到收市價升破20MA才執行,是否應該寫成:
inputs: Price(Close), Length1( 10 ),Length2( 20 ),......................;
variables: var0( 0 ) ,var1( 0 ) ,var2( false ) ,.........................;
var0 = AverageFC( Price,Length1 ) ; var1= AverageFC( Price,Length2 ) ; ................................................;
if Close < var0 then var2 = false else if Close > var0 then var2= true ;
End else if Close > var1 then
var2= false
else if Close > var1 then var2= true ;
condition1 = var2 and................................... ; if condition1 then
Sellshort ( "MASE" ) next bar at market ;
還是應該是這樣:
inputs: Price(Close), Length1( 10 ),Length2( 20 ),......................;
variables: var0( 0 ) ,var1( 0 ) ,var2( false ) ,var3( false ) ,.........................;
var0 = AverageFC( Price,Length1 ) ; var1= AverageFC( Price,Length2 ) ; ................................................;
if Close < var0 then var2 = false else if Close > var0 then var2= true ;
End else if Close > var1 then
var3= false
else if Close > var1 then var3= true ;
condition1 = var2 and var3................................... ; if condition1 then
Sellshort ( "MASE" ) next bar at market ;
|