@l-andorrà https://fxdreema.com/shared/rf0OwR56c
What is missing is: stop counting when orders are closed by condition and how to determine what was the maximum of open orders until closing
Store how many orders open at the same time
-
-
You can create acounter variable and then count how many trades are open by using a 'For each trade' block. You modify the variable at every pip on the orange dot of the block.
-
@l-andorrà Thank you, in fact this is my problem, unfortunately my 52-year-old dried-up brain is not what I had in high school, I need an example
-
To be more precise, the maximum number of orders opened simultaneously
-
@l-andorrà https://fxdreema.com/shared/rf0OwR56c
What is missing is: stop counting when orders are closed by condition and how to determine what was the maximum of open orders until closing -
@ambrogio said in Store how many orders open at the same time:
@l-andorrà https://fxdreema.com/shared/rf0OwR56c
What is missing is: stop counting when orders are closed by condition and how to determine what was the maximum of open orders until closing -
@ambrogio Take a look here, I think in my example I do similar things https://fxdreema.com/forum/topic/8455/how-can-i-collect-the-latest-open-positions-in-the-event-of-a-trend-change/5
-
Trader.philipps example should be useful for you, ambrogio. And don't be ashamed to be 52. I'm 51 and I can understand you, believe me :D.
-
-
@l-andorrà 49 only .. I lost as a noob
-
I see we're in good company.!!!!
-
@trader-philipps Please take a look at this example, in this case always the count is incremented https://fxdreema.com/shared/w1ZUoXluc
But I need as in this pictureCalmly is not urgent
-
@ambrogio What exactly you want to count (and what not)?
In your example you increase the variable each time a trade is closed by 1
But you want to know how many orders are currently open, right?
The idea is that the number of open orders only change if a new trade is opened or an existing trade is closed.
That's why I use the 2 blocks Trade created and Trade closed on the onTrade tab.
In the screenshot case I have 1 For Each trade for Buys and one for sells. If you just need the total number of both, you just need 1 For each trade block.
Important: Re-set the counter variable on white dot to 0. So it will start the calculation each time by 0.
Than you just add 1 to the counter variable each time the modify Cariabkes block is called (for each trade).
-
@ambrogio said in Store how many orders open at the same time:
To be more precise, the maximum number of orders opened simultaneously
@trader-philipps I need to know the maximum number of orders opened at the same time, in the example above is 19 buy orders, all that is less than 19 I do not need. If later I have a series of 32 orders open at the same time, at that point the number that interests me is 32 and the 19 I no longer need
-
@ambrogio Okay, so you need something like a high watermark? Will that ever be re-set?
By logic you'd do the same as metioned above, but would create another counter variable. This you would only update, if the condition is true that the current counter for open orders is bigger than the high watermark variable. Do you need an example?
-
@trader-philipps Hi! Thanks to your suggestion, I came up with it. This works for me, please take a look, is it too complicated in your opinion?
-
@ambrogio Well, it's not exactly as I would do it. With your approach you wouldn't check for update if a trade gets closed for any other reason by the broker (eg. TP or SL is hit or margin call, etc.). Hence I'd do on both events on the onTrade tab (order opened and order closed) a calculation loop over all currently open trades. Hence your counter would always be up to date.
Check this out!
-
@trader-philipps ok, thank you, talk later
-
@ambrogio Ok. Keep in mind that if you closed the terminal while trades were open, you may want to run the check as well. Alternatively you may store the value of max_orders_buy to a terminal variable (mus be unique per EA instance!) as well and read that variable if existing on the onInit tab.
-
@trader-philipps Thank you very much, it is much better. But please, explain me why in the pass block #40 you put 0 value at V1 variable and why on the white dot? It's the same to reset V1 variable to 0 value?