Please… I need this part of Code.
If capital is Cross Up 10000€ the Next operations as to 3€.
But, if capital is Cross down 10000€ the Next operations as to 1€.
Thanks!
capital = 10000
equity = capital + strategyprofit
if equity > capital then
positionsize = 3
else
if equity <= capital then
positionsize = 1
endif
endif
if (your conditions) then
buy positionsize contracts at market
endif
The above simply changes between position size of 3 or 1 depending upon if you are above or below 10k. Is this what you mean as your description is not very clear?
Another possibility:
capital = 10000
equity = capital + strategyprofit
once lastchange = capital
once positionsize = 1
if equity > lastchange + 10000 then
positionsize = positionsize * 3
lastchange = lastchange + 10000
else
if equity < lastchange - 10000 then
positionsize = max(1,positionsize / 3)
lastchange = lastchange - 10000
endif
endif
if (your conditions) then
buy positionsize contracts at market
endif
This version multiplies position size by 3 every time a new 10k profit is reached and divides it by 3 every time 10k is lost down to a minimum size of 1.
Not tested.
EDIT:2019/09/04. MIN in line 11 should have been MAX – I have edited the post to correct this.
Thanks Vonasi!
The first publicatión is valid.