Calculate Position Size based on fixed risk (ie. $100)

Forums ProRealTime English forum ProOrder support Calculate Position Size based on fixed risk (ie. $100)

Viewing 7 posts - 1 through 7 (of 7 total)
  • #144839

    Hi,

    In the attached code I tried to calculate the position size based on a fixed risk of $100 with a profit target of $200. But for some reason it sometimes does it correctly and sometimes it doubles the position size which then for a losing trade causes twice as the defined loss (-$200) and also gets twice the profit (+$400) in case of a winning trade. This happens for long and short trades. I tested it on AUDUSD.

    I thought the code is correct (see line 105-132 and line 216-254) but there must be a mistake that I can’t see it.

     

    The second problem is, that when there is a long position and then a new short position is triggered, the long position will be closed. How can I avoid that?

    Thank you.

    Sascha

    #144884

    Hi,

    This is the part of the code that should calculate the position size.

    If anyone can find the mistake, I would be very grateful.

    What it should do, is simply use the current close and the lowest low of the last two days as the initial stop loss (for a long trade) and use twice that risk as a profit target.

    Thanks.

    #144886

    I don’t see any reason why it doubles the contract size. Are you sure you have set the cumulating orders to false?

    In order to not order a contrarian order while you are already at market, just add “AND NOT ONMARKET” in your conditions lines 3 and 16.

    1 user thanked author for this post.
    #144888

    Thank you Nicolas for your quick reply. You’re a genius. I indeed still had set the cumulating orders to True. It’s now not doubling anymore the position size.

    Regarding a contrarian order: How can I allow a contrarian order to be placed without closing the existing order?

     

    #144893

    It is not possible to hedge position with ProOrder sorry. The only possibility is to divide your strategy into 2 separated ones, 1 for buy orders and 1 for sellshort orders.

    1 user thanked author for this post.
    #162650

    I have max risk set to $300, but this is giving me position size of 61 contract on NASDAQ. The order list shows 1 position with 2100$ loss. It has correct size in other orders. Why would it do this?

    I have attached the image. The risk graph is flat meaning the risk is always $300, position size has spiked around the area. The largest spike in the image on 4th bar from where my cursor is 189 contracts size

    #162651

    This is the code being used with accumulating order set to false

     

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

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