Problem with “Trading the strategy profit curve”

Viewing 15 posts - 1 through 15 (of 21 total)
  • Author
    Posts
  • #168558 quote
    Link
    Participant
    Senior

    I am trying to adapt this Nicolas Money management system to my strategy.

    The problem is that I can’t get that when the strategy profit falls below the equity curve the system stops operating.

     

    So far what I have is this:

    //variables
    equitycurve = undefined
    curveperiod = 17280
    once mydays = 1
    once olddate = 0
     
    //indicators
    equitycurve = average[curveperiod](strategyprofit)
     
    //mydays variable incrementing to let the average curve build over time
    if date > olddate then
    mydays=mydays+1
    olddate = date
    endif
     
    //first trades while the average profit curve is building
    IF CONDBUY and Strategyprofit <= 20000 and NOT LongOnMarket AND mydays<curveperiod THEN
    ONCE Positionsize = 0.5
    buy positionsize contract at market
    SET TARGET %PROFIT 2
    SET STOP %LOSS 1.5
    ELSE
    //trades when the curve has built
    IF CONDBUY and Strategyprofit <= 20000 and NOT LongOnMarket AND strategyprofit>=equitycurve AND mydays>curveperiod THEN
    ONCE Positionsize = 0.5
    buy positionsize contract at market
    SET TARGET %PROFIT 2
    SET STOP %LOSS 1.5
    ENDIF
    ENDIF
    
    //first trades while the average profit curve is building
    IF CONDBUY and Strategyprofit >= 20000 and NOT LongOnMarket AND mydays<curveperiod THEN
    ONCE Positionsize = 0.5
    buy positionsize contract at market
    SET TARGET %PROFIT 2
    SET STOP %LOSS 1.5
    ELSE
    //trades when the curve has built
    IF CONDBUY and Strategyprofit >= 20000 and NOT LongOnMarket AND strategyprofit>=equitycurve AND mydays>curveperiod THEN
    ONCE Positionsize = 0.5
    buy positionsize contract at market
    SET TARGET %PROFIT 2
    SET STOP %LOSS 1.5
    ENDIF
    ENDIF
     
    GRAPH equitycurve coloured(255,0,0) as "equity curve"
    GRAPH strategyprofit as "strategy profit"
    

     

     

    Function.png Function.png
    #168560 quote
    GraHal
    Participant
    Master

    Have you tried with Line 2 commented out, Rem’d out?

    Also the CurvePeriod is very large, how did you arrive at 17280?

    Just a few thoughts.

    #168561 quote
    Link
    Participant
    Senior

    17280 is 60 days of trading on 5 minutes bars.

    3 montes.

    #168562 quote
    Link
    Participant
    Senior

    This is the link of Nicolás strategy.

     

    https://www.prorealcode.com/blog/trading-strategy-profit-curve/

    GraHal thanked this post
    #168563 quote
    GraHal
    Participant
    Master

    From the link you posted, it states the code was written for PRT v10.2 so maybe it does not wotk correctly on v11.

    Just more thoughts from me, but hopefully a coding wizard will be along to help you.

    #168564 quote
    Link
    Participant
    Senior

    My versión es 10.2 or 10.3.

    #168565 quote
    robertogozzi
    Moderator
    Master

    Lines 48-50 do the job:

    //variables
    ONCE equitycurve = 0
    curveperiod = 17280
    once mydays = 1
    once olddate = 0
     
    //indicators
    equitycurve = average[curveperiod](strategyprofit)
     
    //mydays variable incrementing to let the average curve build over time
    if date > olddate then
    mydays=mydays+1
    olddate = date
    endif
    CONDBUY = close crosses over average[200,0](close)
    //first trades while the average profit curve is building
    IF CONDBUY and Strategyprofit <= 20000 and NOT LongOnMarket AND mydays<curveperiod THEN
    ONCE Positionsize = 0.5
    buy positionsize contract at market
    SET TARGET %PROFIT 2
    SET STOP %LOSS 1.5
    ELSE
    //trades when the curve has built
    IF CONDBUY and Strategyprofit <= 20000 and NOT LongOnMarket AND strategyprofit>=equitycurve AND mydays>curveperiod THEN
    ONCE Positionsize = 0.5
    buy positionsize contract at market
    SET TARGET %PROFIT 2
    SET STOP %LOSS 1.5
    ENDIF
    ENDIF
     
    //first trades while the average profit curve is building
    IF CONDBUY and Strategyprofit >= 20000 and NOT LongOnMarket AND mydays<curveperiod THEN
    ONCE Positionsize = 0.5
    buy positionsize contract at market
    SET TARGET %PROFIT 2
    SET STOP %LOSS 1.5
    ELSE
    //trades when the curve has built
    IF CONDBUY and Strategyprofit >= 20000 and NOT LongOnMarket AND strategyprofit>=equitycurve AND mydays>curveperiod THEN
    ONCE Positionsize = 0.5
    buy positionsize contract at market
    SET TARGET %PROFIT 2
    SET STOP %LOSS 1.5
    ENDIF
    ENDIF
    
    IF StrategyProfit CROSSES UNDER equitycurve THEN
    QUIT
    ENDIF
    
    GRAPH equitycurve coloured(255,0,0) as "equity curve"
    GRAPH strategyprofit as "strategy profit"
    #168566 quote
    Link
    Participant
    Senior

    Ok Roberto.

     

    But isnt “QUIT”.

     

    Is pause trading only.

    #168567 quote
    robertogozzi
    Moderator
    Master

    You wrote “system stops operating“. Indeed pausing it makes no sense, since it’s almost like QUIT if you don’t add any condition to resume operations, but… there you go:

    //variables
    ONCE equitycurve = 0
    curveperiod = 17280
    once mydays = 1
    once olddate = 0
    
    //indicators
    equitycurve = average[curveperiod](strategyprofit)
    
    ONCE TradeON = 1
    IF StrategyProfit CROSSES UNDER equitycurve THEN
    TradeON = 0
    ENDIF 
    //mydays variable incrementing to let the average curve build over time
    if date > olddate then
    mydays=mydays+1
    olddate = date
    endif
    CONDBUY = close crosses over average[200,0](close) AND TradeON
    //first trades while the average profit curve is building
    IF CONDBUY and Strategyprofit <= 20000 and NOT LongOnMarket AND mydays<curveperiod THEN
    ONCE Positionsize = 0.5
    buy positionsize contract at market
    SET TARGET %PROFIT 2
    SET STOP %LOSS 1.5
    ELSE
    //trades when the curve has built
    IF CONDBUY and Strategyprofit <= 20000 and NOT LongOnMarket AND strategyprofit>=equitycurve AND mydays>curveperiod THEN
    ONCE Positionsize = 0.5
    buy positionsize contract at market
    SET TARGET %PROFIT 2
    SET STOP %LOSS 1.5
    ENDIF
    ENDIF
     
    //first trades while the average profit curve is building
    IF CONDBUY and Strategyprofit >= 20000 and NOT LongOnMarket AND mydays<curveperiod THEN
    ONCE Positionsize = 0.5
    buy positionsize contract at market
    SET TARGET %PROFIT 2
    SET STOP %LOSS 1.5
    ELSE
    //trades when the curve has built
    IF CONDBUY and Strategyprofit >= 20000 and NOT LongOnMarket AND strategyprofit>=equitycurve AND mydays>curveperiod THEN
    ONCE Positionsize = 0.5
    buy positionsize contract at market
    SET TARGET %PROFIT 2
    SET STOP %LOSS 1.5
    ENDIF
    ENDIF
     
     
    GRAPH equitycurve coloured(255,0,0) as "equity curve"
    GRAPH strategyprofit as "strategy profit"

    I added lines 10-13, then added TradeON to CONDBUY at line 19.

    #168568 quote
    Link
    Participant
    Senior

    Ok Roberto.

     

    This afternoon i see.

     

    Thanks!

    #168570 quote
    Link
    Participant
    Senior

    With this code the system stops operating when the profit strategy falls below the equity curve.

    It is about operating again when the profit strategy crosses up the equity curve again.

    Captur5.png Captur5.png
    #168572 quote
    robertogozzi
    Moderator
    Master

    How can the curve go up again if trading is paused?

    Try adding this AFTER line 13:

    IF StrategyProfit CROSSES OVER equitycurve THEN
        TradeON = 1
    ENDIF
    #168573 quote
    Link
    Participant
    Senior

    No function.

     

    🙁

    #168574 quote
    Link
    Participant
    Senior

    Equity Curve Average Filter

     

    This Code thats OK!!!!!!!!!!!!!!

     

    🙂

    #168577 quote
    Link
    Participant
    Senior

    It does something, but this code doesn’t work well either.

    It should stop operating but continues to operate.

    yo.png yo.png
Viewing 15 posts - 1 through 15 (of 21 total)
  • You must be logged in to reply to this topic.

Problem with “Trading the strategy profit curve”


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Link @tony-manero Participant
Summary

This topic contains 20 replies,
has 3 voices, and was last updated by Link
4 years, 6 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/02/2021
Status: Active
Attachments: 4 files
Logo Logo
Loading...