[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Q re ApplyStop



PureBytes Links

Trading Reference Links

I'm trying to write a system that sells if the price falls below what I
bought at, or
"some other condition". I've attached the full details of my setup but in
short it is:

Buy=<condition>;
BuyPrice=O;

Sell = <condition>;
SellPrice=O;

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);

ApplyStop(0, 2, 1, 1);
ApplyStop(2, 2, 1, 1);


What I'm *trying* to achieve with the ApplyStop's is to exit as soon as the
price
falls below my entry price .. I believe they should be applied as soon as
the stop falls
1 point below my purchase price, according to my reading of the manual
(which is
clearly wrong). I've used Sell & SellPrice to exit on my other condition.

I have set "apply stops immediately" and "allow same day entry & exit" in
the settings
and I'm using the latest Beta download, but I cannot get it to work. In
particular there
are a few trades where I enter on Open, the day goes lower immediately and
stays
lower, but I don't exit until the next day ... I thought the ApplyStop would
get me out?

Any help would be much appreciated.

Regards,
Matt Atterbury (mailto:matt@xxxxxxxxxx)

------------------------ Yahoo! Groups Sponsor ---------------------~-->
New Yahoo! Mail Plus. More flexibility. More control. More power.
Get POP access, more storage, more filters, and more.
http://us.click.yahoo.com/Hcb0iA/P.iFAA/46VHAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 


Title: AmiBroker System Test Report




  
  
    Settings
  
     
  
    Initial Equity:
    100000
    
    Periodicity/Positions:
    Daily/Long 
  
    Commissions:
    0.00 (Use portfolio settings)
    
    Annual interest rate:
    0.00%
  
    Range:
    6/02/2002 00:00:00 - 9/03/2003
    
    Apply to:
    Current Symbol
  
    Margin requirement:
    100
    
    Futures mode:
    No
  
    Def. round lot size:
    1
    
    Def. Tick Size
    1
  
    Drawdowns based on:
    High/Low prices
    
     
     
  
    Long trades
  
    Buy price:
    Open
    
    Sell price:
    Close
  
    Buy delay:
    0
    
    Sell delay:
    0
  
    Short trades
  
    Short price:
    Close
    
    Cover price:
    Close
  
    Short delay:
    0
    
    Cover delay:
    0
  
    Stops
  
    Maximum loss:
    disabled
    
    Profit target:
    disabled
  
    Value:
    1.00
    
    Value:
    0.00
  
    Exit at stop?
    yes
    
    Exit at stop?
    no
  
     
  
    Trailing stop:
    disabled
    
     
     
  
    Value:
    0.00
    
     
     
  
    Exit at stop?
    no
    
     
     


  
  
    Formulaperiods=250; 
 
Odji=Ref(Foreign("$DJ","Open"),-1); 
Cdji=Ref(Foreign("$DJ","Close"),-1); 
deltaDJI=IIf(Cdji<Odji,-1,IIf(Cdji>Odji,1,0)); 
 
Oxxx=O; 
Cxxx=C; 
deltaXXX=IIf(Cxxx<Oxxx,-1,IIf(Cxxx>Oxxx,1,0)); 
 
Corr=IIf(deltaXXX == deltaDJI, 1, 0); 
AvgCorr=MA(Corr,periods); 
 
isCorrelated=(Avgcorr > 0.5); 
isBuySignalled=(deltaDJI > 0); 
 
Buy=isCorrelated AND isBuySignalled; 
BuyPrice=O; 
 
isSellSignalled=(deltaDJI < 0); 
Sell = isSellSignalled; 
SellPrice=O; 
 
Buy=ExRem(Buy,Sell); 
Sell=ExRem(Sell,Buy); 
 
