|
本帖最後由 kilroy 於 14-2-26 20:21 編輯
Hi,
小弟這邊給大大範例
RequestTimedRefresh(1, onlyvisible = False);
_InitialEquity = 1000000;
_MaxPosition = 100;
_DoPositionSizing = 0;
_DayGap = abs(TimeFrameGetPrice("O",inDaily,0)-TimeFrameGetPrice("C",inDaily,-1));
_SECTION_BEGIN("Product Settings");
SetPositionSize(1, spsShares);
SetOption("MaxOpenPositions", 8);
SetOption("InitialEquity", _InitialEquity);
SetOption("FuturesMode", 1);
SetOption("CommissionMode", 3);
SetOption("CommissionAmount", 70);
RoundLotSize = 1;
//TXF_HOT
TickSize = 1;
MarginDeposit = 83000;
PS = 1;
PointValue = 200*PS;
DEC=0;
_SECTION_BEGIN("Background_Setting");
SetChartBkColor(1);
SetChartOptions(2,chartShowArrows|chartShowDates|chartWrapTitle);
SetChartBkGradientFill(1, 1, 1);
GraphXSpace = Param("Zoom/In Out", 100, -50, 150, 1);
dist = 5*ATR(12);
_SECTION_END();
_SECTION_BEGIN("Trading Rules");
barcomplete = BarIndex() < LastValue(BarIndex());
_SECTION_BEGIN("William's % R");
function PercentR( periods )
{
return -100 * ( HHV( H, periods ) - C )/( HHV( H, periods ) - LLV( L, periods ) );
}
//Plot( PercentR( Param("Periods", 12, 2, 100 ) ),_DEFAULT_NAME(),ParamColor("Color", ColorCycle ),styleOwnScale );
//Plot( -30,_DEFAULT_NAME(),colorGreen,styleOwnScale );
//Plot( -70,_DEFAULT_NAME(),colorGreen,styleOwnScale );
_SECTION_END();
Buy=Cross(PercentR(6),MA(PercentR(26),25)) AND barcomplete;
Short=Cross(MA(PercentR(26),25),PercentR(6)) AND barcomplete;
Buy = Cover = ExRem(Buy, Short);
Short = Sell = ExRem(Short, Buy);
Slippages1 = 5*TickSize;
Slippages2 = 5*TickSize;
BuyPrice = CoverPrice = C+Slippages1;
ShortPrice = SellPrice = C-Slippages2;
printf("\nBP %g",BuyPrice);
printf("\nSP %g",ShortPrice);
_SECTION_END();
_SECTION_BEGIN("Charts");
_N(Title = StrFormat(Name()+"- {{INTERVAL}} {{DATE}} \nOpen %g, Hi %g, Lo %g, Close %g (%.1f%%), Volume %g{{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ), V));
PlotOHLC( O, H, L, C, "", IIf(C>O, colorRed, colorGreen), styleBar|styleNoLabel);
PlotShapes(IIf(Buy, 59, shapeNone), 7, 0, WMA(O, 1)-2*ATR(15), 6);
PlotShapes(IIf(Short, 60, shapeNone), 7, 0, WMA(O, 1)+2*ATR(15), 0);
_SECTION_END();
_SECTION_BEGIN("Index");
X = Param ("X - Left Up Corner", 1.55, 1, 3, 0.01);
Y = Param ("Y - Right Up Corner", 55, 30, 100, 1);
GfxSelectFont("Tahoma", Status("pxheight")/7*0.5 );
GfxSetTextAlign( 6 );
GfxSetTextColor( 2 );
GfxSetBkMode(0);
GfxTextOut( " "+C , Status("pxwidth")/X, Status("pxheight")/Y );
_SECTION_END();
參考看看吧~
|
評分
-
查看全部評分
|