Nice one global and seems likely you are correct. Even if not, I have made the change and updated the post 1 version.global wrote:Thanks for the update Steve. I checked your updated code and I'm wondering if the int iPipsAboveVisual variable in line 901 needs to be converted to double iPipsAboveVisual from this line of code...SteveHopwood wrote:If, say, StopLoss is declared as an integer as in int StopLoss = 20:
double NewStop = NewStop = OrderOpenPrice() - (StopLoss * Point); is allowed and (StopLoss * Point) creates a 0.xxxxxxxx result.
The command using factor is OrderOpenPrice() - (StopLoss / factor); But, if StopLoss is an integer then the code (StopLoss / factor) returns a zero value.
All the pip values in mptm were declared as integers, so when interacting with factor resulted in 0 being added to whatever the bot was supposed to be doing, and so trades were closing prematurely. All that was needed was to convert them to doubles - something Paul forgot to do and that I did not notice.
So, fix is in post 1; sing out if I am barking at the wrong moon and the fix does not work.
...because a little further down you divide iPipsAboveVisual by Pipfactor as below:Code: Select all
bool CheckForHiddenStopLossHit(int type, int iPipsAboveVisual, double stop )
Code: Select all
double sl = NormalizeDouble(stop + (iPipsAboveVisual /Pipfactor), digits);
I tamper with mptm's code with the greatest reluctance. The Steve who started coding it back in about 2007 and the Steve who codes these days are completely different coding individuals. Had I understood even a fraction back then of what I understand now, the code would be completely different. Anybody updating my code now has the me back from 2007 to contend with, and does so at the peril of the entire EA. I shall probably ignore well-intentioned updates in the future.
Added to my early inexperience is the fact that mptm's code has been expanded by several contributors over the years. I rarely have any idea what they were doing and just go with the flow. mptm is ridiculously complex and we are left this this unavoidable truth: tampering with mptm code invites LUC (Law of Unintended Consequences) to throw the bender of the decade for his buddies. What has happened here is a great example.