Discussion of article "Statistical Distributions in MQL5 - taking the best of R" - page 8

[Deleted]  

And what follows is the very text of the permissive subroutine from R:

      ier = 0
      neval = 0
      last = 0
      result = 0.0 e+00
      abserr = 0.0 e+00
      alist(1) = a
      blist(1) = b
      rlist(1) = 0.0 e+00
      elist(1) = 0.0 e+00
      if(epsabs.le.0.0 e+00.and.epsrel.lt.amax1(0.5 e+02*epmach,0.5 e-14))
     *   ier = 6
      if(ier.eq.6) go to 999
c
c           first approximation to the integral
c           -----------------------------------
c
      uflow = r1mach(1)
      oflow = r1mach(2)
      ierro = 0
      call qk21(f,a,b,result,abserr,defabs,resabs)
c
c           test on accuracy.
c
      dres = abs(result)
      errbnd = amax1(epsabs,epsrel*dres)
      last = 1
      rlist(1) = result
      elist(1) = abserr
      iord(1) = 1
      if(abserr.le.1.0 e+02*epmach*defabs.and.abserr.gt.
     *  errbnd) ier = 2
      if(limit.eq.1) ier = 1
      if(ier.ne.0.or.(abserr.le.errbnd.and.abserr.ne.resabs).or.
     *  abserr.eq.0.0 e+00) go to 140
c
c           initialization
c           --------------
c
      rlist2(1) = result
      errmax = abserr
      maxerr = 1
      area = result
      errsum = abserr
      abserr = oflow
      nrmax = 1
      nres = 0
      numrl2 = 2
      ktmin = 0
      extrap = .false.
      noext = .false.
      iroff1 = 0
      iroff2 = 0
      iroff3 = 0
      ksgn = -1
      if(dres.ge.(0.1 e+01-0.5 e+02*epmach)*defabs) ksgn = 1
c
c           main do-loop
c           ------------
c
      do 90 last = 2,limit
c
c           bisect the subinterval with the nrmax-th largest
c           error estimate.
c
        a1 = alist(maxerr)
        b1 = 0.5 e+00*(alist(maxerr)+blist(maxerr))
        a2 = b1
        b2 = blist(maxerr)
        erlast = errmax
        call qk21(f,a1,b1,area1,error1,resabs,defab1)
        call qk21(f,a2,b2,area2,error2,resabs,defab2)
c
c           improve previous approximations to integral
c           and error and test for accuracy.
c
        area12 = area1+area2
        erro12 = error1+error2
        errsum = errsum+erro12-errmax
        area = area+area12-rlist(maxerr)
        if(defab1.eq.error1.or.defab2.eq.error2) go to 15
        if(abs(rlist(maxerr)-area12).gt.0.1 e-04*abs(area12)
     *  .or.erro12.lt.0.99 e+00*errmax) go to 10
        if(extrap) iroff2 = iroff2+1
        if(.not.extrap) iroff1 = iroff1+1
   10   if(last.gt.10.and.erro12.gt.errmax) iroff3 = iroff3+1
   15   rlist(maxerr) = area1
        rlist(last) = area2
        errbnd = amax1(epsabs,epsrel*abs(area))
c
c           test for roundoff error and eventually
c           set error flag.
c
        if(iroff1+iroff2.ge.10.or.iroff3.ge.20) ier = 2
        if(iroff2.ge.5) ierro = 3
c
c           set error flag in the case that the number of
c           subintervals equals limit.
c
        if(last.eq.limit) ier = 1
c
c           set error flag in the case of bad integrand behaviour
c           at a point of the integration range.
c
        if(amax1(abs(a1),abs(b2)).le.(0.1 e+01+0.1 e+03*epmach)*
     *  (abs(a2)+0.1 e+04*uflow)) ier = 4
c
c           append the newly-created intervals to the list.
c
        if(error2.gt.error1) go to 20
        alist(last) = a2
        blist(maxerr) = b1
        blist(last) = b2
        elist(maxerr) = error1
        elist(last) = error2
        go to 30
   20   alist(maxerr) = a2
        alist(last) = a1
        blist(last) = b1
        rlist(maxerr) = area2
        rlist(last) = area1
        elist(maxerr) = error2
        elist(last) = error1
c
c           call subroutine qpsrt to maintain the descending ordering
c           in the list of error estimates and select the
c           subinterval with nrmax-th largest error estimate (to be
c           bisected next).
c
   30   call qpsrt(limit,last,maxerr,errmax,elist,iord,nrmax)
c ***jump out of do-loop
        if(errsum.le.errbnd) go to 115
