Backtest RHS shows false sell signal

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #78214 quote
    capngoggles
    Participant
    New

    Hi all,

    I am not sure if I have my thinking wrong or not.

    I have a simple backtest built off an indicator and it shows the black program termination mark on the very last bar (RHS) and a sell (X), whether the indicator

    is in sell or not.

    To me this is a false and misleading signal, and I have to look at the indicators to determine if it hasnt just flagged a real sell or not. I dont why it would do that.

    Any assistance would be greatly appreciated.

    Although the following code uses a CALL, the problem exists on other backtests as well using standard indicators.

    Thanks for any assistance you can provide

    John

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    // Conditions to enter long positions
    ignored, indicator1 = CALL JBWaveTrendDiff
    c1 = (indicator1 > 0)
    
    IF c1 THEN
    BUY 5000 CASH AT MARKET
    ENDIF
    
    // Conditions to exit long positions
    ignored, indicator2 = CALL JBWaveTrendDiff
    c2 = (indicator2 < 0)
    
    IF c2 THEN
    SELL AT MARKET
    ENDIF
    PNV-Daily.png PNV-Daily.png PNV-DailyCUTDOWN.png PNV-DailyCUTDOWN.png PNV-DailyBackTestSettings.png PNV-DailyBackTestSettings.png
    #78218 quote
    robertogozzi
    Moderator
    Master

    To write code, please use the <> “insert PRT code” button, to make code easier to read. Thank you.

    For anyone to be of help, please post the code for the CALLed indicator or modify the code using a standard indicator.

    #78220 quote
    capngoggles
    Participant
    New

    Hi Roberto,

    sorry about the code.

    Indicator code is below:

    n1 = 10 //Channel Length
    n2 = 21 //Average Length
    
    ap = medianprice
    esa = exponentialaverage[n1](ap)
    apesa = abs(ap - esa)
    d = exponentialaverage[n1](apesa)
    ci = (ap - esa) / (0.015 * d)
    tci = exponentialaverage[n2](ci)
    
    wt1 = tci
    wt2 = average[4](wt1)
    
    RETURN 0 as "0", (wt1-wt2)*20 coloured(0,0,200) as "difference"
    
    #78241 quote
    robertogozzi
    Moderator
    Master

    It works, as far as I understand what it does, I tested it on a Daily TF on a coulple of stocks as from attached pics. I embedded the indicator in the strategy, but this shouldn’t make any difference. I used GRAPH to debug the strategy:

    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    n1 = 10 //Channel Length
    n2 = 21 //Average Length
    ap = medianprice
    esa = exponentialaverage[n1](ap)
    apesa = abs(ap - esa)
    d = exponentialaverage[n1](apesa)
    ci = (ap - esa) / (0.015 * d)
    tci = exponentialaverage[n2](ci)
    wt1 = tci
    wt2 = average[4](wt1)
    //RETURN 0 as "0", (wt1-wt2)*20 coloured(0,0,200) as "difference"
    // Conditions to enter long positions
    indicator1 = (wt1-wt2)*20
    c1 = (indicator1 > 0)
    c2 = (indicator1 < 0) 
    IF c1 THEN
       BUY 5000 CASH AT MARKET
    ENDIF
    // Conditions to exit long positions
    IF c2 THEN
       SELL AT MARKET
    ENDIF
    graph indicator1

    Did you set your initial capital large enough to accomodate all losses?

    x-7.jpg x-7.jpg x1-1.jpg x1-1.jpg
    #78295 quote
    Nicolas
    Keymaster
    Master

    This is a “normal” behavior if you backtest a strategy on a stock you haven’t the real time subscription. Is it the case? 😉

    #78330 quote
    capngoggles
    Participant
    New

    Hi Nicolas and thanks,

    I dont recall it being normal some time ago with the end of day version on other backtests I had. I think I only started seeing it with 10.3 perhaps?

    I wouldnt mind the black stop line signalling the end of run, its the sell signal that is just plain incorrect logic. It should not flag a sell unless the logic says to sell, not the end of program.

    Even if it isnt real time, it shouldnt give misleading signals which are effectively telling you to close out each day. I am trying to use the backtest to work out what I do on the next day, not much use if it constantly tells me every day to close out open positions.

    I dont need real time, since I work the ASX and its not available real time through PRT but I shouldnt expect different behavoiur in the two either.

    Thanks for your help

    John

    #78331 quote
    capngoggles
    Participant
    New

    Thank you Roberto for your effort in setting it up and testing it. The stock I used as an example the capital went up over the period, not down so running out of funds was not an issue.

    As per Nicolas post, It seems realtime works differently to end of day. As I said in response to Nicolas, it would be better with the sell signal not being there.

    End of run line OK, but an end of run shouldnt force a close out of position. I think that is an error.

    Thanks again.

    robertogozzi thanked this post
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

Backtest RHS shows false sell signal


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 6 replies,
has 3 voices, and was last updated by capngoggles
7 years, 6 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 08/15/2018
Status: Active
Attachments: 5 files
Logo Logo
Loading...