LotSize based on Centroid [SOLVED] - page 2

 

SOLVED:

I don't really know what caused the error, but just like this, the error has been resolved

double TradesCenterPrice(ENUM_ORDER_TYPE type)
  {
   double center = 0;
   int count = 0;
   for(int i = 0; i < PositionsTotal(); i++)
     {
      if(PositionGetTicket(i) <= 0)
         continue;
      if(PositionGetInteger(POSITION_MAGIC) != MagicNumber || 
      PositionGetString(POSITION_SYMBOL) != Symbol() || PositionGetInteger(POSITION_TYPE) != type)
         continue;
        {
         center += Position.PriceOpen();
         count++;
        }
     }
   if(count == 0)
      return 0;
   return center / count;
  }

 BEFORE:

double TradesCenterPrice(ENUM_ORDER_TYPE type)
  {
   double center = 0;
   int count = 0;
   for(int i = 0; i < PositionsTotal(); i++)
     {
      if(Position.SelectByIndex(i) && Position.Type() == type)
        {
         center += Position.PriceOpen();
         count++;
        }
     }
   if(count == 0)
      return 0;
   return center / count;
  }
 
Enrique Enguix #:

SOLVED:

I don't really know what caused the error, but just like this, the error has been resolved

 BEFORE:

Nice , another possible issue in the Trades library then ? 

 
Lorentzos Roussos #:

Nice , another possible issue in the Trades library then ? 

I was checking the library, but I have not found any error
 
Enrique Enguix #:
I was checking the library, but I have not found any error

Okay , they did an update recently i think so if you found something it must be reported.

You also passed me in the rating points , noooooooooooooo


I'm kidding , well done . cheers  ☕️

 
Lorentzos Roussos #:

Okay , they did an update recently i think so if you found something it must be reported.

You also passed me in the rating points , noooooooooooooo


I'm kidding , well done . cheers  ☕️

😅😅😅😅😅
 
Lorentzos Roussos #:

Nice , another possible issue in the Trades library then ? 

Not necessarily.


We are assuming Enrique used the built-in CPositionInfo class,

But since this is beyond the scope of the code he's shared, it might not be the case.


When the error occured, had you been using the built-in CPositionInfo class for obtaining positions' data/properties?

 
AMI289 #:

Not necessarily.


We are assuming Enrique used the built-in CPositionInfo class,

But since this is beyond the scope of the code he's shared, it might not be the case.


When the error occured, had you been using the built-in CPositionInfo class for obtaining positions' data/properties?

All the related code part is here in the post. The rest of the code is unrelated

 
Enrique Enguix #:

All the related code part is here in the post. The rest of the code is unrelated

No, it's not.

I'm starting to understand why William Roeder is so impatient with newbie programmers.

You make it so difficult to help you guys (to the point of you just being lazy and stubborn).


You solved your problem by accident,

But you still don't understand where the problem lays.


After your modifications, the issue clearly relays in the function calls of the 'Positions' variable.

HOWEVER- you don't show the code where you declare it.

If it is of the built-in CPoisitonInfo class, then it is an issue that needed to be check and reported if it is not working correctly,

If it is your own custom class, then you could have just saved all of us a lot of time if you'd just showed the variable declaration (which you still fail to understand that it is related to the code that you've shown).


It is really alarming,

As it is the 2nd post I come across in the past few days of people who are selling EAs in here, which clearly has very little knowledge regarding programming,

Showing how low the bar for writing an EA is.

 
AMI289 #:

No, it's not.

I'm starting to understand why William Roeder is so impatient with newbie programmers.

You make it so difficult to help you guys (to the point of you just being lazy and stubborn).


You solved your problem by accident,

But you still don't understand where the problem lays.


After your modifications, the issue clearly relays in the function calls of the 'Positions' variable.

HOWEVER- you don't show the code where you declare it.

If it is of the built-in CPoisitonInfo class, then it is an issue that needed to be check and reported if it is not working correctly,

If it is your own custom class, then you could have just saved all of us a lot of time if you'd just showed the variable declaration (which you still fail to understand that it is related to the code that you've shown).


It is really alarming,

As it is the 2nd post I come across in the past few days of people who are selling EAs in here, which clearly has very little knowledge regarding programming,

Showing how low the bar for writing an EA is.

A successful strategy does not require a good coder brother  😇 . 

Yes there is the occasional "would crush a jumbo jet 747 from 1967" rare type of event , absolutely normal to occur in a project this vast (mt5) in code , and Enrique may have stumbled upon it.

However if one shows restraint and exercises politeness they can get more info regarding a situation i think  😊

 
Lorentzos Roussos #:

However if one shows restraint and exercises politeness they can get more info regarding a situation i think  😊

Hey Lorentzos,

Appreciate your reply,

Throughout this correspondence I've asked him several times, politely, and even 'spoon-fed' him the single line of code that could determine if he is indeed using the CPositionInfo class.

I've also wrote him privately explaining the above, as I didn't wanted to 'pressure' him to post it here, if he doesn't like, as he doesn't seem to co-operate much.

Yet, he doesn't seem to care much about the consequenses of this possible bug.

I think it is unreasonable for one to ask for assistance from fellow programmers,

Yet to do the bare minimum to give back to the community, when such an issue had been found.

I don't think that neither of you understand how critical it is if there is a bug in the CPositionInfo class.

If, as you've said, they did an update to this class, and it is now not working correctly,

Every EA that is now being developed, that is using this class, or any existing EA that using that class, that would get an update (meaning, the author will re-compile it with the updated version of CPositionInfo) will essentialy 'suffer' from this type of bugs.


Lorentzos Roussos #:

Okay , they did an update recently i think so if you found something it must be reported.

I haven't been able to replicate this bug myself.

How do you know that they've made an update to this class recently?

Is there a public changelog which shows what updates been made to the code?


And on a final note-

Lorentzos Roussos #:

A successful strategy does not require a good coder brother  😇 . 

1) Succesful trading strategy, implemented correctly to an EA, is not worth much, if there is a built-in bugs in the coding language, as, even if properly coded, it will not work as intended.

2) Succesful trading strategy does not worth much when converted to an EA, if one doesn't know how to properly code it, as is the case with the OP, as it will not work as intended.


Have you encountered any issues with while using CPositionInfo class?

As stated above, I haven't been able to reproduce this bug (though that doesn't mean that there isn't a bug).