I have created a simple indicator. When a long condition is triggered I want to call up the value of the user defined indicator “2ATR long stop loss indicator”, divide the entry price by this amount, to calculate the position size to use for the trade. “Fund” is a defined amount – for example fund = 10000. C1 is a simple moving average cross over.
See code below – but it is not working. Where am I going wrong?
Thanks for your help.
Position size determined from user defined indicator
1
2
3
4
5
IFc1THEN
SLprice=POSITIONPRICE-CALL"2ATR long stop loss indicator"
You can add the function “round” to PositionSize, as PositionSize = round(fund / SLprice), nethertheless your PositionSize is working without “round”
I think POSITIONPRICE is only working if an position is really opened.
Alseo maybe an error into the code : CALL“2ATR long stop loss indicator”, can you show us the code ? (except with an instruction ONCE, it’s recommanded to avoid the call function)
Hi – I’ve added the code for the indicator below. I’ve put this code in instead of calling up the indicator value and that now works.
However it is rounding the position size to a whole number – I want it rounded to two decimal places – how can I do that? So say fund is 100, indicator (2xATR) is 15 I want the position size to be 100/15 (2 decimal places) = 6.67.
Thanks for your help – I am quite new to this and it seems for every step forward at the moment I need to take ten steps back !
Indicator to show price less 2xATR
1
2
3
4
5
6
//Indicator to show the price MINUS a multiple of ATR
To help us continually offer you the best experience on ProRealCode, we use cookies. By clicking on "Continue" you are agreeing to our use of them. You can also check our "privacy policy" page for more information.Continue