c ***jump out of do-loop
        if(ier.ne.0) go to 100
        if(last.eq.2) go to 80
        if(noext) go to 90
        erlarg = erlarg-erlast
        if(abs(b1-a1).gt.small) erlarg = erlarg+erro12
        if(extrap) go to 40
c
c           test whether the interval to be bisected next is the
c           smallest interval.
c
        if(abs(blist(maxerr)-alist(maxerr)).gt.small) go to 90
        extrap = .true.
        nrmax = 2
   40   if(ierro.eq.3.or.erlarg.le.ertest) go to 60
c
c           the smallest interval has the largest error.
c           before bisecting decrease the sum of the errors
c           over the larger intervals (erlarg) and perform
c           extrapolation.
c
        id = nrmax
        jupbnd = last
        if(last.gt.(2+limit/2)) jupbnd = limit+3-last
        do 50 k = id,jupbnd
          maxerr = iord(nrmax)
          errmax = elist(maxerr)
c ***jump out of do-loop
          if(abs(blist(maxerr)-alist(maxerr)).gt.small) go to 90
          nrmax = nrmax+1
   50   continue
c
c           perform extrapolation.
c
   60   numrl2 = numrl2+1
        rlist2(numrl2) = area
        call qelg(numrl2,rlist2,reseps,abseps,res3la,nres)
        ktmin = ktmin+1
        if(ktmin.gt.5.and.abserr.lt.0.1 e-02*errsum) ier = 5
        if(abseps.ge.abserr) go to 70
        ktmin = 0
        abserr = abseps
        result = reseps
        correc = erlarg
        ertest = amax1(epsabs,epsrel*abs(reseps))
c ***jump out of do-loop
        if(abserr.le.ertest) go to 100
c
c           prepare bisection of the smallest interval.
c
   70   if(numrl2.eq.1) noext = .true.
        if(ier.eq.5) go to 100
        maxerr = iord(1)
        errmax = elist(maxerr)
        nrmax = 1
        extrap = .false.
        small = small*0.5 e+00
        erlarg = errsum
        go to 90
   80   small = abs(b-a)*0.375 e+00
        erlarg = errsum
        ertest = errbnd
        rlist2(2) = area
   90 continue
c
c           set final result and error estimate.
c           ------------------------------------
c
  100 if(abserr.eq.oflow) go to 115
      if(ier+ierro.eq.0) go to 110
      if(ierro.eq.3) abserr = abserr+correc
      if(ier.eq.0) ier = 3
      if(result.ne.0.0 e+00.and.area.ne.0.0 e+00) go to 105
      if(abserr.gt.errsum) go to 115
      if(area.eq.0.0 e+00) go to 130
      go to 110
  105 if(abserr/abs(result).gt.errsum/abs(area)) go to 115
c
c           test on divergence.
c
  110 if(ksgn.eq.(-1).and.amax1(abs(result),abs(area)).le.
     * defabs*0.1 e-01) go to 130
      if(0.1 e-01.gt.(result/area).or.(result/area).gt.0.1 e+03
     * .or.errsum.gt.abs(area)) ier = 6
      go to 130
c
c           compute global integral sum.
c
  115 result = 0.0 e+00
      do 120 k = 1,last
         result = result+rlist(k)
  120 continue
      abserr = errsum
  130 if(ier.gt.2) ier = ier-1
  140 neval = 42*last-21
  999 return
      end
[Deleted]  

What is easier: to write a subroutine in C or MQL4-MQL5 for 0.5...1 hour and then use it for years for yourself and for people,

as an option - use a subroutine from the MQL4-MQL5 library,

or digging for weeks in sources and crazy function names and parameter names from netLib and R package, trying to understand them, and especially in Martian logic of Fortran programmers - under-physicists?

If you want to write a complex programme, you should care first of all about simplicity and clarity, not about its speed.

Speed of operation is a SECONDARY thing.

Metaquotes knows how to make things clear and understandable. You have to have a special talent for that, by the way. That's why they defeated everyone in the first round of the struggle for an affordable trading terminal and development environment. Nobody else managed to do it clearly, logically and simply.

So use it! It's great! And it's free!

333). And now some bad news for San-Sanych, for the R package and possibly for Metaquotes:

Several basic maths functions that are needed for trading are not counted correctly in Netlib, R and Metaquotes.

I have them counted correctly and it gives positive results. If they are counted the way everyone else counts them, the trading result is negative or barely positive. I won't tell you which functions they are, sorry. That's why I prefer to write everything myself and use LONG NAMES in my work. It's easier to understand what you wrote yourself yesterday.

Here's a sample:

