This code snippet demonstrates how to implement a dynamic money management system and handle positions over the weekend in a trading strategy using ProBuilder language. The money management system adjusts the position size based on the strategy’s profit, and the weekend handling ensures that all positions are closed by Friday night to avoid holding them over the weekend.
once startpositionsize=1
once positionsize=startpositionsize
once flatoverweekends=1
once startequity=0
once Reinvest=1
if reinvest then
//------------ Fixed fraction money management ----------
once multiplier=1
once delta=200 // < == THROTTLE
once fraction=delta*pipvalue
once newlevel=delta*pipvalue
once oldlevel=delta*pipvalue
if strategyprofit+startequity>newlevel then
multiplier=multiplier+1
oldlevel=newlevel
newlevel=strategyprofit+startequity+multiplier*fraction
positionsize=multiplier*startpositionsize
elsif strategyprofit+startequity=2 then
newlevel=strategyprofit+startequity
oldlevel=strategyprofit+startequity-multiplier*fraction
multiplier=multiplier-1
positionsize=multiplier*startpositionsize
endif
Endif
if flatoverweekends then
//--------------- daylight-saving corrections ------------------
if currentmonth=3 and day>=15 then
dlc=10000
elsif currentmonth=11 and day<8 then
dlc=10000
else
dlc=0
endif
fridaynight=(currentdayofweek=5 and time>=(223000-dlc))
else
fridaynight=0
endif
if fridaynight then
if longonmarket then
sell at market
elsif shortonmarket then
exitshort at market
endif
endif
The code snippet above includes several key components:
This example is useful for understanding how to dynamically manage investment size based on performance and how to mitigate risks associated with holding positions over the weekend in financial markets.
Check out this related content for more information:
https://www.prorealcode.com/topic/money-management-snippet/#post-70501
Visit Link