Yes, there are several logic problems in your code.
You never call the function "CheckVolKatan()" anywhere in your code, so how do you expect it to have any influence?
In the "OpenOredrsThisPair()" (which is a mistype I think), you never test the result of OrderSelect() and just assume that it always works.
In the same "OpenOredrsThisPair()", you also do not check for your magic number, so the order count will be incorrect.
Your IsNewCandle() is unreliable. You should not use Bars to check for a New Candle. It is a very old and a unreliable technique. Use the following instead:
Yes, there are several logic problems in your code.
You never call the function "CheckVolKatan()" anywhere in your code, so how do you expect it to have any influence?
In the "OpenOredrsThisPair()" (which is a mistype I think), you never test the result of OrderSelect() and just assume that it always works.
In the same "OpenOredrsThisPair()", you also do not check for your magic number, so the order count will be incorrect.
Your IsNewCandle() is unreliable. You should not use Bars to check for a New Candle. It is a very old and a unreliable technique. Use the following instead:
Hi FMIC,
Do you think the below change Improve this function for #2 and 3 (mistype Indeed).
steve_o: Do you think the below change Improve this function for #2 and 3 (mistype Indeed).
You are still missing Point 3 (magic number). As it is, it will return the wrong count because it will include in that count trades from other EAs (other magic numbers) and Manual Trades and not just trades from your specific EA (your magic number).
int OpenOrdersThisPairMagic( string pair, int magic )
{
int total = 0;
for( int i = OrdersTotal() - 1; i >= 0; i-- )
{
ResetLastError();
if( OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) )
{
if( ( OrderSymbol() == pair ) && ( OrderMagicNumber() == magic ) )
total++;
}
elsePrint( "Select: ", i, "; Error: ", _LastError );
}
return total;
}
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.
you're right:-)- see below:
Yes, there are several logic problems in your code.
All- thanks very much for your assistance and Important comments!
much appreciated!!!
Yes, there are several logic problems in your code.
Hi FMIC,
Do you think the below change Improve this function for #2 and 3 (mistype Indeed).
Thanks.