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

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

Currently, there are 0 users and 1 guest visiting this topic.
View all attachments
Viewing 5 posts - 1 through 5 (of 5 total)
• #144839 Report

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

###### Attachments:
1. Decision.itf
#144884 Report

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 Report

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 Report

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 Report

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.
Viewing 5 posts - 1 through 5 (of 5 total)