Subject changed from [127] Market Position (...) is Not Short, once selected is being shown as Is Short to [127] Market Position (...) is Not Short, once selected is being shown and calculated as Is Short
CURRENT DEFINITIONS:
//+------------------------------------------------------------------+
bool sqMarketPositionIsNotShort(int magicNo, string symbol, string comment){
if(sqSelectOrder(magicNo, symbol, 1, comment, false)) {
return false;
}
return true;
}
//+------------------------------------------------------------------+
bool sqMarketPositionIsNotLong(int magicNo, string symbol, string comment){
if(sqSelectOrder(magicNo, symbol, 1, comment, false)) {
return false;
}
return true;
}
THE WAY IT SHOULD LOOK LIKE:
//+------------------------------------------------------------------+
bool sqMarketPositionIsNotShort(int magicNo, string symbol, string comment){
if(sqSelectOrder(magicNo, symbol, -1, comment, false)) {
return true;
}
return false;
}
//+------------------------------------------------------------------+
bool sqMarketPositionIsNotLong(int magicNo, string symbol, string comment){
if(sqSelectOrder(magicNo, symbol, 1, comment, false)) {
return true;
}
return false;
}
It was working fine in my code when I did these changes and applied NotLong and Not Short functions. Before that when Short or Long order was active (opened) it didn't see it and behave like it was not opened.
Hmm my changes are not enough. IT is working fine when the order is placed, but when there is no Order it is still not working as it should.
Status changed from New to Fixed
thank you for your suggestion to the code. Obviously there was a mistake in the code.
I modified the code this way:
bool sqMarketPositionIsNotLong(int magicNo, string symbol, string comment){ if(sqSelectOrder(magicNo, symbol, 1, comment, false)) { return false;
} else return true; } bool sqMarketPositionIsNotShort(int magicNo, string symbol, string comment){ if(sqSelectOrder(magicNo, symbol, -1, comment, false)) { return false; } else return true; }
I think there was just a missing minus sign in sqMarketPositionIsNotShort function in the original code.
Best regards,
Tomas
Please make sure the label is fixed as well,
Market Position (...) is Not Short, once selected from the menu, it is being shown as Is Short
Market Position (...) is Not Short, once selected is being shown and calculated as Is Short
PLEASE SEE BELOW and compare NotShort and NotLong functions (I copy/pasted this code from default definitions):
When you look at "1" and "-1" it is clear that some are wrong here. I checked "NotShort" with MQ5 debug and it is behaving like "IsShort".
//+------------------------------------------------------------------+
bool sqMarketPositionIsShort(int magicNo, string symbol, string comment){
return sqSelectPosition(magicNo, symbol, -1, comment, false);
}
//+------------------------------------------------------------------+
bool sqMarketPositionIsNotShort(int magicNo, string symbol, string comment){
if(sqSelectOrder(magicNo, symbol, 1, comment, false)) {
return false;
}
return true;
}
//+------------------------------------------------------------------+
bool sqMarketPositionIsLong(int magicNo, string symbol, string comment){
return sqSelectPosition(magicNo, symbol, 1, comment, false);
}
//+------------------------------------------------------------------+
bool sqMarketPositionIsNotLong(int magicNo, string symbol, string comment){
if(sqSelectOrder(magicNo, symbol, 1, comment, false)) {
return false;
}
return true;
}