Hi everyone!
I find a way to join the market with the exact risk that I wanna take in each trade, and wanted to share it with you.
capitalinicial = 10000 //Capital
riesgo = 0.07 // risk per operation
REM Money management
equity = capitalinicial+strategyprofit
maxriesgo = round(equity*riesgo)
REM Stop distance
pipstop = //your stop variable or number
REM Calculate contracts
myLOT = abs(((maxriesgo/pipstop)/PointValue)*pipsize)
MyLOT will be the number of contracts in next operation:
if myconditions then
buy myLOT contracts at market
endif
Seems that it’s working ok for me. Enjoy it!
Thanks a lot Adolfo! Much appreciated to share this code snippet with the community. It makes me think that we could create some kind of “perfect” codes examples for usual needs like money management, grid orders, stop trailing, etc.. What do you think?
Exactly what i was looking for! I will contribute on this as much as i can!
Cheers!