Strategy stop-loss

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #9387 quote
    merc1203
    Participant
    Average

    It appears that the code below only checks the strategy p&l once the current trade is stopped-out?

    Is that right?

    Very often, the marked-to-market p&l is less than the “stopout” level but the algo carries on trading until the current position is exited. It seems to be only then that it checks the strategy p&l. I would like it to check the p&l after every change in price and stop trading immediately the “stopout” level is hit. How is this written?

     

    Many thanks

     

    if StrategyProfit <= StopOut then
    QUIT
    endif

    #9388 quote
    Nicolas
    Keymaster
    Master

    That’s right, STRATEGYPROFIT is updated with closed trades.

    You can use POSITIONPERF to know actual positions PnL.

    #9392 quote
    merc1203
    Participant
    Average

    So,

    strategyprofit + p&l from open positions = realtime p&l

    It seems POSITIONPERF is a ratio.

     

    What is the simplest way to convert this into a currency amount for an open position … positionperf*positionprice?

    Thanks

    #9393 quote
    Nicolas
    Keymaster
    Master

    You can compute the floating profit with this function:

    //floating profit
    floatingprofit = (((close-positionprice)*pointvalue)*countofposition)/pipsize //actual trade gains

    and add it to STRATEGYPROFIT to get the whole account profit (closed trades + not closed ones).

    #9394 quote
    merc1203
    Participant
    Average

    Great – thank you Nicolas

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

Strategy stop-loss


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
merc1203 @merc1203 Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by merc1203
9 years, 8 months ago.

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