adding 1 contract for every loser

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #147004 quote
    ullle73
    Participant
    Senior
    //Money Management
    MM = 1 // 0 - disable, 1 - enable
    if MM = 0 then
    positionsize = 1
    ENDIF
    if MM = 1 then
    //Configuration ----
    once maxSize = 4 //maximum lot size
    once minSize = 1 //maximum lot size
    once startingsize = 1 //starting lot size
    once stepsize = 1 //lot step size to increase/decrease
    once resetafterlost = 1 //reset to starting lot size when loss. 0 - disable, 1 - enable
    once doublestepdown = 1 //double the stepsize for decrease when loss. 0 - disable, 1 - enable
    once resetafterstrikewin = 2 //reset the lot size to starting size after n wins
    //Configuration ----
    
    once positionsize = startingsize
    once wincount = 0
    if strategyprofit <> strategyprofit[1] then
    if positionperf(1)>0 then
    if positionsize < maxSize then
    positionsize = positionsize + stepsize
    endif
    wincount = wincount + 1
    if wincount >= resetafterstrikewin then
    positionsize = startingsize
    wincount = 0
    endif
    else
    if resetafterlost then
    positionsize = startingsize
    elsif doublestepdown then
    positionsize = positionsize - stepsize * 2
    else
    positionsize = positionsize - stepsize
    endif
    wincount = 0
    endif
    endif
    
    if positionsize < minSize then
    positionsize = minSize
    endif
    ENDIF

    Found this code. Cant figure out what to change to add 1 contract to every losing trade. If losing trade, add positionsize+1. Reset after x winning trades in a row

    #147008 quote
    ullle73
    Participant
    Senior

    tries this one as well, but cant seem to get it to work…

     

    ONCE positionSize  = 1
    IF StrategyProfit < StrategyProfit[1] THEN
    positionSize = positionSize + 1
    if StrategyProfit > StrategyProfit[1] THEN
    positionSize = positionSize 
    endif
    ENDIF
    #147016 quote
    robertogozzi
    Moderator
    Master

    I think position sizing should be completely redesigned because as it is now it supports many ideas other than increasing positions after a loss.

    Nevertheless I think that replacing line 35 with:

    positionSize = positionSize + 1

    and at the same time you should set to 0 the two variables at lines 12 and 13 could do.

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

adding 1 contract for every loser


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
ullle73 @jonas_rydqvist Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by robertogozzi
5 years, 4 months ago.

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