https://www.mql5.com/en/blogs/post/678673

https://www.mql5.com/en/users/alexeros/blog

Library of Math functions
Library of Math functions
  • 2016.08.29
  • //www.mql5.com/en/users/AlexEros">
  • www.mql5.com
This is an extract from production library of EAs "Graalino-Pro" and "Ocean Breeze". There is a dosen of general math functions here. Everything in this library is PUBLIC DOMAIN (and free). Example...
 
Sergiy Podolyak:

...

Amazing, first time I've met someone with a similar attitude to writing programmes. That's why I'm fiercely plus.

The main arguments of eRaists are a huge database of functions and so-called "packages", which are constantly replenished. Note that all or 99% of these people do not know C or MQL at all. They are not used to digging into code, they are opponents of "bicycles". But, for some reason, eRasts never say that R is unreadable and that if you need to correct something for yourself, it is practically impossible to do it or involves huge labour costs. They forget about the fact that for C and C++ (in which R itself is written) there is probably more code than for any other language, innumerable libraries with source code that are transferred to MQL really like two bytes.

If Gadzila, for example, from the moment he started rewriting the codebase from MQL4 to MQL5, had rewritten open mat and stat libraries from C sources, then by now MT5 would be the most powerful platform ready for various research and advanced trading, but the work is already being done, fortunately, by MQ.

By the way, before I wrote my GA, I reviewed if not hundreds, then dozens of C/C++ sources with codeproject, although my programming skills were hardly above zero level. That is, open source codes of C/C++ allow you not only to study the theory and approaches to tasks, but also to create something unique and new even for people far from writing programmes. But even R specialists can hardly be able or want to write something new in R, it is easier for them to be satisfied with what someone else has already done believing that everything works correctly.

[Deleted]  
Andrey Dik:
...

If Gadzila, for example, had rewritten open mat and stat libraries from C sources since he started rewriting the codebase from MQL4 to MQL5, then by now MT5 would be the most powerful platform READY for various research and advanced trading, but the work is already being done, fortunately, by MQ.

Agreed.

But what does it mean "would be"?

MT4 (and MT5) terminal has long been a teaching and academic terminal for various trading research. They just don't shout about it on every corner, probably they are embarrassed by its free of charge (i.e. supposedly "non-credible").

From my personal experience of communicating with mid-level pro traders, I can say for sure that nowadays new trading algorithms are first written in MQL4, and then transferred to any other paid terminals with more trading instruments and access to more exchanges. But it costs much more: from $250 per month for the platform and quotes up to $1500 per month. Even Reuters and Bloomberg with very limited functionality for algo-trading cost about $2000 per month.

As for "advancedness", I can say that I (we are a group) wrote the world's first commercially available trading programme (Expert Advisor) with acceleration on CUDA GPU for MT4.

And here is a link to the forum of Multicharts trading system (100...200 dollars a month for the terminal and quotes), where they claim that "THIS IS IMPOSSIBLE". And that they were told about it by nvidia itself - i.e. the developer of the CUDA subsystem itself.

http://www.multicharts.com/discussion/viewtopic.php?f=1&t=8067

........................................................................................................................................................................

"Dear bomberone1,

The programme achitechture of MultiCharts does not allow to take advantage of systems like CUDA, GPU and others. In MC the calculations of current values are based on the calculations of previous values. We have contacted CUDA in the past and they have confirmed that their technology cannot be used to make MC calculations faster because of the algorythm used in MC. Which is common for trading software as normally CUDA, GPU and others are not used for trading. We do not know any examples of similar software that supports CUDA or GPU."

.........................................................................................................................................................................

See? They say it's impossible. Their architecture does not allow it in principle. And the Methaquots have it working in the terminal. I think it's ridiculous.

MultiCharts: Trading Software for Automated Trading and Backtesting • View topic - Windows HPC Server 2008 R2 and CUDA
  • www.multicharts.com
Author Message Will multicharts support the HPC technical computing? I'd like to use the power of computing cloud. In the while is it possible use the power of CUDA, the GPU power calculation for backtesting? Mathlab and other many trading software support this function, when will see these on mc? I write here the possibility to use...
 
Sergiy Podolyak:

I agree.

But what does it mean to say "WOULD"?

MT4 terminal (and MT5) has long been a teaching and academic terminal for various trading studies. They just don't shout about it on every corner, probably they are embarrassed by its free of charge (i.e. supposedly "non-credible").

