[127] Market Position (...) is Not Short, once selected is being shown and calculated as Is Short

Market Position (...) is Not Short, once selected is being shown as Is Short
Attachments
No attachments
  • Votes 0
  • Project AlgoWizard
  • Type Bug
  • Status Fixed
  • Priority Normal

History

p
#1

pitro

14.05.2020 01:27

Task created

p
#2

pitro

14.05.2020 02:10

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



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;


p
#3

pitro

14.05.2020 18:04


OK I have some new findings here. I think both NotShort and NotLong functions are incorrect. It did some debug with MQ5 and I think it should be corrected as per below :


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.






p
#4

pitro

14.05.2020 18:44


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.

TB
#5

Tomas Brynda

29.05.2020 08:43

Status changed from New to Fixed

Hi Pitro,

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

p
#6

pitro

02.06.2020 17:16
Thank you 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


Votes: 0

Drop files to upload

or

choose files

Max size: 5MB

Not allowed: exe, msi, application, reg, php, js, htaccess, htpasswd, gitignore

...
Wait please