Can't get MAX PROFIT/GAIN per day to work

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #131036 quote
    Bel
    Participant
    New
    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    // ---parameters
    MaxDailyProfit=20 //Max daily profit allowed (in money)
    
    once tradeon=1
    
    
    // reset the current state of the strateygprofit each new day
    If intradaybarindex=0 then
    MyProfit=STRATEGYPROFIT
    tradeon = 1
    endif
    
    // test if the strategyprofit of the day is currently above the daily profit allowed of below the daily loss allowed
    If StrategyProfit>=MyProfit+MaxDailyProfit  then
    tradeon = 0
    endif  
    IF  tradeon=1 and c1 AND c2  THEN
    BUY 1 contract AT MARKET
    ENDIF
    
    IF  tradeon=1  and c3 AND c4 THEN
    SELLSHORT 1 contract AT MARKET
    ENDIF
    
    Screenshot-2020-05-10-at-21.52.47.png Screenshot-2020-05-10-at-21.52.47.png
    #131038 quote
    Bel
    Participant
    New

    Good evening.

     

    Been studying how to get my intraday system to stop trading after MAX PROFIT/GAIN reached of lets say 20 euros. https://www.prorealcode.com/blog/learning/max-profit-loss-day-trading-strategy/ has it all outlined but somehow I can’t get it to work. Any help would be appreciated.

    p.s. sorry for the double post as couldnt type my msg after adding PRT code somehow, live and learn)

    Thank you.

    Best regards,

    Bel.

    #213533 quote
    Nicolas
    Keymaster
    Master

    This version works ok:

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    // ---parameters
    MaxDailyProfit=100 //Max daily profit allowed (in money)
    
    once tradeon=1
    
    // reset the current state of the strateygprofit each new day
    If intradaybarindex=0 then
    MyProfit=STRATEGYPROFIT
    tradeon = 1
    endif
    
    // test if the strategyprofit of the day is currently above the daily profit allowed of below the daily loss allowed
    If StrategyProfit>=MyProfit+MaxDailyProfit  then
    tradeon = 0
    endif
    IF  tradeon=1 and rsi[14]crosses over 50  THEN
    BUY 1 contract AT MARKET
    ENDIF
    
    IF  tradeon=1  and rsi[14]crosses under 50 THEN
    SELLSHORT 1 contract AT MARKET
    ENDIF
    
    //graph strategyprofit 
    //graph MyProfit+MaxDailyProfit coloured("orange")
    //graph tradeon
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Can't get MAX PROFIT/GAIN per day to work


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Bel @saulyte1 Participant
Summary

This topic contains 2 replies,
has 1 voice, and was last updated by Nicolas
2 years, 10 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/10/2020
Status: Active
Attachments: 1 files
Logo Logo
Loading...