@alfi said in stop after a condition and some buys and then reactivate when the condition occurs again.:
EA stop after a condition occurs and make a defined number of buys
How can your EA make buys when stopped? You mean manual trades?
@alfi said in stop after a condition and some buys and then reactivate when the condition occurs again.:
EA stop after a condition occurs and make a defined number of buys
How can your EA make buys when stopped? You mean manual trades?
@feliziano7 why the counters here?

Otherwise I dont see anything wrong here, you'll have to provide some screenshots explaining whats happening and what you expected
thats not the only error though, lol
To find the erroneus block, open the .mql4 in metaeditor and try to compile in there. Then you can double-click the error message and you get the code line in question.

Then scroll up the code and you will soon find the corresponding fxdreema block:

I suspect your variable name is wrong here. Perhaps you have declared "last_candle_close_price" but you try to use "LastCandleClosePrice"

@luigi_123 this block is unnecessary (and incorrectly used)

@cesardefez something like this might work
https://fxdreema.com/shared/yYbSk9vke
@cesardefez you cant "add to volume" of history trades. Use the "buy now" block
@ambrogio the first level is random? Just put the first level in a variable, set up some constant deviation and multiply it to further levels.
Opening new buys after TP is not very optimal, you are gifting spreads and commissions to your broker.
@khalids222 use a loop block to select the trade and then you can use condition or modify variables to get the profit of that individual trade:

@khalids222 said in I have fixed volume for all trades and want to close equal trades from buy and sell:
@roar Thank you, I appreciate your efforts and creativity. I will try it now
But I have a question, how can I know the value of the lot in some way? As an amount or points, not a number?
One lot is $100 000, you can just calculate it
@khalids222 alternatively we could just wait for the trades to line up, so that win = loss +/- 2%:
https://fxdreema.com/shared/DWK422a2d
@khalids222 ok, this is actually pretty hard a problem. To pair wins and losses together, you must only partially close the bigger trade. Mql4 doesnt really support partial closing, it just closes the whole trade and then creates another trade with smaller volume. Because of this, you will always see your balance change.
https://fxdreema.com/shared/nSulvMHEd
@khalids222 ok, so I made the netting for lot amount but you need netting for profit amount. Let me think of something.. .
@khalids222 we can add an age filter before the netting system:
https://fxdreema.com/shared/gKzcKNdwb

@khalids222 oh, I'm flattered lol
Here's what I came up with, let me know if it works for you:
https://fxdreema.com/shared/qX2t8ZYYd
@nalin I'm not talking about metaeditor, but the fxdreema builder.
https://fxdreema.com/builder
@biztet multipair EAs with tracking variables (maxprofit) will get complicated pretty fast. I usually create an array to store the individual maxprofit variables for each pair, and then load from array at the start of "pair cycle" and save into array at the end of "pair cycle".
I can make an example of what I mean, but I'd suggest optimizing your EA for a single pair first.
@biztet Yes, it works. This resets the variable when there is no trades, you might want resetting in some other situtation, but this is one example.
@morwim there's a terminate block
@nalin just open two browser tabs and copy-paste the blocks from mt4 project to mt5 project.