Am I crazy, or is everyone re-inventing the wheel RE: trailing stop-loss/take-profit?

 

I've been scouring mql5 for days trying to find a solid implementation of the logic built into the class "CTrailingFixedPips" ... but all I've been able to find is a myriad of seemingly bespoke algorithms that people are developing by hand.

Is there any particular reason for this? 

My guess would be that since this class is a fairly new development, folks had to build their own solutions for many years, and either stuck with their solutions or piggybacked off of someone else's implementation - thus, not many people have bothered implementing the various solutions available in the CExpertTrailing base class.


If anyone has any links to sample code, or nice write-ups on an implementation of this class, I would greatly appreciate seeing it!


Cheers

 
ratracesurvivor:

...algorithms that people are developing by hand...

Is there any particular reason for this? 

:) that "by hand" thing is the best.

the reason are:
many people who just have started to learn how to code, think they are good to go, and start to code things the way they understand/improvise.
then they see Libraries, Classes, Objects and stuff like that, they become like :O
libraries/classes and many other expert level codes are avoided simply because of this simple "fear of new things".

you can show your attempt at using CExpertTrailing, and we'll help you if there's a mistake/bug/...

otherwise you just become what you described :

ratracesurvivor:

... or piggybacked off of someone else's implementation...

 
Code2219 or probably 2319:

:) that "by hand" thing is the best.

Agreed - programming is as much a creative endeavour as a technical one, IMHO, and that's what I love about it. 

But that said, there's always a 'best in class' implementation of a given concept (even if a community can't agree on which one it is ;-]) so I assumed that for something as fundamental as adjusting TP/SL, such an implementation would be well documented, and not as open to interpretation as I've found it to be thus far.

Code2219 or probably 2319:

otherwise you just become what you described :

lol exactly what I'm trying to avoid...

My programming background is limited to node/javascript/ruby/various webdev junk, so I'm fumbling around the MQL5 documentation and various code snippets to try and piece together a clear understanding of how this language works. 

I don't have much experience in functional programing languages & OOP admittedly, so the goal was to work backwards through functional code of varying complexity and piece together a broader understanding.

Code2219 or probably 2319:

you can show your attempt at using CExpertTrailing, and we'll help you if there's a mistake/bug/...

Right now, I don't have any implementation of CTrailingFixedPips, but I'll work towards that and share the code here when/if I can reach the milestone of "getting a meaningful error" lol

Cheers

 

ratracesurvivor:

I'll work towards that and share the code here when/if I can reach the milestone of "getting a meaningful error" lol

here's how to get to that milestone faster :

  • create a object : CPositionInfo
  • create a object : CTrailingFixedPips
  • loop through your open positions (and filter out unwanted ones)
  • for each long position , use method : CheckTrailingStopLong() and then StopLevel()
  • for each short position , use method : CheckTrailingStopShort() and then StopLevel()

read here and here
 
Code2219 or probably 2319:

here's how to get to that milestone faster :

  • create a object : CPositionInfo
  • create a object : CTrailingFixedPips
  • loop through your open positions (and filter out unwanted ones)
  • for each long position , use method : CheckTrailingStopLong() and then StopLevel()
  • for each short position , use method : CheckTrailingStopShort() and then StopLevel()

read here and here

Excellent, thanks for the leads!

Cheers

 
My guess would be that since this class is a fairly new development

Looks like it has been around since Dec of 2010, according to the wayback machine, so not that new.

That said, I hadn't seen it until now.

Reason: