Please keep in mind I am not a coder and my knowledge and understanding is limited.
I would recommend getting a comprehensive understanding of mql4 following the book.
where and how could I insert the "orderclose"
You can create a function, then place it within the start(). I recommend naming your function something descriptive like Close_Buy_Orders_In_Reverse_Logic() instead of OC().
at the moment a trade is opened and closed after conditions met, however, a new trade is opened immediately in the same direction, because the same conditions are still intact
You can try limiting the Time. Can be achieve by searching for the Last_Order_Time. Then check if X-amount of time have elapsed or X-number Bars have elapsed.
You declare these variables extern:
extern double MacdCurrent= 48;
extern double MacdPrevious = 24;
but then you overwrite them in your start() function:
MacdCurrent=iMACD(NULL,60,4,2,9,PRICE_CLOSE,MODE_MAIN,0);
MacdPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1);
Also, your MACD parameters are different. This will give you very strange results I think, unless you are looking for some cross over perhaps?
As Ubzen suggests, plenty of reading is in order. I suggest you find the "MACD sample" in the codebase and study it as I think the sample will do what you are trying to code.
I think you are asking about stopping orders from being opened while the opening conditions have not changed. The two ways to remember a status
1) is to use a static variable
2) keep notes in a file. File operations every tick will slow you down so avoid if posible.
Your code would look something like and written for clarity.
static bool AllowBuy = true ; if ( Buytrigger()==true && AllowBuy==true ) { OpenBuy(); AlowBuy=false ; } // no more buy trades until if ( BuyTrigger()==false ) { AlowBuy=true ; }

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Above is an EA that I have been trying to insert a "orderclose" portion, at the moment a trade is opened and closed after conditions met, however, a new trade is opened immediately in the same direction, because the same conditions are still intact, if i changed the conditions to follow the twist and turn of the MACD, as it goes up buy and as it turns and goes down sell, etc.. (will be able to figure this part of the code out myself) then where and how could I insert the "orderclose" keeping the code in a similar manner to the OB & OS if this is possible (this I understand).
Please keep in mind I am not a coder and my knowledge and understanding is limited, thanks in advance R