ApplyStop(0, 2, 1, 1); 
ApplyStop(2, 2, 1, 1); 



  
  
    Overall performance summary
  
     
  
    Total net profit:
    17503.46
     
    Total commissions paid:
    0.00
  
    Return on account:
    17.50 % 
     
    Open position gain/loss
    0.00
  
    Buy&Hold profit:
    -19082.90
     
    Bars (avg. days) in test:
    275 (395)
  
    Buy&Hold % return:
    -19.08%
     
    System to Buy&Hold index:
    191.72%
  
     
  
    Annual system % return:
    16.07%
     
    Annual B&H % return:
    -17.77%
  
     
  
    System drawdown:
    -5785.04
     
    B&H drawdown:
    -24385.84
  
    Max. system drawdown:
    -14251.65
     
    B&H max. drawdown:
    -31137.87
  
    Max. system % drawdown:
    -11.31%
     
    B&H max. % drawdown:
    -29.17%
  
    Max. trade drawdown:
    -7479.33
     
     
     
  
    Max. trade % drawdown:
    -7.21%
     
     
     
  
    Trade drawdown:
    -6638.24
     
     
     
  
     
  
    Total number of trades:
    71
     
    Percent profitable:
    47.9%
  
    Number winning trades:
    34
     
    Number losing trades:
    37
  
    Profit of winners:
    87452.12
     
    Loss of losers:
    -69948.66
  
    Total # of bars in winners:
    104
     
    Total # of bars in losers:
    91
  
    Commissions paid in winners:
    0.00
     
    Commissions paid in losers:
    0.00
  
     
  
    Largest winning trade:
    6603.80
     
    Largest losing trade:
    -6349.59
  
    # of bars in largest winner:
    5
     
    # bars in largest loser:
    2
  
    Commission paid in largest winner:
    0.00
     
    Commission paid in largest loser:
    0.00
  
     
  
    Average winning trade:
    2572.12
     
    Average losing trade:
    -1890.50
  
    Avg. # of bars in winners:
    3.1
     
    Avg. # bars in losers:
    2.5
  
    Avg. commission paid in winner:
    0.00
     
    Avg. commission paid in loser:
    0.00
  
    Max consec. winners:
    5
     
    Max consec. losers:
    6
  
     
  
    Bars out of the market:
    81
     
    Interest earned:
    0.00
  
     
  
    Exposure:
    70.5%
     
    Risk adjusted ann. return:
    22.78%
  
    Ratio avg win/avg loss:
    1.36
     
    Avg. trade (win & loss):
    246.53
  
    Profit factor:
    1.25
     
    
    



  
  
    Performance for BHP 
  
     
  
    Total net profit:
    17503.46
     
    Total commissions paid:
    0.00
  
    Return on account:
    17.50 % 
     
    Open position gain/loss
    0.00
  
    Buy&Hold profit:
    -19082.90
     
    Bars (days) in test:
    275 (395)
  
    Buy&Hold % return:
    -19.08%
     
    System to Buy&Hold index:
    191.72%
  
     
  
    Annual system % return:
    16.07%
     
    Annual B&H % return:
    -17.77%
  
     
  
    System drawdown:
    -5785.04
     
    B&H drawdown:
    -24385.84
  
    Max. system drawdown:
    -14251.65
     
    B&H max. drawdown:
    -31137.87
  
    Max. system % drawdown:
    -11.31%
     
    B&H max. % drawdown:
    -29.17%
  
    Max. trade drawdown:
    -7479.33
     
     
     
  
    Max. trade % drawdown:
    -7.21%
     
     
     
  
    Trade drawdown:
    -6638.24
     
     
     
  
     
  
    Total number of trades:
    71
     
    Percent profitable:
    47.9%
  
    Number winning trades:
    34
     
    Number losing trades:
    37
  
    Profit of winners:
    87452.12
     
    Loss of losers:
    -69948.66
  
    Total # of bars in winners:
    104
     
    Total # of bars in losers:
    91
  
    Commissions paid in winners:
    0.00
     
    Commissions paid in losers:
    0.00
  
     
  
    Largest winning trade:
    6603.80
     
    Largest losing trade:
    -6349.59
  
    # of bars in largest winner:
    5
     
    # bars in largest loser:
    2
  
    Commission paid in largest winner:
    0.00
     
    Commission paid in largest loser:
    0.00
  
     
  
    Average winning trade:
    2572.12
     
    Average losing trade:
    -1890.50
  
    Avg. # of bars in winners:
    3.1
     
    Avg. # bars in losers:
    2.5
  
    Avg. commission paid in winner:
    0.00
     
    Avg. commission paid in loser:
    0.00
  
    Max consec. winners:
    5
     
    Max consec. losers:
    6
  
     
  
    Bars out of the market:
    81
     
    Interest earned:
    0.00
  
     
  
    Exposure:
    70.5%
     
    Risk adjusted ann. return:
    22.78%
  
    Ratio avg win/avg loss:
    1.36
     
    Avg. trade (win & loss):
    246.53
  
    Profit factor:
    1.25
     
    
    



  
  
    Trade list for BHP 
  
    Trade
    Entry date
    Entry price
    Exit date
    Exit price
    Position size
    Net Profit
    Equity value
  
    Long
    11/02/2002
    10.97
    13/02/2002
    11.26
    99989.14
    2640.26
    102640.26
  
    Long
    14/02/2002
    11.54
    18/02/2002
    11.05
    102633.10
    -4404.51
    98235.75
  
    Long
    21/02/2002
    10.89
    22/02/2002
    10.83
    98231.59
    -505.91
    97729.84
  
    Long
    25/02/2002
    10.80
    27/02/2002
    11.08
    97723.10
    2538.27
    100268.11
  
    Long
    28/02/2002
    11.06
    1/03/2002
    10.97
    100258.03
    -847.50
    99420.61
  
    Long
    4/03/2002
    10.95
    6/03/2002
    11.11
    99418.64
    1536.84
    100957.45
  
    Long
    7/03/2002
    11.23
    8/03/2002
    11.33
    100952.71
    916.23
    101873.68
  
    Long
    11/03/2002
    11.27
    14/03/2002
    10.89
    101869.05
    -3463.21
    98410.47
  
    Long
    15/03/2002
    10.69
    19/03/2002
    10.80
    98407.22
    946.22
    99356.69
  
    Long
    20/03/2002
    11.00
    21/03/2002
    10.80
    99353.45
    -1857.08
    97499.61
  
    Long
    27/03/2002
    10.46
    2/04/2002
    10.84
    97491.04
    3572.06
    101071.67
  
    Long
    5/04/2002
    10.88
    9/04/2002
    11.03
    101063.40
    1389.19
    102460.86
  
    Long
    11/04/2002
    11.16
    12/04/2002
    10.47
    102451.51
    -6349.59
    96111.27
  
    Long
    15/04/2002
    10.74
    16/04/2002
    10.89
    96109.14
    1338.34
    97449.61
  
    Long
    17/04/2002
    10.93
    18/04/2002
    10.90
    97443.30
    -250.07
    97199.55
  
    Long
    22/04/2002
    10.81
    23/04/2002
    10.70
    97191.76
    -924.84
    96274.70
  
    Long
    1/05/2002
    10.05
    6/05/2002
    10.26
    96270.38
    2059.74
    98334.44
  
    Long
    8/05/2002
    10.24
    10/05/2002
    10.56
    98327.59
    3142.89
    101477.33
  
    Long
    14/05/2002
    10.43
    16/05/2002
    10.73
    101475.65
    2909.69
    104387.02
  
    Long
    17/05/2002
    10.87
    21/05/2002
    10.68
    104379.42
    -1795.01
    102592.01
  
    Long
    23/05/2002
    10.37
    27/05/2002
    10.37
    102591.16
    0.00
    102592.01
  
    Long
    3/06/2002
    10.05
    4/06/2002
    9.95
    102591.26
    -1049.77
    101542.24
  
    Long
    6/06/2002
    9.82
    7/06/2002
    9.66
    101540.31
    -1643.99
    99898.25
  
    Long
    13/06/2002
    9.70
    14/06/2002
    9.86
    99894.69
    1636.04
    101534.29
  
    Long
    18/06/2002
    9.89
    20/06/2002
    9.68
    101532.63
    -2207.23
    99327.06
  
    Long
    25/06/2002
    9.40
    26/06/2002
    9.50
    99325.98
    987.34
    100314.39
  
    Long
    27/06/2002
    9.47
    1/07/2002
    9.79
    100310.67
    3366.79
    103681.19
  
    Long
    4/07/2002
    10.02
    9/07/2002
    10.50
    103676.94
    4966.56
    108647.74
  
    Long
    18/07/2002
    9.52
    19/07/2002
    9.93
    108642.25
    4678.92
    113326.66
  
    Long
    25/07/2002
    9.59
    31/07/2002
    9.55
    113325.03
    -472.68
    112853.98
  
    Long
    1/08/2002
    9.52
    2/08/2002
    9.04
    112850.09
    -5689.93
    107164.06
  
    Long
    7/08/2002
    8.60
    13/08/2002
    9.13
    107156.00
    6603.80
    113767.85
  
    Long
    15/08/2002
    8.95
    19/08/2002
    8.96
    113763.45
    127.11
    113894.97
  
    Long
    20/08/2002
    9.30
    21/08/2002
    9.26
    113887.80
    -489.84
    113405.13
  
    Long
    22/08/2002
    9.52
    26/08/2002
    9.45
    113402.25
    -833.85
    112571.28
  
    Long
    27/08/2002
    9.53
    28/08/2002
    9.54
    112568.36
    118.12
    112689.40
  
    Long
    5/09/2002
    8.94
    6/09/2002
    8.80
    112688.69
    -1764.69
    110924.71
  
    Long
    9/09/2002
    9.03
    12/09/2002
    9.43
    110924.52
    4913.61
    115838.32
  
    Long
    17/09/2002
    9.47
    18/09/2002
    9.38
    115837.04
    -1100.88
    114737.43
  
    Long
    23/09/2002
    9.05
    24/09/2002
    8.91
    114735.90
    -1774.92
    112962.51
  
    Long
    26/09/2002
    8.90
    30/09/2002
    9.14
    112958.80
    3046.09
    116008.60
  
    Long
    2/10/2002
    9.50
    3/10/2002
    9.39
    116004.50
    -1343.21
    114665.39
  
    Long
    9/10/2002
    9.19
    10/10/2002
    8.83
    114663.62
    -4491.72
    110173.68
  
    Long
    11/10/2002
    9.16
    17/10/2002
    9.64
    110167.32
    5772.97
    115946.64
  
    Long
    18/10/2002
    9.95
    23/10/2002
    9.73
    115937.40
    -2563.44
    113383.20
  
    Long
    24/10/2002
    9.89
    25/10/2002
    9.72
    113378.96
    -1948.88
    111434.32
  
    Long
    28/10/2002
    9.58
    29/10/2002
    9.67
    111424.98
    1046.79
    112481.11
  
    Long
    30/10/2002
    9.46
    1/11/2002
    9.58
    112479.40
    1426.80
    113907.91
  
    Long
    4/11/2002
    9.54
    8/11/2002
    9.71
    113907.60
    2029.80
    115937.71
  
    Long
    13/11/2002
    9.51
    19/11/2002
    9.74
    115936.41
    2803.92
    118741.63
  
    Long
    21/11/2002
    9.79
    25/11/2002
    9.94
    118733.12
    1819.20
    120560.83
  
    Long
    26/11/2002
    9.85
    27/11/2002
    9.52
    120554.15
    -4038.87
    116521.96
  
    Long
    28/11/2002
    9.73
    2/12/2002
    10.25
    116516.74
    6227.01
    122748.97
  
    Long
    5/12/2002
    10.10
    6/12/2002
    10.05
    122745.30
    -607.65
    122141.31
  
    Long
    9/12/2002
    10.11
    10/12/2002
    9.90
    122138.91
    -2537.01
    119604.30
  
    Long
    11/12/2002
    9.89
    13/12/2002
    9.68
    119599.77
    -2539.53
    117064.77
  
    Long
    17/12/2002
    9.75
    18/12/2002
    10.01
    117058.50
    3121.56
    120186.34
  
    Long
    23/12/2002
    9.92
    24/12/2002
    10.08
    120180.80
    1938.40
    122124.73
  
    Long
    31/12/2002
    10.05
    6/01/2003
    10.00
    122117.55
    -607.55
    121517.18
  
    Long
    7/01/2003
    10.03
    8/01/2003
    10.00
    121513.45
    -363.45
    121153.73
  
    Long
    10/01/2003
    9.92
    14/01/2003
    9.79
    121152.96
    -1587.69
    119566.04
  
    Long
    15/01/2003
    9.87
    16/01/2003
    9.78
    119565.18
    -1090.26
    118475.78
  
    Long
    24/01/2003
    9.35
    28/01/2003
    9.10
    118473.85
    -3167.75
    115308.03
  
    Long
    29/01/2003
    9.10
    31/01/2003
    8.91
    115306.10
    -2407.50
    112900.53
  
    Long
    3/02/2003
    8.92
    5/02/2003
    9.10
    112900.44
    2278.26
    115178.80
  
    Long
    11/02/2003
    9.31
    12/02/2003
    9.21
    115174.02
    -1237.10
    113941.69
  
    Long
    17/02/2003
    9.10
    20/02/2003
    9.32
    113941.10
    2754.61
    116696.31
  
    Long
    24/02/2003
    9.18
    25/02/2003
    9.39
    116696.16
    2669.52
    119365.83
  
    Long
    26/02/2003
    9.29
    27/02/2003
    9.29
    119357.92
    0.00
    119365.83
  
    Long
    28/02/2003
    9.24
    4/03/2003
    9.25
    119362.32
    129.18
    119495.01
  
    Long
    6/03/2003
    9.00
    7/03/2003
    8.85
    119493.00
    -1991.54
    117503.46