利用ShowMe 來判斷進出場的位置是否可行後,就可以把自己的想法寫成訊號了
語法完全同 ShowMe 時的寫法,但唯一不同的是,不再畫圖(plot), 而是用買(Buy)/賣(Sell)
Input: Price(Close), Length1(18), Length2(50), Displace(0);
Vars: ViewLen(3), EntLen(5),FastMA(0),LowMA(0),EntPriceL(0),EntPriceS(0),LEntBar(-999),LEntPrice(0),SEntPrice(0),SEntBar(0),PlotEnt(0);
If Displace >= 0 OR CurrentBar > AbsValue(Displace) Then Begin
FastMA = AverageFC(Price, Length1);
LowMA = AverageFC(Price, Length2);
IF FastMA Crosses Above LowMA Then Begin
EntPriceL = Highest(H,ViewLen);
LEntBar = BarNumber;
End
Else
IF FastMA Crosses Below LowMA Then Begin
EntPriceS = Lowest(L,ViewLen);
SEntBar = BarNumber ;
End;
{Bullish}{多頭市場,若均線交叉向上,且價格>=三日內最高點,則買在收盤價一成以上突破的位置}
If BarNumber < LEntBar + EntLen then Begin
IF C >= EntPriceL then Begin
Buy("RS_Buy") at C * 1.01 stop;
End;
End;
{Bearish}{空頭市場,若均線交叉向下,且價格<=三日內最高點,則買在收盤價一成以上跌破的位置}
If BarNumber < SEntBar + EntLen then Begin
IF C <= EntPriceS then Begin
Sell("RS_Sell") at C * 0.98 Stop;
End;
End;
End;
會出現買訊,另一個買訊出現時,因已經有多頭部位在手上了,所以Tradestation 並不會再下單。