Forecast of the sum of Stop Loss Calculation of pending or open orders
-
Can you help me?
I want to work with pending orders and already open orders.
All of them will have the same Stop Loss price in the case of a line that I placed on the chart and named as StopLoss.I want my EA to calculate the negative stop loss value of each order individually and add up all these values.
Imagine as in the image below:
I have order 1 open at the price 1880.434 and the white line is at 1859.633
So if we perform the distance calculation we have a distance of:
1880,434-1859,633=20801 points
(20801=distance from opening price)*(current lot 0.07)*100=USD -145.61Now imagine I have a second open order:
1870,622-1859,633= 10989 points
(10989=distance from opening price)*(current lot 0.07)*100=USD -76.92The sum of these 2 orders should then be USD -222.53
In short, I want my EA to be able to get the negative value that each order will cost if a certain market value is set by me and add all these values together.
Can you help me find this out?
For just one order it is very easy but to do this calculation with several orders I am not able to.
-
@ontradingx So you mean you want to add the combined maximum loss of all open trades right now to open a third trade with a stop loss distance worth that combined loss? Are you sure that is a safe money management?
-
In my strategy for some markets, I consider this management to be ideal because it allows you to inform, according to your account balance, how much you would bear if the market went against you, and in this way it would show you exactly the size of your maximum loss even before you authorize the opening of the first order. Manually I've been using it since 12/2020 and my account is with + 800% profit, now I want to automate it. In short, I initially want the calculation to be with pending orders. If I place 10 pending orders on the chart with a distance between them of 100 points and the stop loss of all of them I set to be equal at the same price at 1500 points away from the first order, what would then be the negative value that would be caused if the market hit the stop loss and close all orders? this is what i want. display the total stop loss value of the sum of all orders.
-
-
@ontradingx @l-andorrà
Hi friend, I think I figured it out.
I used the Bucket of positions and "Average Value" block, then I created a few more blocks to calculate the average value of all orders by multiplying by the number of orders and with the price where I want my stop loss target to be.
I haven't finished it yet because the calculation is getting more complex as I progress in creating my EA idea, but it's already one more stage won.
Thanks for making it available to try to help me, I'm often too slow to think about these crazy calculations I want to do in this thankless market heeheh -
@ontradingx You're welcome. If you need more help, just be back here!
