A Good Trading Script for WLD

Discussion in 'Wealth-Lab Developer' started by nozomiHK, Jul 21, 2006.

  1. 再请检查附件的性能报告, 这个报告用三年 HK HSI + HSCCI 和HSCEI 数据测试。 它仍然需要改善 Enter/Exit 战略以便改进赢取的% 和赢利。欢迎您的输入和修改!

    A variation on chartscript Neo Master V2 from WLD website. Simply remove the first two buy signals after a sell since they seem to trigger on the most part on the downward slope.

    - Disable Line 25
    ....................SetShareCap( 1000 )
    - Added Line 40 for better use with simulator
    ....................SetPositionPriority( LastPosition, -1 * CMO(Bar, #Close, 14 ));

    =========================
    var Y, X, Y1, Y2, Y3, Y4: float;
    var BBOUGHT: boolean;
    var
    NSMA, NPANE, NCOUNT, BAR, I, COLOR, LINE, XSERIES, HILO, X1, X2, X3, X4, btcount: integer;
    { Wealth-Lab's Master System }

    { Plot a 14 day Moving Average }
    nSMA := SMASeries( #Close, 14 );
    PlotSeries( nSMA, 0, 044, 1 );

    { Plot 14 day CMO in new chart pane }
    nPane := CreatePane( 60, TRUE, FALSE );
    PlotSeries( CMOSeries( #Close, 14 ), nPane, 009, 0 );
    DrawText( 'CMO 14', nPane, 4, 4, 006, 8 );
    DrawHorzLine( 0, nPane, 666, 0 );
    DrawHorzLine( 50, nPane, 666, 1 );
    DrawHorzLine( -50, nPane, 666, 1 );

    { Some variables }
    nCount := BarCount();
    bBought := false;
    btcount := 0;

    { Max 1000 shares per position }
    //SetShareCap( 1000 );

    { Execute the Trading System }
    for Bar := 15 to BarCount() - 1 do
    begin
    if CumDown( Bar, #Close, 4 ) = 0 then
    bBought := false;
    if (PriceClose( Bar-1 ) < PriceClose( Bar-3 ))
    and ( CMO( Bar, #Close, 14 ) <= 0 ) then
    if not bBought then
    begin
    bBought := true;
    btcount := btcount + 1;
    if btcount > 2 then
    BuyAtMarket( Bar + 1, '');
    SetPositionPriority( LastPosition, -1 * CMO(Bar, #Close, 14 ));
    end;
    if ( CumUp( Bar, #Close, 4 ) >= 9 ) or ( CMO( Bar, #Close, 14 ) >= 50 ) then
    begin
    for i := 0 to PositionCount() - 1 do
    if PositionActive( i ) then
    begin
    SellAtMarket( Bar + 1, i, '');
    btcount := 0;
    end;
    end;
    end;

    { Below is tbui's Support/Resistance PlugIn -
    It displays the most recent up and down trendlines
    Parameters
    --------------------------------------------------------}
    Bar := BarCount() - 20;
    Color := 900;
    Line := 0;

    {High Low AVERAGE
    For the last 50 bars:
    . Calculate the diff. between PriceHight and PriceLow
    . Normalize it with PriceClose
    . Put it into a new series
    . Total all them up
    . Average them with highest and the lowest excluded.
    ---------------------------------------------------------}
    x := 0 ;
    xSeries := CreateSeries();
    For i := Bar - 50 to Bar do
    Begin
    y := (PriceHigh(i) - PriceLow(i)) / PriceClose(i);
    y := y * 100 ;
    SetSeriesValue( i, xSeries, y );
    x := x + y;
    end;
    x := x - Highest(Bar, xSeries, 50);
    x := x - Lowest(Bar, xSeries, 50);
    hilo := Round(x / 48 );

    { RESISTANCE LINE
    . Calculate coordinates of 2 consecutive peaks using
    hilo as ReversalPct.
    . Extrapolate the coordinates to the current bar, also
    10 bars to the left.
    . Draw a resistance line.
    ---------------------------------------------------------}
    y1 := Peak( Bar, #High, hilo);
    x1 := Peakbar( Bar, #High, hilo);
    y2 := Peak( x1, #High, hilo * 2);
    x2 := Peakbar( x1, #High, hilo * 2);
    If (x2 <> x1) then
    Begin
    x3 := x1 + 20;
    if (x3 > (BarCount() - 1)) then x3 := BarCount() - 1;
    y3 := (((y2 - y1) * (x3 - x1)) / (x2 - x1)) + y1;
    x4 := x2 - 10;
    y4 := (((y2 - y1) * (x4 - x1)) / (x2 - x1)) + y1;
    DrawLine( x3, y3, x4, y4, 0, Color, Line);
    end;

    { SUPPORT LINE
    . Same as above
    ---------------------------------------------------------}
    y1 := Trough( Bar, #Low, hilo);
    x1 := Troughbar( Bar, #Low, hilo);
    y2 := Trough( x1, #Low, hilo * 2);
    x2 := Troughbar( x1, #Low, hilo * 2);
    If (x2 <> x1) then
    Begin
    x3 := x1 + 20;
    if (x3 > (BarCount() - 1)) then x3 := BarCount() - 1;
    y3 := (((y2 - y1) * (x3 - x1)) / (x2 - x1)) + y1;
    x4 := x2 - 10;
    y4 := (((y2 - y1) * (x4 - x1)) / (x2 - x1)) + y1;
    DrawLine( x3, y3, x4, y4, 0, Color, Line);
    end;
    { END OF STUDY
    ==========================================================}

    http://www.wealth-lab.cn/download.php?file=6fc668a4c40fab4f266a9967b123324d
     
  2. 请问这是一个趋势追踪系统还是振荡系统?要是趋势追踪系统的话,我想海龟交易系统比较容易执行些!