Ordertype based on indicator - page 2

 

I can't see why your code would open multiple orders at once

unless your openbuy and opensell functions actually open multiple orders

or even stranger, if the closeallorders function places new trades 

Do your openbuy and opensell functions have loops in them for some reason? 

 
No they havent. After one order is closed the ea places a new order, but with the same signal and thats not the way  I want the ea trade 
 
https://www.mql5.com/en/job
 
thats not what I'm searching for! 
 
albo111:
No they havent. After one order is closed the ea places a new order, but with the same signal and thats not the way  I want the ea trade 

Before you said that the EA was opening multiple orders, now you are saying that it is opening an order after the previous order is closed.

Can you not see that this is not the same? 

 

@ GumRai

Better pass it to https://www.mql5.com/en/job

Because I smell somebody is not doing his homework enough.

 
That was a mistake. It doesen't open multiple orders. After one order is closed it opens another order with the same signal and thats what I doesent want
 
albo111:
That was a mistake. It doesen't open multiple orders. After one order is closed it opens another order with the same signal and thats what I doesent want

Yes, but people have wasted their time looking through your code to try to see the reason(s) why it should open multiple trades.

 

You should imagine your EA as an extremely stupid person that is unable to think for himself, but very good at following orders.

You give the instruction "if there is a buy signal, and no buy open already, open a buy order with a SL and TP"

You go away and leave him to it, but when you come back , you find that he has opened a new buy trade every time the order is closed by SL or TP.

You tell him that is not what you wanted and he replies "But there was a buy signal and at the time there was no buy order open"

So, think about how you would explain precisely what you want.

Maybe

If there has already been a buy trade opened don't open a new buy trade until a new bar opens

Or

If the last trade was a buy, don't open another trade until you see a sell signal and then open a sell order

"But how do I know if the last trade was a buy or a sell?"

You see this little book called "Global Variables?. When a buy trade is executed, you write in it - LastTrade=Buy. When a sell trade is executed, you write in it - LastTrade=Sell. Now when you see a signal, look in the book and find the last entry for LastTrade. If it is the same as the signal, then don't open a new trade"

 
Thanks for your help and yes i'm sorry it was my mistake! I will try to do it how you said!
 

You did not modify your code, so it don't work.

 down=iCustom(NULL,0,"ASCTrend",1,0);
   up=iCustom(NULL,0,"ASCTrend",0,0);
Reason: