暫存

摘要:暫存

 

_long =MA(Close,15);
_short =MA(Close,5);
PyramidThreshold = 0.2; 
 
Buy=Cross(_short ,_long);
Sell = Cross(_long,_short );
InTrade = Flip( Buy, Sell ); 
barsintrade = BarsSince(Buy)+1;
EntryPrice = ValueWhen(Buy OR Sell ,Close);
LowStopPrice = (EntryPrice * (1- PyramidThreshold) );
HighStopPrice= (EntryPrice * (1+ PyramidThreshold) );
 
e = Equity(1);
 
eBuy = ValueWhen( Buy, e );
 
PcntProfit = 100 * ( e - ValueWhen( Buy, e ) )/ValueWhen( Buy, e ); 
PcntProfit2 = 100 * ( Close  - ValueWhen( Buy, Close ) )/ValueWhen( Buy, Close  ); 
 
 
// ExRem is used here to ensure that scaling-in/out occurs 
// only once since trade entry 
DoScaleIn = ExRem( InTrade AND PcntProfit2 > PyramidThreshold, Sell );  //加碼
DoScaleOut = ExRem( InTrade AND PcntProfit2 < -PyramidThreshold, Sell ); //減碼
 
// modify rules to handle pyramiding 
Buy2 = Buy + sigScaleIn * DoScaleIn + sigScaleOut * DoScaleOut; 
 
PositionSize = IIf( DoScaleOut, 500, 1000 ); // enter and scale-in size $1000, scale-out size: $500
 
 
y=Sum(1,1);
 
 
x=Cum(Buy - Sell);
AddColumn(Close,"Close");
AddColumn(Buy,"Buy");
AddColumn(Sell,"Sell");
AddColumn(InTrade ,"InTrade");
AddColumn(EntryPrice ,"EntryPrice");
AddColumn(LowStopPrice ,"LowStopPrice");
AddColumn(HighStopPrice ,"HighStopPrice");
 
AddColumn(x,"CUM");
AddColumn(y,"SUM");
AddColumn(e,"Equity");
AddColumn(eBuy,"eBuy");
AddColumn(PcntProfit ,"PcntProfit ");
AddColumn(PcntProfit2 ,"PcntProfit2 ");
 
 
 
 
 
AddColumn(DoScaleIn ,"DoScaleIn ");
AddColumn(DoScaleOut ,"DoScaleOut ");
Filter =(y=1) ;

http://www.plurk.com/SophieQ