hi i created this simple concept of my expert so i can show you whats the problem
expert has to run in diffrent charts of the same currency pair so i have to apply magic number to each order and the basic concept of it is that i have to open the next order based on the results of the last one
for example a sell if the previous orders hit stoploss a buy if it hits tp
the expert works fine until it goes up ...for example the first order which is a buy hits tp and it has to open a sell well it opens a sell and it opens a buy which was the previous order at the same time
instead of one order it opens twp orders the order that it should open and again the previous one
from my tests the problem is magic number if i dont apply magic number the problem is solved but i have to apply it.. so im kinda stuck
here is my code
THANK YOU IN ADVANCE
Looks like this check:
//THE FIRST ORDER if(open_pairr(Symbol(),magic_n)<1) { entry(Symbol(),OP_SELL,0.01,0,5,35,35,NULL,magic_n); }
will be passed and entry() will execute every time (in fact, every tick) that there is no order with magic_n open. I assume this code is not in the other EA that you run in another chart?
Another problem is when you check OrdersHistoryTotal(), you should also check the orders' time, otherwise, as time goes by, you'll always get a history order that close by TP or SL, all the time. Not posing huge problem at the moment if you're only running two charts, and you're also checking your magic_n and magic_n2, but the logic is incomplete.
if(OrderClosePrice()==OrderStopLoss())
- SL becomes a market order when hit. Slippage could be multiple pips.
- Doubles are rarely equal. Understand the links in:
The == operand. - MQL4 programming forum
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hi i created this simple concept of my expert so i can show you whats the problem
expert has to run in diffrent charts of the same currency pair so i have to apply magic number to each order and the basic concept of it is that i have to open the next order based on the results of the last one
for example a sell if the previous orders hit stoploss a buy if it hits tp
the expert works fine until it goes up ...for example the first order which is a buy hits tp and it has to open a sell well it opens a sell and it opens a buy which was the previous order at the same time
instead of one order it opens twp orders the order that it should open and again the previous one
from my tests the problem is magic number if i dont apply magic number the problem is solved but i have to apply it.. so im kinda stuck
here is my code
THANK YOU IN ADVANCE