Money management help with step size of lot increasing

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

    Hi,

    I’m new to this and I’m having trouble to make this money management code for my system to work the way I want it to.

    I found a nice code with fixed fraction that  member Despair hade posted some time ago:

    once multiplier=1
    once fraction=1000
    once newlevel=1000
    once oldlevel=1000
    once startpositionsize=1
    once positionsize=startpositionsize
    if strategyprofit>newlevel then
      multiplier=multiplier+1
      oldlevel=newlevel
      newlevel=strategyprofit+multiplier*fraction
      positionsize=multiplier*startpositionsize
    elsif strategyprofit<oldlevel and multiplier>=2 then
      newlevel=strategyprofit
      oldlevel=strategyprofit-multiplier*fraction
      multiplier=multiplier-1
      positionsize=multiplier*startpositionsize
    endif

    The code works exactly the way i want it to, however I want the system to start at 3 contracts instead of 1. But when I try to raise my startPositionSize to 3.. every time I make profits/losses it increases/decreases the next positionsize by 3 instead of 1.

    e.g. 3, 6, 9, 12, 9 , 12, 15 etc.

    I want it to start with 3 contracts and then increase/decrease positionsize by only 1 contract steps at the time based on profits/losses.

    e.g. 3, 4, 5, 6, 5, 4,

    If someone can help me with this I would be very grateful!

    #105354 quote
    NicolasNicolas
    Keymaster
    Legend

    We need to create a new variable named “step” at the beginning of the code:

    once multiplier=1
    once fraction=1000
    once newlevel=1000
    once oldlevel=1000
    once startpositionsize=1
    once positionsize=startpositionsize
    once step = 1
    
    if strategyprofit>newlevel then
      multiplier=multiplier+1
      oldlevel=newlevel
      newlevel=strategyprofit+multiplier*fraction
      positionsize=multiplier*step//startpositionsize
    elsif strategyprofit<oldlevel and multiplier>=2 then
      newlevel=strategyprofit
      oldlevel=strategyprofit-multiplier*fraction
      multiplier=multiplier-1
      positionsize=multiplier*step//startpositionsize
    endif

    That should work, I have not tested it, please do 😉

    marcusstrom87 thanked this post
    #105363 quote
    marcusstrom87marcusstrom87
    Participant
    New

    Thx alot Nicolas! 😀

    Works better!

    However, the first time when it’s suppose to increase the contractssize from 3 to 4, it starts over from 2 contracts and then works it’s way up from that point one step at the time.

    E.g. I start my backtest with 3 contracts as the startingpoint, everything works fine. But then when I have reached my first strategyprofit step (profit), it goes down to 2 contracts, when I actually would like it to go up to 4 contracts.

    Do you know how to solve this last piece of the puzzle? 🙂

    #105367 quote
    NicolasNicolas
    Keymaster
    Legend

    Hmm.. if you only want to increase/decrease your lot size according of when you loose or win, that code is not really appropriate!

    marcusstrom87 thanked this post
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

Money management help with step size of lot increasing


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by NicolasNicolas
7 years, 1 month ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 08/23/2019
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...