Yes, but it would be easier for those who like "everything out of the box", such as eRaasts, to conduct their research without even minimal effort. That's what I'm saying. And the fact that MT is a uniquely capable research and trading platform - this has indeed been true for a long time.
[Deleted]  
Andrey Dik:
Yes, but for "all out of the box" enthusiasts, such as most eRastas, it would be easier to do their research without even minimal effort. That's what I'm saying. And the fact that MT is a uniquely capable research and trading platform - that's really been true for a long time.

What's the point or benefit to you of calling people names that are misguided? Don't like the R system? Just walk past it! Well, or there are 2-3 times to educate them, these R-schniki, and then pass by. There are no perfect mathematical systems. As well as trading terminals. A pro should choose a professional tool for his work in the first place. That is why sometimes it is necessary to use several tools. I have 8 (eight) versions of subroutines for CUDA in my build: single precision, double precision, sequential algorithm, parallel algorithm (that's 4 combinations of subroutines), just in C, then a C version with CUDA, and then a Lite version of subroutines in pure MQL4 - for the MQL5.com Market. This is necessary for error checking and for checking the accuracy of algorithms. Everything works in C, MQL4 and CUDA - almost the same. San-Sanych has long been urging everyone to use R as well - How? Should I also write the 8th or 9th version of subroutines? Why? To deal with additional parameters and additional error errors later?

Metaquotes started conditionally speaking "cloning" R functions from distribution functions (actually the process is much wider than the R package, this is good). This is necessary to verify by statistical tests the rest of statistical functions.

All the more so then - why should programmers immerse themselves in the crazy world of the R behemoth, if "probably soon" the same functions will appear in MQL4-5 ? Where is the economic sense to spend the main resource - time - on plugging R?

The "general acceptance" of R does not inspire me. Personally, I have seen it many times in science - when the "universally recognised" authority comes out in the side of the one who worships it. From my personal experience, I can say that trading calculations require a precision that the authors of R never dreamed of. RenTec, the first and most successful firm in full algo-trading, employs first of all astro-physicists, i.e. people engaged in especially precise calculations. RenTec has known since the 1990s that a price series is such a dense substance that very precise calculations are required to AUTOMATICALLY extract its microstructure from it.

 
Sergiy Podolyak:

What's the point or benefit to you of calling people names who are misguided? Don't like the R system? Just pass by! Well, or there 2-3 times they are educate them, these R-schnikovs, and then pass by. There are no perfect mathematical systems. As well as trading terminals. A pro should choose a professional tool for his work in the first place. That is why sometimes it is necessary to use several tools.

No, I do not call you names, I call you names. You can call me an eMQL-jast, if you like eRasts.

I don't think that eRastes are misguided in choosing R for research, it's easier for them, that's all. The simplicity of ready-made tools is what attracts them. You install R on your computer, choose a suitable package from the ready-made ones, load your data, get the result - that's the general principle. But in MQL you have to write something else! - It is difficult for them. That's why it is so important now that ready-made packages appear in the standard delivery of MT, it's like exactly what people who like "out of the box" need - there is no need to search for C sources all over the Internet (out of a billion variants of what you need), and just take a ready-made solution in the terminal itself.

Conditionally eRast and eMQL-ast can be divided into fans of dishes from multicooker and fans of improvisation in cooking. Both should have a place in MT, I believe that this is the key to the success of the platform - accessibility for all.

 

Honestly, I don't understand what the argument is about.

Do any of us write Expert Advisors in R?

Maybe someone wants to sell them in the market?

Does anyone write full-featured Expert Advisors in R?

Maybe someone creates hybrid variants, where the "guts" are written in both MQL and R, and are effectively intertwined through DLLs?

In my opinion, the fact that MQL may lack some functionality is quite natural and correctable, but is the complete lack of trading functionality in R correctable and who will fix it? Why do traders need it at all?

(I apologise for my amateurishness).

[Deleted]  
Реter Konow:

Honestly, I don't understand what the argument is about.

Do any of us write Expert Advisors in R?

Maybe someone wants to sell them in the market?

Does anyone write full-featured Expert Advisors in R?

Maybe someone creates hybrid variants, where the "guts" are written in both MQL and R, and are effectively intertwined through DLLs?

In my opinion, the fact that MQL may lack some functionality is quite natural and correctable, but is the complete lack of trading functionality in R correctable and who will fix it? Why do traders need it at all?

(I apologise for the layman's view).

Forgive me. I'll do it for you:

A Google search for "R trading strategies" yields 69,900,000 results.

You're welcome.

 
Sergiy Podolyak:

Forgiving. I'll do it for you:

A Google search for "R trading strategies" returns 69,900,000 results.

You're welcome.

And no... )

I love the "R -approach", give me everything on a platter.))