Assemble two money management codes
Forums › ProRealTime English forum › ProOrder support › Assemble two money management codes
- This topic has 8 replies, 2 voices, and was last updated 7 years ago by Despair.
-
-
09/01/2017 at 7:24 PM #45133
Hello could help me these two MM codes to build that they function with each other
1.
once multiplier=1
once fraction=1000
once newlevel=1000
once oldlevel=1000
once startpositionsize= 10
once positionsize=startpositionsize
if sp>newlevel then
multiplier=multiplier+1
oldlevel=newlevel
newlevel=sp+multiplier*fraction
positionsize=multiplier*startpositionsize
elsif sp<oldlevel and multiplier>=2 then
newlevel=sp
oldlevel=sp-multiplier*fraction
multiplier=multiplier-1
positionsize=multiplier*startpositionsize
endif2.
once os=positionsize //3 // ordersize – can be any number depending on account size;
once osa=os
once teilung=1// 1.5 //1.5 reducing the ordersize after winning trade
once ff=3 //increasing ordersize after losing trade;
once maxcon=ff*os //ff*ff*os+os// defining the maximum ordersize;
if strategyprofit<strategyprofit[1] then // increasing ordersize when losing
os=os*ff
if os>maxcon then
os=maxcon
endif
start=1
endifif strategyprofit>strategyprofit[1] then // decreasing ordersize when winning
start=1
os=os/teilung
if os<osa then
os=osa
endif09/01/2017 at 8:15 PM #45163he second code is to double after a loss the position size until the capital has reached the last highest level before the loss.
an example
start 1000
trade profit with 10 positions1100
trade profit with 10 positions 1200
trade profit with 10 positions 1300
trade loss with 10 positions 1100
trade loss with 20 positions 700
trade profit with 20 positions 900
trade profit with 20 positions 1100
trade profit with 20 positions 1300 (> 1300) = last highest score
next trade again with 10 positions09/02/2017 at 11:13 AM #45217The first looks like an old version of my fixed fraction MM. I raised it since then to calculate correctly also when start equity is <>0. Now you ask for the code for a martingale. I code this long ago. Haven’t looked at the code for a long time so there might be an error inside (but maybe not). Here you go:
Martingale12345678910111213141516171819202122232425262728//-------------------Martingale------------------------if martingale theninccounter=1if strategyprofit[1]>=saldo thenpositionsize=startpositionsizealreadyinc=0saldo=strategyprofit[1]endifif not onmarket and not alreadyinc thenwhile positionperf(inccounter)<0 doinccounter=inccounter+1if positionsize<maxpositionsize thenpositionsize=positionsize*2endifwendalreadyinc=1saldobar=barindex-tradeindex(inccounter)saldo=strategyprofit[saldobar]endifif alreadyinc and saldo>strategyprofit[1] and tradeindex=barindex and posit ionperf(1)<0 thenif positionsize<maxpositionsize thenpositionsize=positionsize*2endifendifif onmarket thenpositionsize=abs(countofposition)endifendif09/02/2017 at 10:00 PM #4525609/02/2017 at 10:29 PM #45258I still have problems with the code,
my first question is what do I do with the variable martingale?
with maxpositionsize I could set it that the code me doubled only once the old capital is reached, then I can use in however no longer with the first code
the last is the still works but still not with the first code it no positions increased after the adjusted capital gain (eg 1000 as adjusted)
09/02/2017 at 10:52 PM #45261so simply said I would have the increase of the position size after a loss only once to reach the old peak level is synonymous if several losses come in series, and I just do not understand why it no longer with the here first code to increase the positions after reach the Capital gains.
I would also have an idea, I believe it would be better positions to increase point gains not for money gains, which would somehow look like strategyprofit divided by position size?
09/02/2017 at 11:38 PM #45262The two codes are not thought to work together. The martingale is reseting the position size to startpostionsize. You will have to change this to make it work. Then I haven’t thought through if this two codes work together or if there are other problems.
The martingale variable is only a switch turn it on/off.
For the money management better use this revised code:
Fixed fraction MM123456789101112131415161718192021222324//------------ Fixed fraction money management ----------once multiplier=1once startpositionsize=1once positionsize=startpositionsizeonce delta=100once fraction=delta*pipvalueonce newlevel=delta*pipvalueonce oldlevel=delta*pipvalueif strategyprofit+startequity>newlevel theni=0oldlevel=newlevelnewlevel=0while newlevel<=strategyprofit+startequity doi=i+1newlevel=newlevel+i*fractionwendmultiplier=ipositionsize=multiplier*startpositionsizeelsif strategyprofit+startequity<oldlevel and multiplier>=2 thennewlevel=strategyprofit+startequityoldlevel=strategyprofit+startequity-multiplier*fractionmultiplier=multiplier-1positionsize=multiplier*startpositionsizeEndif09/03/2017 at 3:12 PM #4529409/03/2017 at 6:51 PM #45311I’m aware of that. This is a revised version of one of the two codes you want to combine and I recommended you to take this version for your affords.
Then I don’t see an advantage of using points instead of profit. points*pointvalue=strategyprofit and since pointvalue is a constant it doesn’t really make a difference if you use points or profit.
-
AuthorPosts
Find exclusive trading pro-tools on