Simple position size calculation using user defined indicator

Forums ProRealTime English forum ProBuilder support Simple position size calculation using user defined indicator

Viewing 5 posts - 1 through 5 (of 5 total)
  • #40909

    Hi

    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.

    #40950

    Which error message you get?

    #40957
    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) 
    1 user thanked author for this post.
    #41035

    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 !

    #41036

    Try with:

     

Viewing 5 posts - 1 through 5 (of 5 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login