Drawdowns safety

Viewing 15 posts - 16 through 30 (of 32 total)
  • Author
    Posts
  • #149195 quote
    Fran55
    Participant
    Veteran

    I’m not worth Grahal.
    The bot is to be fully autonomous

    #149206 quote
    GraHal
    Participant
    Master

    Sounds like you seek the holy grail  … nobody has found it yet!? 🙂

    #149211 quote
    Fran55
    Participant
    Veteran

    Yes, i work in Santo Grial.

    #149213 quote
    nonetheless
    Participant
    Master

    You could try this MM by Vonasi. You can set it to go back to the starting positionsize after a certain % drawdown.

    //MONEY MANAGEMENT Vonasi
    
    Capital = 10000
    MinSize = 1                 //The minimum position size allowed for the instrument.
    MM1stType = 0               //Starting type of moneymanagement. Set to 0 for level stakes. Set to 1 for increasing stake size as profits increase and decreasing stake size as profits decrease. Set to 2 for increasing stake size as profits increase with stake size never being decreased.
    MM2ndType = 1               //Type of money management to switch to after TradesQtyForSwitch number of trades and ProfitNeededForSwitch profit has occurred
    TradesQtyForSwitch = 10    //Quantity of trades required before switching to second money management choice.
    ProfitNeededForSwitch = 3   //% profit needed before allowing a money management type change to MM2ndType.
    DrawdownNeededToSwitch = 5 //% draw down from max equity needed before money management type is changed back to MM1stType.
    DrawdownNeededToQuit = 35   //% draw down from max equity needed to stop strategy
     
    Once MoneyManagement = MM1stType
     
    Equity = Capital + StrategyProfit
    maxequity = max(equity,maxequity)
     
    if equity < maxequity * (1 - (DrawdownNeededToSwitch/100)) then
    enoughtrades = 0
    tradecount = 0
    moneymanagement = MM1stType
    endif
     
    if equity < maxequity * (1 - (DrawdownNeededToQuit/100)) then
    quit
    endif
     
    if not EnoughTrades then
    if abs(countofposition) > abs(countofposition[1]) then
    tradecount = tradecount + 1
    endif
    if tradecount > TradesQtyForSwitch and maxequity >= Capital * (1 + (ProfitNeededForSwitch/100)) then
    EnoughTrades = 1
    MoneyManagement = MM2ndType
    endif
    endif
     
    IF MoneyManagement = 1 THEN
    PositionSize = Max(MinSize, Equity * (MinSize/Capital))
    ENDIF
     
    IF MoneyManagement = 2 THEN
    PositionSize = Max(LastSize, Equity * (MinSize/Capital))
    LastSize = PositionSize
    ENDIF
     
    IF MoneyManagement <> 1 and MoneyManagement <> 2 THEN
    PositionSize = MinSize
    ENDIF
     
    PositionSize = Round(PositionSize*100)
    PositionSize = PositionSize/100
     
     
    // Size of POSITIONS
    PositionSizeLong = 1 * positionsize
    PositionSizeShort = 1 * positionsize
    #149297 quote
    Fran55
    Participant
    Veteran
    The bot must remember at what price it entered the last trade.
    And if this operation is negative, operate in the following operations with half until it exceeds the drawdown.

    Once the drawdown has been overcome, return to operating with what it operated before the drawdown occurred.

    Example:
    The bot is trading with € 3.5 and earning in the historical € 20,000.
    The bot loses a trade and starts a drawdown.
    The bot is still operating, but at € 1.75.
    Time passes, the bot once again exceeds the historical € 20,000.
    The bot operates again at € 3.5.

    This is what I would like to do, I don’t know if it’s possible.

    #149298 quote
    robertogozzi
    Moderator
    Master

    That’s exactly what my code does https://www.prorealcode.com/topic/drawdowns-safety/#post-148910.

    Why don’t you use it?

    #149357 quote
    Fran55
    Participant
    Veteran
    Okay, another problem Roberto.

    Your code works.
    The Minsize = € 0.5, but if in the first operations of the strategy there are losses, for example when it operates at € 0.75, the half is € 0.37, and since the minimum of IG to operate dax is € 0.5 the strategy stops.

    Solution???

    #149363 quote
    GraHal
    Participant
    Master

    Solution???

    Start off at $1 then it will go to $0.5 after a loss … not hard is it?

    You will be testing in Demo anyway so starting at $1 is not a problem?

    #149371 quote
    robertogozzi
    Moderator
    Master

    It’s like trying to spare on car wheels, you buy 3 instead of 4, but it’s impossible to make it move…. buy 4 or use a bike!

    GraHal thanked this post
    #149380 quote
    Fran55
    Participant
    Veteran

    True!

    Im an idiot.

     

    🙁

    #149409 quote
    Fran55
    Participant
    Veteran

    Ok, new problem.

    I thought that was the problem, but no, the system stops the same.

    #149474 quote
    robertogozzi
    Moderator
    Master

    Joking apart, you can use this snippet, modified to make the number of contracts not to drop below the minimum od 0.5:

    Once MaxProfit   = 0
    Once InitialSize = 1
    MaxProfit        = max(MaxProfit,StrategyProfit)
    LotSize          = InitialSize
    If MaxProfit > StrategyProfit Then
       LotSize = max(0.5,InitialSize / 2)
    Endif
    #149586 quote
    Fran55
    Participant
    Veteran
    We get closer …

    But for some reason, it goes from operating from € 6.83 to € 2.83 … when it should go from operating from € 6.83 to € 3,415.

    Maybe the “Round” command is missing ???

    Screenshot_7.png Screenshot_7.png
    #149589 quote
    robertogozzi
    Moderator
    Master

    You can try using ROUND(), but this will remove decimals.

    To be able to tell exactly you should post your code.

    #149773 quote
    Fran55
    Participant
    Veteran

    Problema resolved.

     

    🙂

Viewing 15 posts - 16 through 30 (of 32 total)
  • You must be logged in to reply to this topic.

Drawdowns safety


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Fran55 @fran55 Participant
Summary

This topic contains 31 replies,
has 6 voices, and was last updated by Fran55
5 years, 3 months ago.

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