YvesParticipant
Junior
Hi guys, i hope somebody can help me with the following issue.
I wrote a little lot size calculator for my chart. The problem is i just want to get 2 digits after comma instead of 4. I tried a lot of different workarounds like “a=round(mashort*100)/100” and other calculations but nothing works for me.
thanks in advance!
// Risk/Trade
risk = 150
// currval = Accountcurrency / Tradingcurrency -> Trade USDCAD -> EUR / CAD (*10 for standard Lot)
Currval = 6.57
value = 0
atr = AverageTrueRange[5](close)*10000
size = 0
If atr > 100 then
value = round(atr/100+0.5)
else
value = round(atr+0.5)
endif
// size =risk/(value*currval)
size = round(risk/(value*currval)*100)/100
return size as "LOT"
PRT does not allow to set a custom number of digits, so the only available option is to round numbers like you did!
You could do something like this and return the value as an text indicator of its own:
defparam calculateonlastbars = 1
// Risk/Trade
risk = 150
// currval = Accountcurrency / Tradingcurrency -> Trade USDCAD -> EUR / CAD (*10 for standard Lot)
Currval = 6.57
value = 0
atr = AverageTrueRange[5](close)*10000
size = 0
If atr > 100 then
value = round(atr/100+0.5)
else
value = round(atr+0.5)
endif
// size =risk/(value*currval)
size = round(risk/(value*currval)*100)/100
drawtext("#size#",barindex,0) coloured(0,0,0)
return
YvesParticipant
Junior
good idea, i think that works! thx!
Question: Is it necessary to have PorOrder round calculated lot sizes or are they automatically adjusted/rounded upon position entry with IG? Does anybody know?