Stay flat after a big loss

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #65635 quote
    irioton
    Participant
    Average

    Hi ! what would be the code to be flat after a big loss (like 5%) ?

    #65637 quote
    robertogozzi
    Moderator
    Master
    I started a new topic since your question had nothing to do with FLATAFTER. To tell your system to stay flat after a big loss (5% in your case) you have to:
    1. set a variable so that trading is enabled (say TradeOn = 1) and add this condition to Your_Conditions to start a new trade
    2. set a variable with your initial Equity
    3. compare the current strategyprofit agains the previous one AFTER exiting a trade (when OnMarket[1] is true while OnMarket is false)
    4. if the difference is >= -5% you’ll have to set the above said variable TradeOn = 0 so that no more trades are started till you want (you may want to set further conditions to reenable trading)
    5. update your equity
    .
    .
    ONCE BigLoss  = 0.95                                            //5% or more has to be considered a big loss
    ONCE TradeOn  = 1                                               //Trading enabled by default at launchtime
    ONCE Capital  = 10000                                           //Set your initial capital
    IF NOT OnMarket AND OnMarket[1] THEN                            //When a trade is closed ...
       IF (Capital + StrategyProfit) <= (Capital * BigLoss) THEN    //... check if it's a big loss and ...
          TradeOn = 0                                               //... eventually stop trading
       ENDIF
       Capital = Capital + StrategyProfit                           //Update your Equity
    ENDIF
    .
    .
    IF Your_Conditions AND TradeOn AND Not OnMarket THEN
       .
       .
       BUY/SELLSHORT .......
       .
       .
    ENDIF
    .
    .
    Nicolas and irioton thanked this post
    #65664 quote
    irioton
    Participant
    Average
    Hi Robertogozzi ! Thank you for your answer, I think I found simpler in PRT manual :
    //x = maximum loss in euros
    
    IF STRATEGYPROFIT <-x
    
    THEN QUIT
    
    ENDIF
      and thats it ! The goal was to cut the system alltogether in case of an emergency. I put a fixed value, but I am sure it is possible to put a pourcentage instead, tell me what you think. Chears !
    #65671 quote
    robertogozzi
    Moderator
    Master
    The code you found is useful when you want to stay flat after a big loss on the whole equity, so that if you earn 7%, then lose 10% you will keep trading. My code, instead, even if you have earned, say, 30%, once you have a big loss it stops trading, so that you won’t lose all of your profits! It’s up to you to set your own strategy that best fits you!
    #65674 quote
    irioton
    Participant
    Average
    Oh ok, this is a smart one, thank you !
    #65676 quote
    Vonasi
    Moderator
    Master
    We were just discussing something similar to what you have requested on this thread yesterday:
    Backtest sorting by lowest drawdown
    Capital = 3000
    MaxDrawDownPercentage = 66
     
    Equity = Capital + StrategyProfit
    MaxDrawdown = Equity * (MaxDrawDownPercentage/100)
     
    IF OnMarket and ((PositionPrice - low)*CountOfPosition) > MaxDrawDown THEN
    Quit
    ENDIF
    #65678 quote
    GraHal
    Participant
    Master
    My code, instead, even if you have earned, say, 30%, once you have a big loss it stops trading, so that you won’t lose all of your profits!
    I’ve added your code to my Snippet Finder database
    Snippets – Find Here
    PS Anybody can add your own or anybody else’s snippets … please try, it takes less than 1 minute.  
    #65679 quote
    irioton
    Participant
    Average
    Yeeeah ! I love being here, great community ! Talking about snippets, you could add the one for position sizing, I think it was perfected on the Reiner´s Pathfinder thread, and it is great, just an idea…
    #65682 quote
    GraHal
    Participant
    Master
    Hi irioton Please could you add the snippet you mention or any other, then the task is shared? I’m trying to pull together the google sheet so that snippets can be found, sorted and accessed by anybody all in one place. Thank You GraHal
    #65683 quote
    robertogozzi
    Moderator
    Master
    @GraHal, thank you. I’ll add something to that sheet as soon as I can!
    GraHal thanked this post
    #65685 quote
    irioton
    Participant
    Average
    Okay, will do, right away !
    #65687 quote
    irioton
    Participant
    Average
    Money management snippet : OK.
    Nicolas thanked this post
Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.

Stay flat after a big loss


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
irioton @irioton Participant
Summary

This topic contains 11 replies,
has 4 voices, and was last updated by irioton
7 years, 11 months ago.

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