请高手帮忙看看这个Script有什么问题

Discussion in 'Wealth-Lab Developer' started by rainbow57, Jan 16, 2009.

  1. 主要是想实现:昨天的最低点是前天、昨天、今天这三天的最低点,并今天的最低点在10天最低点之内ATR(10)距离,则在今天收盘价附近买入,止损为买入价格-ATR(10)。当价格达到10天最高点-0.5*ATR(10)之后卖出。
    但是脚本写出来以后,交易次数很少。我检查了一下,不知道哪里有问题,请高手帮忙看看。
    ……………………………………………………………………………………………………………………

    var ChannelUp, ChannelDn: integer;
    var N, L1, L2, LE, LS, Account, Tick: float;
    var Bar, p, LeadBars, ATRParam : integer;

    { Parameters input }
    ChannelUp := 10 ;
    ChannelDn := 10 ;
    ATRParam := 10 ;
    Account := 1000000 ; //This is the notional account

    { Cosmetics and general info }
    HideVolume ;
    PlotStops;
    EnableNotes(false);
    tick := GetTick ;

    { Indicators plotting }
    PlotSeries( HighestSeries( #High, ChannelUp ), 0, #blue, #Thin );
    PlotSeries( LowestSeries( #Low, ChannelDn ), 0, #green, #Dotted );

    { MAIN CYCLE }
    LeadBars := Trunc(ChannelUp); // Failsafe > Channel and Failsafe > Exit
    for Bar := LeadBars to BarCount - 1 do
    begin
    N := ATR( Bar, ATRParam ); // N calculation
    LE := Highest( Bar, #High, ChannelUp) - 0.5 * N ;

    { Entering the first position }
    if (PositionCount = 0)and(PriceLow( Bar - 2 ) > PriceLow( Bar - 1 ))
    and(PriceLow( Bar - 1 ) < PriceLow( Bar ))
    and (PriceClose( Bar ) < Lowest( Bar , #Low, ChannelDn) + N) then
    begin
    SetShareSize(Int( (Account * 0.01) / (N * GetPointValue*100))*100); // Unit Using China
    L1 := PriceClose( Bar ) ;
    L2 := L1 + 0.5 * N ;
    BuyAtStop( Bar , L1, 'L1 ' + FormatFloat( '#0.00', L1));
    LS := L1 - N;
    end; // of 'if PositionCount = 0 then'

    { Check for position exit conditions }
    for p := 0 to PositionCount -1 do begin
    if PositionActive(p) then begin
    if not SellAtStop( Bar + 1, LS, p, 'LongStop' + FormatFloat('#0.00', LS)) then
    SellAtStop( Bar + 1, LE, p, 'LongExit' + FormatFloat('#0.00', LE));
    end;
    end; // of position exits
    end; // OF THE MAIN CYCLE