Gain Today and Latent Gain

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #26822 quote
    deletedaccount14122020
    Participant
    New

    Hi Nicolas,

    Can you tell me if it’s possible to get access to the fields “Gain Today” and “Latent Gain” from the Order Book area.

    I’m trying to build into my system a piece of code which will allow me to set a profit level for the strategy so when “Gain Today” or “Latent Gain” reach a certain level all trades for the strategy are closed and the system stopped. Am I thinking along the correct lines here or is there another way to code this.

    Many thanks

    #26827 quote
    Wing
    Participant
    Veteran

    For daily gain or loss, see code snippet below. For total gain, just use strategyprofit. Adapt the code to your needs (exiting strategy for example.)

    // ---parameters 
    MaxDailyProfit=1000 //Max daily profit allowed (in money)
    MaxDailyLoss=1000 //Max daily loss allowed  (in money)
    
    // first time we launch the code, the trading is allowed
    once TradeAllowed=1
    
    // reset the current state of the strateygprofit each new day
    If intradaybarindex=0 then
     MyProfit=STRATEGYPROFIT
     TradeAllowed=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 or Strategyprofit<=MyProfit-MaxDailyLoss then
     TradeAllowed=0
    endif
    
    // initiate a new BUY order
    if TradeAllowed=1 and buyconditions then
     buy 1 lot at market
    endif
    Nicolas thanked this post
    #26828 quote
    deletedaccount14122020
    Participant
    New

    Hi Wing,

    Many thanks for your speedy response to my question. This gives me the information I need.

    Regards

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

Gain Today and Latent Gain


ProOrder: Automated Strategies & Backtesting

New Reply
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by deletedaccount14122020
9 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 03/01/2017
Status: Active
Attachments: No files
Logo Logo
Loading...