Overall profit limit/target per day

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #14397 quote
    KarlTraderKarlTrader
    Participant
    New

    Hi all, i am new to this forum and still rather new to coding automated strategies.

    I was wondering if it was possible to set a profit/target limit for each day of trading.

    For example within a day i may have numerous trades but do not want to open any more trades once a certain total pipcount/profit or loss is reached. however i do not want to have to restart the program every day. (So that i can use as back test and also have running if i am away, which i am a lot)
    Is this possible and could one of you kind folk show me how.

    many thanks

    #14411 quote
    WingWing
    Participant
    Veteran

    Example:

    MaxDailyProfit=1000
    MaxDailyLoss=1000
    once TradeAllowed=1
    
    If time<010000 then
    MyProfit=STRATEGYPROFIT
    TradeAllowed=1
    endif
    
    If StrategyProfit>MyProfit+MaxDailyProfit or Strategyprofit<MyProfit-MaxDailyLoss then
    TradeAllowed=0
    endif
    
    if TradeAllowed=1 and buyconditions then
    buy 1 lot at market
    endif
    

    This will count only closed positions. To count running positions, you need to add the check to you selling conditions, and change ‘strategyprofit’ to ‘strategyprofit+positionperf(0)’. I have not tested this code, but tell me if it works or not.

    #14441 quote
    KarlTraderKarlTrader
    Participant
    New

    That’s perfect thankyou. I will test it out and let you know the results. Thanks again

    #14474 quote
    NicolasNicolas
    Keymaster
    Legend

    @Wing

    Thanks, I’ll add this in the blog, since it is commonly requested and your code is great.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Overall profit limit/target per day


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
KarlTrader @karltrader Participant
Summary

This topic contains 3 replies,
has 3 voices, and was last updated by NicolasNicolas
9 years, 11 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 10/06/2016
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...