|
本帖最後由 kilroy 於 14-3-18 14:11 編輯
uncleray888 發表於 14-3-18 10:20
有沒有大大可以指導一下
Hi,
小弟很想幫忙,但是本身沒有在策略做停損停利的方式
所以只能給網路範例,讓大大參考
StopLevel =Param("Percentage Trail Stop",0.2, 0.01, 0.6, 0.01 );
LK=50;
FF=10;
A1= IIf( L> Ref(HHV( Close,LK),-5), 1, 0);
A2= Sum( A1, LK ) ;
A3= IIf(C>0, FF, 0);
Buy = Cross(A2,A3);
Sell = 0;
trailARRAY = Null;
trailstop = 0;
for( i = 1; i < BarCount; i++ )
{
if( trailstop == 0 AND Buy[ i ] )
{
trailstop = High[ i ] * (1-stoplevel);
}
else Buy[ i ] = 0; // remove excess buy signals
if( trailstop > 0 )
{ trailstop = Max( High[ i ] * (1-stoplevel), trailstop );
trailARRAY[ i ] = trailstop;
}
if( trailstop > 0 AND Low[ i ] < trailstop )
{
Sell[ i ] = 1;
SellPrice[ i ] = trailstop;
trailstop=0;
}
}
PlotShapes(Buy*shapeUpArrow,colorBlue,0,Low);
PlotShapes(Sell*shapeDownArrow,colorRed,0,High);
Plot( Close,"Price",colorBlack,styleBar);
Plot( trailARRAY,"trailing stop level", colorRed );
上面的範例是一組 buy(多單進場) sell(多單平倉) 的 trailling stop 範例
如此,再增加一組 short(空單進場) cover(空單平倉) 就可以了
應該不難才對
且,在AB裡,你的進場條件如果是某個特定價位
進場條件不互相牴觸(俗稱 bug)的情況下
可以做當根K某個價位進場
參考看看了~~
|
|