MAE 最大亏损幅度是怎么算出来的?

Discussion in 'Wealth-Lab Developer' started by lgperson, Mar 17, 2006.

  1. CoverAtLimt
    CoverAtStop
    什么意思?
    为什么要用Random?
    ---------------------------------------------------
    //####################################
    for Bar := 20 to BarCount - 2 do
    //####################################
    begin

    ProfitTarget := (ATR ( Bar, ATRPeriod)/ RangeDivBy) ;
    MaxRisk := ProfitTarget / 4;

    if not LastPositionActive then
    { Entry Rules }
    begin
    // here we are peeking into the future !
    tomorrowOpen := PriceOpenR( Bar + 1);
    If ( tomorrowOpen < PriceHighR(bar))
    and ( tomorrowOpen > PriceLowR (bar)) then
    begin
    // if Random() > 0.5 then begin // sometimes long
    BuyAtStopR( bar + 1, PriceHighR(Bar) ,'');
    // end else begin // and sometimes short
    ShortAtStopR ( bar + 1, PriceLowR(Bar) ,'');
    // End;
    end;
    end
    else
    { Exit Rules }
    begin
    //ApplyAutoStops(Bar);
    for p := 0 to PositionCount - 1 do
    if PositionActive( p ) then
    Begin
    If PositionLong(p) then
    begin
    if Random() < 0.5 then begin // sometimes pt is hit before sl
    SellAtLimitR( bar, PositionEntryPrice( p ) + ProfitTarget , p, 'PT');
    SellAtStop( bar, PositionEntryPrice( p ) - MaxRisk , p, 'SL');
    end else begin // and sometimes the other way round
    SellAtStop( bar, PositionEntryPrice( p ) - MaxRisk , p, 'SL');
    SellAtLimitR( bar, PositionEntryPrice( p ) + ProfitTarget , p, 'PT');
    End;
    SellAtClose( bar, p, 'AtClose');
    end;

    If PositionShort(p) then
    begin
    if Random() > 0.5 then begin // sometimes pt is hit before sl
    CoverAtLimit( bar, PositionEntryPrice( p ) - ProfitTarget , p, 'PT');
    CoverAtStop( bar, PositionEntryPrice( p ) + MaxRisk , p, 'SL');
    end else begin // and sometimes the other way round
    CoverAtStop( bar, PositionEntryPrice( p ) + MaxRisk , p, 'SL');
    CoverAtLimit( bar, PositionEntryPrice( p ) - ProfitTarget , p, 'PT');
    End;
    CoverAtClose( bar, p, 'AtClose');
    end;
    end;
    end;
    //================================
    // just costmetic to see the potential setup bars
    tomorrowOpen := PriceOpenR( Bar + 1);
    If (( tomorrowOpen < PriceHighR(bar))
    and ( tomorrowOpen > PriceLowR (bar)) )then
    SetBarColor( Bar+1, #yellow);

    end;
     
  2. 有人看没人回啊!

    有人看没人回啊! :(