//---trailing and close if (OrderType() == OP_BUY) { if (Is_Close_Buy==true) //-- the signal to close { RefreshRates();// Refresh rates res= 0; res= OrderClose(order_id,Lots,Bid,3,Gold); while(IsTradeAllowed() == false) Sleep(100); //---wait a little to get response from server if (res>0){ PlaySound("cash_register.wav");} //--happy sound, making money hopefully !!!! if (res<0) { PlaySound("creak.wav"); Print("OrderSend failed with error #",GetLastError()); return(0); } return; } }//end close Buy Order check //--- if (OrderType() == OP_SELL) { if (Is_Close_Sell==true) //--the signal to close { RefreshRates();// Refresh rates res= 0; res= OrderClose(order_id,Lots,Ask,3,Gold); while(IsTradeAllowed() == false) Sleep(100); //---wait a little to get response from server if (res>0){ PlaySound("cash_register.wav");} if(res<0) { PlaySound("creak.wav"); Print("OrderSend failed with error #",GetLastError()); return(0); } return; } }//end close Sell Order check }//--------+ return; }
@ RaptorUK, I'm considering wearing crash helmet so at least I can think well ahead than I'm currently now. Isn't that, those drivers do, think well ahead ? :D
@ skaboy, I'm asking politely here, if you don't mind, would you please use SRC button to post your code. We've been asking that too many times in this thread alone.
@ crossy, It's almost a week since your first post. Surely I understand that you may not have a clear head now dealing with 4000 lines, right now I myself have mine here too. If you still don't understand it, - ehm - you can ask us to write that Close code for you. However you still have to write the code even just a little - and show us. :D, RaptorUK's code just above there is more direct than mine, think about it and then you can move on with your EA.
With the way you write code here - too many unnecessary repeated code - you should have a little worry with your 4000 lines of code that it may slow down your EA and makes your EA miss a tick. It's okay to miss a couple point, however what happen if you miss like 10 pips away ? and probably your 4000 lines may still can be reduced to just 400 lines. Who knows ?, your EA, become more lighter and faster. :D
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
O.K. Here is the modified version, which I got the same mistake.
Y.
You don't need the Function at all . . . . . . get rid of it.
Let's do it again part 2 :(
Do this . . . ( repeated from here: https://www.mql5.com/en/forum/139543 )
. . . and you don't need the Function at all.
Let's do it again part 2 :(
I want your exuss, please, since I have an holiday, So I will be back on sunday nigth.
I will do what you suggested, and I hope to succeed.
Thank you both.
Y.
I want your exuss, please, since I have an holiday, So I will be back on sunday nigth.
I want your exuss, please, since I have an holiday, So I will be back on sunday nigth.
I will do what you suggested, and I hope to succeed.
Thank you both.
Y.
Have a good time :D
Me have F1 Monaco to watch this Sunday :D
Have a good time :D
Me have F1 Monaco to watch this Sunday :D
Thanks onewithzachy,
First I think that you have a small mistake with:
for(int cnt = OrdersTotal() -1 ; cnt >= 0; cnt--)
You have to add the green and bold correction.
But, I do not understand how the following line can help us?
#include "..\libraries\stdlib.mq4"
Thanks, Y.
I find this much simpler, and it works for me:
//---------------------------------------------+
void CheckForClose()
{
int i, res, order_id;
//-------+
for(i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue;
order_id= OrderTicket();
//---trailing and close
if (OrderType() == OP_BUY)
{
if (Is_Close_Buy==true) //-- the signal to close
{
RefreshRates();// Refresh rates
res= 0;
res= OrderClose(order_id,Lots,Bid,3,Gold);
while(IsTradeAllowed() == false) Sleep(100); //---wait a little to get response from server
if (res>0){
PlaySound("cash_register.wav");} //--happy sound, making money hopefully !!!!
if (res<0)
{
PlaySound("creak.wav");
Print("OrderSend failed with error #",GetLastError());
return(0);
}
return;
}
}//end close Buy Order check
//---
if (OrderType() == OP_SELL)
{
if (Is_Close_Sell==true) //--the signal to close
{
RefreshRates();// Refresh rates
res= 0;
res= OrderClose(order_id,Lots,Ask,3,Gold);
while(IsTradeAllowed() == false) Sleep(100); //---wait a little to get response from server
if (res>0){
PlaySound("cash_register.wav");}
if(res<0)
{
PlaySound("creak.wav");
Print("OrderSend failed with error #",GetLastError());
return(0);
}
return;
}
}//end close Sell Order check
}//--------+
return;
}
//----------------------------------------------+
And tomorrow, FP3 and Qualifying ;-)
@ RaptorUK, I'm considering wearing crash helmet so at least I can think well ahead than I'm currently now. Isn't that, those drivers do, think well ahead ? :D
@ skaboy, I'm asking politely here, if you don't mind, would you please use SRC button to post your code. We've been asking that too many times in this thread alone.
@ crossy, It's almost a week since your first post. Surely I understand that you may not have a clear head now dealing with 4000 lines, right now I myself have mine here too. If you still don't understand it, - ehm - you can ask us to write that Close code for you. However you still have to write the code even just a little - and show us. :D, RaptorUK's code just above there is more direct than mine, think about it and then you can move on with your EA.
With the way you write code here - too many unnecessary repeated code - you should have a little worry with your 4000 lines of code that it may slow down your EA and makes your EA miss a tick. It's okay to miss a couple point, however what happen if you miss like 10 pips away ? and probably your 4000 lines may still can be reduced to just 400 lines. Who knows ?, your EA, become more lighter and faster. :D
I find this much simpler, and it works for me: