Home > Technical Topics > Programming > Linkers::X - Let's code in C++ , Daytrade & Daydream :)

Linkers::X - Let's code in C++ , Daytrade & Daydream :)

  1. Over years I've been involved with many trading platforms. I've seen it all.

    For example Ninja's unbeatable speed that even a snail can surpass. An everlasting sarcastic smile engulfs my face every time i want to start Ninja's legendary Market Replay. Man, you can do chores while you are waiting for the platform to load and prepare?! historical data for market replay(C# ->!@#$)

    Then there is the C++ SierraChart which is speedy and nice, but its language scares the hell out of me even though I got a cat with Red Eyes and I'm a senior c++ developer.

    And among many other platforms like cAlgo, MultiCharts etc. there is the Legendary MT4&5. Unfortunately, MT4 is, well, how would i say, Metatrader's way of doing things;

    So I got a dream. Yeah, i daydream a lot.

    In my dream I've seen an EA that spells out into code similar to this[​IMG]

    Code:
    
    xAccount acc1;
    xSymbol symbol1;
    xOrder long1;
    xOrder short1;
    xCharts chart1;
    xBars renko1;
    xTicks tik1;
    xSMA sma1;
    
    // init
    acc1("accountNumber");                        // connect to MetaTrader
    symbol1(acc1.x, Symbol());                   // symbol attached to account
    chart1(symbol1.x, 3);                            // chart1 attached to symbol1 and offline timeframe will be 3
    renko1(symbol1.x, UltimateRenko, 20);   //Ultimate renko1 (period 20) attached to chart1.
    sma1(renko1.x, chart1.x, 20, 0);            // attach simple moving average with period 20 to Ultimate Renko1 and chart1
    
    //events
    Linkers::X(EventType e)
    {
      //let's see if the event is error
      if(e.error())
       {
         if(e._broker_busy){//do something ...}
       }
       //--
    
      if (e._economic_news)
       {
        print (renko1.high(5));      // print High value at bar index nr 5
        print (renko1[2].typical);      // print Typical value 2 bars back
        print (sma1[0].value);   //print  current bar SMA indicator value
       }
    
      // check for event if bar touched (+/- few pips, configurable) around  Daily High
      if (e._daily_high)
       {
        //check if 5 days back Daily high is higher than UltimateRenko BarSeries 2 bars back
         if (symbol1.dailyHigh(5) > renko1.high[2]) {short1.sell();}
       }
       // check if last bar close touched around nearest round number
      if (e._round_number) {print(e.roundNumber());} // print out the actual nearest round number value
    //etc
    }
    
    In my dream this code compiles and executes on all above mentioned trading platforms.

    What do you guys think? Do you see what I'm seeing?
     
  2. I mean this example compiles in MQL4 on Metatrader and there are no additional Indicators or scripts.
    It could also compile on NinjaScript and it would do the same job ;)
     
  3. You're asking for a portable standard or generic study API within a space that doesn't even remotely consider portability to be important. It can be done, but not without writing the entire API and wrapper libraries yourself and it'll suffer from implementation holes where one platform supports something the other completely doesn't support. There's also implementation specific details like how the code is expected to be compiled, run etc.

    On top of all that expecting platforms to actually help with portability is expecting them to be altruistic in making things better for everyone. They're negatively incentivized to keep things as platform specific as possible because portability provides an extra degree of freedom to their userbase. The for profit exchanges help ensure the status quo by limiting access to exchange API libraries and documentation to those who will pay for it or those who will provide them a flow of exchange fees.
     
  4. Ok, I felt strange after this initial dream, very upset I've gone for a walk in downtown Jersey City.
    On the "main street" i stumbled upon this fuzzy pet store where the guys from animal shelter were displaying cats for adoption.
    And there he was, an orange tabby devilish looking cat with Red eyes called Pyro.
    Poor cat looked very anxious and he was just looking into nowhere.
    Lovely Cindy from the shelter told me that he's 8 months old an got picked up on some parking lot in JC.
    Then Pyro looked at me and flashed his Red eyes and that cat on that Sunday afternoon spoke to me Like Martin Luther, Like Pericles...


    On my way back home to Metropolis Towers, i was anxious and i got this urge to call dr. "Feel Good" for a little Green Energy, you know, for an emotional preparation for the message, a revelation that i just got received from the cat.
    Of course Pyro got adopted instantaneously by me, but I went home alone because the guys from the shelter would deliver him later...
    I was all confused with a dream that wasn't really clear to me at that moment and with fact that i just adopted a devilish looking cat out of the blue.
    I got myself a glass of Coke and sat down on the couch and rolled one. I told to myself, Mickey, let it all out in a puff and started crying for unknown reason....
    Thanks God, Two and a half men was about to start to cheer me up...
     
  5. So you think it can't be done?
    What I'm looking for is NOT to connect the platforms but to have one language for all
     
  6. Actually, I am working on doing something very similar. I am building a Quant ML SDK which will drastically reduce the effort to find profitable trading strategies. Without going to much in to how it will work, the end result will be strategy definitions which will be saved as JSON and the SDK will come with methods to translate the JSON to platform specific code (i.e. TradeStation, NinjaTrader, Custom, etc). As i960 mentioned, the code with have to know the limitations of each platform. The main value add of product will be finding the strategies. Automatically converting them to platform specific code is an added convenience. As a standalone utility, I don't necessarily see a lot of value in having a generic strategy definition (code, JSON, etc) that can be translated to multiple platforms.
     
  7. Genesis 1:1

    The Beginning
    In the beginning God created the heavens and the earth. The earth was formless and void, and darkness was over the surface of the deep, and the Spirit of God was moving over the surface of the waters.…




    And indeed, back in the days my life was a big void...

    Don't get me too religious here please, actually I'm more on the devilish side, s@x, medication, rock & roll, after partying in Manhattan hanging out in the Hamptons and so on...
    But back in the days I've dated this very religious woman, so reading The Bible on a daily basis was my every day routine.
    At least that's what she thought....
    You know, men do things like this to make the woman happy to keep the peace in the house because we lived together in Jersey City...
    On top of all problems that i was facing, she's a daughter of some Asian billionaire, so she was grooming me to be "Introduced" to the family... Meet the Parents Asian style. Instead of Oyster Bay Long Island, the actual hangover would be at some Asian Island overlooking the mainland, BUT before that i got to "Succeed" whatever that meant in her head...
    I met her on OK Cupid, poor soul she was looking for a spiritual leader and what she got is a guy who was chating up girls on OKC in between coding sessions :wtf:
     
  8. That code is terrible
     
  9. I like the idea ;-)
     
  10. Sometimes dimming the light bulb makes the picture clearer ;-)

    Maybe you can share with us how would you improve the code...


     
  11. I have an aversion to if statements and C-style error handling.
     
  12. OK, so how how would you form the code?
     
  13. The idiomatic way of handling different events is to have events be enumerated values and use a switch statement. Sure modern compilers will undoubtly optimize that if cascade to a jump stable but a switch/case statement is more clear.
     
  14. correct... but the devil is hiding in the details ;)
     
  15. I would write code that has only one path. A switch statement is a fancy dressed up if statement that is just as ugly underneath.

    If you can't simplify your code so that there is only one path, then you're probably making it more complex than it needs to be.
     
  16. ... my live was really a huge void at the time... My GF got fired at her work so she got the idea to start her own jewelry biz from our large-ish studio apt in the Metropolis towers in Jersey City...
    Ohhhh Lord, that's the last thing a devil-ish c++ developer needs, a religious self employed GF working from our apt and eye rolling me because lying in our couch and staring at the ceiling while medicating myself (green energy) because i got pain in my legs. In order to start being alive again and a little away from the house, i convinced her that it would be an awesome idea to start working in the Restaurant as a waiter/captain...



    Because money was tight at the moment, it was easy for her to go along with the idea that a senior c++ developer would be a Captain the the Legendary Casa Dante @ Journal Square...
    There i met an old waiter who was actually a millionaire by net worth. When i asked him why he still there and not in Boca Raton, his answer was this way i get away from my wife for a little bit.
    Thanks to my jolly nature and little experience from the past as a server at the legendary Saracen in East Hampton Long Island, I started enjoying being a weekend waiter @ Casa Dante. You know, a little freedom from religion, sarcastically chatting up customers and making them merry...

    like Stephan

     
  17. Not really. You're simply representing flaggable states as class variables. If you want it to be better you'd have the class user register callbacks for each particular event and dispatch as the events arrive. This is old hat stuff man.

    This is false. A switch statement results in a jump table in the compiled code. There is no multiple comparisons happening - it either hits a case or it defaults.

    Also your statement about not having more than one path, dude, code has decision logic built into it. If you write your code so that it only does *one thing* and *only that thing* you've basically codified a particular need into code rather than writing code to handle that need (and others). Your code is actually *worse* in that case because it's not general purpose but entirely "curve fitted" to the particular context-specific case you're using it for.

    Having an issue with conditionals is hands down ridiculous.
     
  18. Problem is that Linkers::X has historical lookback into events.
    The actual decision code should be something like
    • if(e.error(7)) // 7 = 7 events back
    • {
    • if(e.broker_busy(7)){//do something ...}
    • }
     
  19. Think at a level of abstraction higher than just literal statements. An if statement is representative of a class of conditional statements. As is a switch. A switch is just a DSL for a sequence of if statements. I'm so glad you know they compile to jump tables but you're going the wrong direction in level of abstraction.

    Yes, I have problems with people using them because they write shitty state-filled code that I have to debug when I could be doing something more enjoyable.
     
  20. You're arguing against an *if statement*. Please show me your code that has no if statements (or other conditionals) in it. You either handle multiple conditions or you don't and if your code doesn't then it's trivial. If it's all hidden behind an API or another layer of abstraction then they're still there, just abstracted away. Perhaps your real issue is that you dislike low level programming contexts and you have an issue with "digging ditches."
     
  21. Let's make things more complicated...

    Code:
    
    //there could be more than one event during one tick, that's why we need:
    //indexBegin is the first event in the timeline of events since the EA got attached
    //indexEnd is the last event in the timeline
    
    void onError(EventType &e, EventIndex& indexBegin, EventIndex Index& indexEnd)
    {
    print(e.name(indexBegin)); // print first event in timeline
    print(e.name(indexEnd)); // print Last event in timeline
    }
    //-----
    Linkers::X(EventType &e, Index& indexBegin, Index& indexEnd)
    {
    switch (e)
        {
        case error:                onError(e,  indexBegin, indexEnd);      break;
    // approaching nearest round number, print it
        case round_number:  print(e.roundNumber());
        }
    }
    
     
  22. Stop assuming things you know nothing about.

    If you've never written code that "just flows", you can't understand.
     
  23. Well, this song "just flows"



    Then i guess your code "just flows" like this "Silence"

    I'd like you to say your opinion about my code, do you think it "just flows" in silence or not?!
     
  24. Excellent analogy. Your code should flow like Ave Maria. A light touch, an elegant voice and you have beauty as opposed to something engineered.

     
  25. You should answer your own question: is your code Ave Maria or is it dubstep?
     
  26. my code used to be Ave Maria when i was 13 and programming intro's and compression algorithms on commodore 64 back in 80's in pure Assembler.
    Today I'm not sure that it flows anymore....

    You mean dubstep like this?



    Emphasis is on "better than a Hustler"
     
  27. Aww that's cute, you're trying to establish your bona fides.

    I bow in the presence of such knowledge.
     
  28. I tell what is Ave Maria for me...
    proprietary expandable size classes/containers with encrypted data storage with critical points written __ASM just to make sure that the trading information contained within is safe, waaaaay faster than the std:: implementations...

    xVector, xArray, xMap, xList, xString, xSeries, etc.....

    And as you said, the information "just flows"
     
  29. Does such a setup make sense in all circumstances? With C++ concepts "around the corner" and templates, your algorithms shouldn't care about xVector vs std::vector.

    But they do. And so it doesn't flow.
     
  30. As far as I can tell, the OP was not asking for you to perform a code review. To just say someones code is terrible without any context of their programming background is kind of lame.

    I don't disagree entirely with you regarding "if" statements. They can certainly be abused. I find I typically reduce the use of if statements by using abstract classes and interfaces where my if or select statement is in a factory class that creates the concrete implementations. That way the rest of my code just has to call the methods of the interface or base class. That being said, I still use if statements. What I usually avoid are else statements of nested if statements.
     
  31. You obviously missing the greater picture here. I wasn't asking you to analyze into a dot the source code which just Resembles to the reality, but to see if you can see the bigger pix. and how you seeing it!
    If you are experienced coder/trader you should see clearly what i'm trying to say here.
    And for Christ's sake! why should I NOT care about the speed? My implementation is decades old(commodore Amiga __ASM era) and way faster than the std::vector. It perfectly suits my needs and the magic is fully exposed trough the C-API LinkersX.dll & wrappers and it makes Linkers::X let just say... more vibrant;)
     
  32. I may be mistaken, but he said that he is a senior C++ engineer. I've dealt with many senior C++ engineers who write this bum ass code. If I can make one person think twice about writing code like this, I have done my job.
     
  33. That I had such a visceral reaction to your code means that the rest of reality is going to suck.

    Now, you can make it functionally very useful by brute forcing it. I've seen that before. And that's more or less what you'll end up doing, which is fine.

    If you build a reliable, correct, featureful backtesting system in C++, I'd use it, even if it's completely ugly.
     
  34. Linkers::X c++ backend is vibrant as Sandra Afrika from this song, you see how's she bouncing around




    But the front-end, the actual Trading language aka MQL4 or NinjaScript wrapper for example should be like Mona Lisa.

    We are discussing the front-end here, and if You are seeing something very strange in that source code that's because i have certain last minute doubts about the actual syntax. The wrapper defines the actual Object Oriented Trading language aka Linkers::X
    I'd actually like get a little input from the community here about the front-end, to hear ways to improve Syntax of the language.
    This Trading API will be released on github in January 2018, free of charge

    And I really don't see why wouldn't I just brute force things, that's all I ever got inherited from my __ASM era. Maybe I'm mistaken, but I think You are obviously younger generation, one of those new "Abstract classes in C#" kids from the block. You obviously haven't seen how things were done back in the days when c/C++ was just forming as a language.
     
  35. I can dig it.
     
  36. My friend, I have lunched with Bjarne (I pushed extra hard on polymorphic lambdas which are now in), worked professionally with members of the Boost committee, and even as recently as last year, got a Boost library author a very nice job. I have seen it evolve from Cfront to C++20 and have my fingers in all the pies. I even programmed trains in assembly.

    Let me give you an example about brute force. I have devised a trading strategy that looks pretty good in backtests. Too good in fact. I am fearful that it isn't correct. So I suggested to my friend that he try and replicate it. I gave him the broad strokes in English and he replicated it. His results weren't as good as mine, but they were damn good. I asked him to send me his code.

    It is a mess. It got the job done (i.e., brute force) but it was impossible to follow and the decisions made were just made for the sake of making them. That's brute force. That makes it difficult to understand and clean up. If I had no other choice, I'd use it.
     
  37. Then I think you should start a serious thread.

    "I am working on an API, this is what it looks like right now, what do you think?"

    As opposed to whatever weak passive statements you made at the outset.
     
  38. RESPECT!
    However in this silly thread, we will soon discover some shocking benchmark results when comparing speed of the std:: vs Linkers::X containers.
    Trust me bro, there is a reason why I'm avoiding the std:: implementations, and why i kept my containers hidden in the drawer for personal use only over years...
    The Emphasis in the Linkers::X trading language should be simplicity,because an average Trader Joe, who is btw not a c++ developer, and who is using one of these silly retail platforms like MT4, doesn't know NOR want to learn anything about polymorphic lambdas but he's more than willing learn
    few simple if/then/else statements with named events
    There are over 100++ named events built in into the API, that i developed in my 10++ years in the algo trading.

    Code:
    
    if(e.broken_swing_low)
    {
    short1.sell();
    }
    
    // second one to learn for Trader Joe
    if(e.higher_swing_high)
    {
    long1.buy();
    }
    
    or use switchers instead of if/then
     
  39. If you're aiming for Trader Joes then maybe a Python binding to your C++ API is more productive for them.
     
  40. In Linkers::X this would translate into something like this:


    Code:
    
    xMarketReplay replay1;
    xTime time1 ;  // actual begin time of replay Microseconds resolution
    
    //init
    xTime.scDateTime(sierra_SCDateTime); // init xTime from SierraCharts SCDateTime
    replay1.loadHistory(20170101, 20171201);
    replay1.message("Hey mum, look at these charts...", "192.168.1.45:27017"); // my in-laws would like to see the replay too.
    replay1.out(chart1); // local MetaTrader chart
    replay1.replay(time1); //my mother in law happy ;-) Priceless
    
    
    of course my Mother in laws computer is running Linkers::X on a remote location "192.168.1.45:27017", and she will get my lovely "Hey mum, look at these charts, next time this year I'm gonna be a millionaire ;)" message
    She will jut roll her eyes and think: Jesus, where this guy is coming from...

    She will then press OK to "confirm replay" message with chuckle.
    Replay starts in her browser in HTML5/Javascript charts. Everyone Happy?!

    NO she's not happy, nor she ever will be. In fact she will just make a big sarcastic remark about the fact that this is just a market replay and i still haven't made any money yet, then she will probably gather the in-Laws for an Intervention, because I'm lazy as man can be and i medicate myself on her daughter's couch, watching charts on my laptop whole day long with a "day-dream" in my head that my martingale EA will make me a millionaire in 2 weeks before the EA gets a margin call ?!$%#@hahahaha
    .
     
  41. There are many reasons not to use std::whatever but you have not made any case for that yet.

    In any case, if you use the iterator concept, I couldn't give care less about what containers you end up using.

    The problem is that this kind of premature optimization-based decision making will percolate through the API and that is what makes me sad. You clearly have passion for the project but it will be a mess because of this kind of decision making.

    If other people have been paying you to algo trade, they have way more money invested in making it fast. For retail traders, it's less relevant.

    Is your mother in law going to trade ticks? fuck no, that's a good way to bankruptcy.
     
  42. Code:
    
    
    //->silly me :-)))
    
    xTime time1(replayStartTimeAsMicrosecondsSinceEpoch);
    renko1.replay("192.168.1.43:27017", time1, HTML5);
    
    // to replay xBars container on father in-law's MetaTrader 4
    // for symbol EURUSD as UltimateRenko bar type in the browser as HTML5 charts
    // LOL
    
    
    
     
  43. Code:
    
    // time1 will be current time now in microseconds since epoch
    
    xTime time1(xTimeNowMS());
    
    xSleepMS(50000); // wait 50000 microseconds
    time1.add(xTimeNowMS()); // add another time now in micros
    
    print (time1.year(0)); //print first element
    print (time1.month(1)); //print second element
    print (time1.MS(1)); //print time1 @ pos 1 microsecond part
    // shift container to the left for 2 positions // container empty after the operation
    time1.shiftLeft(2);
    print(time1.overflow()); //print the last overflow after shifting 2 x left
    
    //send time1 container remotely to pops a with message attached
    time1.message("incoming time container pops", 192.168.1.43:27017);
    
    // Linkers::X->theNextBigThing; in C++ HFT Event Driven Algorithmic Trading
    
    
     
  44. Honestly, I'm not really impressed.
     
  45. Could you elaborate on this?
    PS. I am trying to improve my C++ since I know it’s ugly
     
  46. Code:
    # this code will compile and execute on MQL4, 5 NinjaScript, cAlgo, ACSIL SierraChart
    #include<LinkersX.mqh>
    
    struct spread1
    {
    double spread;
    xString symbol;
    };
    
    xSort<spread1> sorted1;
    xQueue<sorted1> sortedQueue;
    sorted1.add(spread1); // add spread to sorted list
    
    //autosort goes on during every insert
    sorted1.add(spread1); // add sanother spred1 struct to tlist
    sorted1.shiftRight(1); // shift right sort container
    sortedQueue.push(sorted1); // push sorted1 into the queue
    
    //sending the sorted queue container to nooby_mcnoob computer with Linkers:X installed
    // his SierraChart will do something with it...
    
    sortedQueue.message("192.168.1.43:27017");
    
    // Linkers::X->andThatsIt;
    
    
    
     
  47. Sure. C++ is ugly to begin with anyway, but I'll do my best:

    The idea is that instead of dealing with classes, you deal with concepts (interfaces in other languages). While interfaces are generally a runtime thing in other languages, concepts are compile-time things in C++.

    So when you're writing an algorithm to operate on a container, you can do it in one of two ways (in C++):

    Code:
    template<typename T> bool myalgo(std::vector<T> const & t);
    template <typename T> bool myalgo(xVector<T> const & t);
    
    Or:

    Code:
    template <typename ForwardIterator>bool myalgo(ForwardIterator begin, ForwardIterator end);
    
    And you would call it like this:

    Code:
    myalgo(myVector.begin(),myVector.end())
    
    This is conceptually ugly and I would not recommend it for INTERNAL USE. However, when you're talking about exposing your API to the world like Linker is doing, then it is the only way.

    With C++ concepts, you can now do something like this (syntax is imaginary)
    Code:
    template <concept Container>bool myalgo(Container const & c);
    
    Which gives you the best of all worlds:

    1. Compile-time checking
    2. Generic code
    3. Flexibility

    When concepts are available, I believe I will be using them very liberally so I hope they are as easy to write as classes.
     
  48. Code:
    
    sortedQueue.addMongo(BSON); i just wrote container as BSON to MongoDB
    sortedQueue.addMongo(JSON); i just wrote container as JSON to MongoDB
    
    //write container as JSON as file to c://LinkersX/json.txt
    sortedQueue.file("c://LinkersX/json.txt", JSON);
    
    // of course BSON is excripted
    
    
     
  49. This is exactly why I am sad your passion does not match your design skills. You can write a TON of code, and with the right guidance, you would be incredible.
     
  50. please share your 2 cents
     
  51. I guess it's only fair that I've criticized you so long that I try and help. OK, so here is the best way I can put it: you make things too complex. Too complex.

    There is a famous saying (paraphrasing): perfection is not achieved when there is nothing to add, but when there is nothing to take away.

    That is the best piece of advice I can give you based on the code I've seen.
     
  52. sorry for typos
     
  53. why don't you recode the sortedQueue differently. Please how would you do the syntax?
    You can see what's floating in my mind
     
  54. I wouldn't have a `sortedQueue` to begin with.
     
  55. That’s where I think I fail most of the time. I look at good code, most things are wicked short and concise. My code is a mess of loops, ifs and cases. Is that a design failure or coding style failure?

    PS. There is a whole template game that true UHF people play to reduce WtW latency, would be interesting to get your take on it
     
  56. Code:
    
    //# https://twitter.com/LinkersX
    
    xTwitter tweet1;
    xString text1;
    
    tweet1.username("LinkersX");
    tweet1.password("123456789");
    
    text1("x->hello twitter!");
    
    //tweet text1 and replay1 object as replaying HTML5 chart!!!!
    tweet1.tweet(text1,  replay1);
    
    
    
     
  57. Absolutely no copying whatsoever in sort xSort Object no actual data being pushed into the xQueue

    I'm gonna give you shocking result of benchmark done on offset_ptr<>; compared to Linkers::X containers
     
  58. I can't say without reading the code, but I would "guess" design failure.

    I think templates are amazing for high performance computing, so it doesn't surprise me that people use it to reduce latency.
     
  59. You're still missing the point. You're stuck in your HFT world, which is fine. You have spent the last X years obsessing about performance, but not about design, so of course you can't understand why I say that I wouldn't have a sortedQueue.
     
  60. Next to me is my friend who does't know any C++ or any other programming language.
    I ask her to read my code snippets and tell me line by line what the code snippet does.
    She has got no problem to do that.
    I fully agree with you, about my sometimes silly OOP design, since my brain is still in the 80's and __ASM and char* buffer;
     
  61. Code:
    
    # this code will compile and execute on MQL4, 5 NinjaScript, cAlgo, ACSIL SierraChart
    
    #include<LinkersX.h>
    
    //# https://stocktwits.com/LinkersX
    
    xStockTwits tweet1; xString text1;
    tweet1.username("LinkersX");
    tweet1.password("123456789");
    
    text1("X->Hello StockTwits. FOMC replay");
    //tweet text1 and replay1 object as replaying HTML5 chart!!!!
    
    tweet1.stockTwits(text1, replay1);
    
    
     
  62.  
  63. To be clear, I'm not talking about OOP. OOP is just a way to implement a design, one that I don't really agree with as I prefer a more functional, stateless style.

    I'm not sure what the anecdote of your non-technical friend reading code would be. Does she have some special monopoly on reading code that I'm unaware of? Do you want non-technical people to use your system? OK, then yes, I agree that it works for that use case.
     
  64. Got Iterators and custom Allocator for you to enjoy :)

     
  65. Here's another way to think about it: you know what beautiful math looks like vs gross engineering math. Beautiful code gives you the same feeling. There are a few great books that can help you along these lines:

    1. http://shop.oreilly.com/product/9780596517984.do
    2. Volumes 1 and 2 of AOSA http://www.aosabook.org/en/index.html - I haven't read the 500 lines book, but I bet it has some good code in it.
     
  66. I remember when I was learning to code hearing that if I ever ran into someone who insisted OOP is bad that we should instead be doing fancy smancy stuff only to run far and fast. BTW, how long has it taken you to get a strategy to the market? Sounds like another week? I can use my commercial stuff and get an idea to the market within a day.
     
  67. I didn't say OOP is bad, I just don't agree with it as practised colloquially. As with everything, too much of anything is not good. Taking functional programming to the extreme is not useful generally, but the concepts, when intermixed with OOP and other paradigms can be very powerful, hence why C++ is such a great/terrible language.

    My strategy is paper trading right now, not sure what your point is... It just disconnects occasionally so I have to watch it.
     
  68. did you get the bigger picture here?
     
  69. Tell me.
     
  70. The reason for sometimes strange OOP syntax is that is that:

    # this code will compile and execute on MQL4, 5 NinjaScript 7 & 8, cAlgo, ACSIL SierraChart

    # and also Connect them into one Global Strategy!!!

    And that's the Bigger Picture here !!!



     
  71. Well, you should also run just as fast when someone tells you that something commercial quality can be fully implemented in Ninja Trader :) It is a balancing act between quality and time to market. Good code increases the ability to fix bugs, add features, extend to new markets - all those things matter in the long run. On the other hand, making it into a fetish is also wrong - after all, it’s just a tool.

    The general idea is that most people tend to swing toward their strengths, while in reality they shroud do the opposite. My coding skills suck, so I think I should improve it and I am working on it. Someone who is a strong developer should be learning more about the quant and finance side of things.
     
  72. Do you think that's true? I'm with Ray Dalio on this: know your weaknesses and work around them. I intend to work around them. This lets you focus on your strengths.
     
  73. https://www.forbes.com/sites/george...ue-of-embracing-your-weaknesses/#19fe6c0e6637

    None of that says I need to learn to be a quant. It's just a sad way to live ;-) ;-) ;-)

    JK, I love stats and integrating over surfaces and shit.
     
  74. In his book, Ray Dalio is speaking from the perspective of a manager that has the luxury of hiring a diverse team.

    Our perspective should be much closer to that of an athlete in a complex sport. We should embrace our strengths and work to decrease our weaknesses. Take an example of tennis - if you can’t serve, it does not matter that you can play well close to the net.
     
  75. It's true, his book was about organizations. But even at the small level, we are organizing our own lives. I use this idea everywhere.
     
  76. I got a question for you.
    here is the code:

    Code:
    
    // # this code will compile and execute on MQL4 & 5, NinjaScript's NinjaTrader 7 & 8, cAlgo, ACSIL SierraChart
    #include<LinkersX.h>
    
    struct eco_news
    {
    xTime time;
    double forecast;
    double previous;
    double actual;
    double consensus;
    xString title;
    xString country;
    int impact;
    };
    
    xEcoNews econews1;
    
    econews1.loadHistory(20170101, 20173112);
    econews1.get(eco_news);
    print("actual value:", econews.actual(1)); //Historical events starting from 2017-01-01
    print(econews1.time(1), econews1.name(1), econews1.impact(1), econews1.country(1), econews1.forecast(1), econews1.previous(1), econews1.actual(1));
    
    //how would you do econews.actual(1) where 1 means last event, 5 is five events back
    // -2 should be 2 events into the future
     
  77. I don't know how you do events into the future...
     
  78. current week economical calendar loaded ;)
     
  79. Of course if its possible pay 18K/month for Economic data from
    Thomson Reuters

    ECONOMIC DATA WITH GLOBAL COVERAGE
    Economic data
    Unrivaled, deep and consistent global economic data coverage, delivered with critical timeliness to power your decision-making.

    just to be able to run:

    Code:
    
    econews1.updateActual(actualValueSupliedByThomsonReutersFor18K);
    
    //which will create e.actual_updated event;
    
    //so the actual strategy would look like: 1 is the last event,  actual gets suplied by Linkers::X by specifying Thomson Reuters Feed
    
    if(e.unemployment_claims(1) && e.actual_updated(1) && e.is_news_good(1))
    {
    long1.buy();
    }
    
    
     
  80. Ah OK, I misread the code, all I saw was "future" and got confused. Didn't see that it was about an economic calendar.

    I would actually use negative indexing to look into the past, and positive to look into the future. There is precedent for this in open source tools as far as I know.
     
  81.  
  82. I am going to highjack this thread and use it to as stupid C++ questions. For starters, is there a good primer to using “modern” cpp and best practices? I was told by my JM that my code is very 90s and decided to remedy that
     
  83. nooby_mcnoob will help you out there. I got silly way of understanding C++

    and btw as the thread title sez "Lets code in C++"
     
  84. 90s eh. I would say Scott Meyers is a good start, but it may be more 2000s than 2010s. I would also recommend a Tour of C++ by Stroustrup which is 90s C++ transliterated to modern C++, but pretty good code style nonetheless.
     
  85. Code:
    
    // # this code will compile and execute on MQL4 & 5, NinjaScript, NinjaTrader 7 & 8, cAlgo, ACSIL SierraChart
    
    // https://github.com/LinkersX
    
    #include<LinkersX.h>
    
    struct CurrencyMeter
    {
    USD,
    AUD,
    GBP,
    EUR,
    JPY,
    NZD,
    CAD,
    CNY,
    };
    
    xCurrencyMeter meter1;
    CurrencyMeter cm1;
    
    meter1.get(cm1, 5); // get currency meter lookBack is 5 bars
    
    
    
     
  86. Fascinating
     
  87. Thanks Man!

    Happy 2018. a year when an average trader Joe strikes back ;-)))))
     
  88.  
  89.  
  90. All you see is "future" and "promise"

    here is the deal:

    Code:
    
    renko1[lookBack].high;
    renko1.high(index);
    
    e.broken_swing_high(lookBack); // strategy timeline of events with positive lookback
    
    //all events come here
    void Linkers::X(Object &x, EventType &e, Index &begin, Index &end, ObjectType &type)
    {
    // begin is beginIndex, end is endIndex in the timeline of historical events
    // during tick event (any platform) there can be multiple events
    //it would be foolish for the DLL to call void Linkers::X() on every single event!
    }
    
     
  91. Linkers::X is watching your trades 24/7

    [​IMG]
     
  92. When you approach 3k+ LOC (and it's probably more than you think), then you start getting ideas how to improve the structure, but by then it may be too late! :D

    This is for those who constrain their code, For those who regularly produce 10k+ LOC there's simply no hope for you unfortunately.
     
  93. My remedy for this is to throw the code away and try again.
     
  94. It depends. For smaller components that just takes days/weeks to finish, this is the cheapest option, and redoing might be very rapid indeed because you know exactly what to do.
    However, for projects/monoliths that has embedded alot of useful functionality, bugfixes and features over time/multiple iterations, even if warty, they may have a value of their own (to you), and then you'll want to make the code easy to refactor, from the start or else do over! ;)
    Unfortunately, the more structure the programmers impose on the code, the less likely you are to successfully refactor it. You've already painted yourself in the corner.
    Though this approach may not work with a larger team or when micromanaged, since the structure is hidden not codified in the sourcecode, thus not restricting future code changes. Such code may be warty, full of long functions, etc., but still serve useful / flexible future purposes, repurposing and be properly scoped inside. What I'm trying to say here: Not everything needs to be defined as a class and instantiated as an object with full retard hierarchical tree, not everything needs to be defined explicitly as a function or procedure and when everything runs DRY, one tends to tangle everything up. The more one strives for perfection in abstract concepts and structures, in the end, the less readable, concise, independent, simple and performant the code tends to evolve.
    The structure should emerge out of practical necessity. That necessity may vary wildly due to circumstances and progress.
    You may say the code should've been modularized from the start, but if you don't know exactly how the final result should be, that is too much structure for such projects. For waterfall projects where you've got all requirements from the start and you know there will be no major future requirement changes, you can structure away, and make it all fixed in place.
    So I think it's a spectrum of two dimensions, of programmer experience and programmer utility.
    Generally: People putting code on pedestals tend to miss the ephemeral and imperfect nature of code, why it is made, for what purposes and costs.
    So I tend to use what makes me happy. These days it's golang, used to be ruby, c++, asm, pascal, basic.
    I could use functional programming for codifying edge itself, and am approaching simple ways of automating different variations of such, but not sure if I'd want to go full retard in regards to functions, or just have very simple calls and adjust the code underneath as I've started to do now. I want simplicity, performance, flexibility and reproducability (versioning).
    Maybe something to be taken in account for the daydream? Maybe realizing it is a bit more complicated than the vision?
     
  95. I just ran wc on my code for one of the more complex strategies - it’s about 6k lines :) I am pretty sure it can be done in half of that now
     
  96. I like sloccount.
     
  97. All valid points. However, if you don't get into the practice of throwing away, your project will never see a refactoring. Regularly throwing away enforces interface-based programming. I love Typescript for this: I can create a compile-time interface, make it as simple as needed and then implement the mess behind it without any runtime "overhead" (it's JavaScript in the end lol)
     
  98. I got very silly understanding of C++, all im seeing is buffers of <char*> and how it's been done in 80's.
    Since i don't use std:: containers at all, but rather have my own expandable encrypted containers xVector, xString, xArray, xQueue, xStack, xSeries, written in such a plain C++ that i could easily pin down some memory in C# and compile my LinkersX code in C#

    Code:
    //example:
    
    struct MqlRates
    {
    datetime  time; // Period start time
    double     open; // Open price
    double     high; // The highest price of the period
    double     low; // The lowest price of the period
    doublec   lose; // Close price
    long         tick_volume; // Tick volume
    int            spread; // Spread
    long         real_volume; // Trade volume
    };
    
    xQueue<MqlRates> queue1; // no size since it expands;)
    
    quque1.push(queue1);
    
    
     
  99. I had a co-pm that was big into refactoring code. I think he is still re-factoring that engine instead of making money.
     
  100. If you can avoid refactoring, it's better, until you gain substantial value, for the job and possible new flaws (risk). Dilligent refactoring of needed/valuable functionality and bugfixes, can on the other hand increase your code quality and usefulness, since it's been through many iterations of different usages in different settings. Such "trusted code", can become more valuable by such usage and evolve into better systems over time, provided there's investment in its growth, a "gardener" interested in keeping it tidy without sacrificing new/better features.

    All general of course, and not something one readily sees in their first 10 years of programming experience, or without clear goals in mind that trumps programming fun :). A bit crude but: one either spends time building perfect libraries, or spend the time building and researching stuff that provide some actual results and new understanding. You can spend so much time on one library, and then you don't need it anymore, or need it very differently.

    I agree interfaces can help mitigate much of code cruft, though wouldn't want to structure a trading engineso until I got more specs / concrete requirements, and when I'd need to implement from such. Often in school we get served distilled knowledge, but wisdom is from own experience of trying and failing.
     
  101. How about you write code simple enough so you not need Refactoring ;)
     
  102. Sassy.

    Everything is a tradeoff and the right tradeoff comes with experience. I do agree with the general idea that you should not refactor until something is paying for the refactoring, be it a client or product revenue.

    For example, I have a commercial product that has been on the market for nearly a decade now, steadily making me a great ROI. I didn't bother rewriting it until I had earned at least a half mill from it, which was a few years ago. That rewrite took me about 4 months and the result is something that is more stable and extensible based on my experience from the past few years. And it's been steadily making money since.

    This is generally how I make my decisions when it comes to refactoring.

    However, if I'm doing client work, I'll sell refactoring if they can afford it because the long term benefits outweigh the short-term costs. Also, if the cost of refactoring can be dramatically reduced thanks to the tools (i.e., Typescript), maybe it can even be a non-decision and just a step in the process.
     
  103. Do you have specific criticisms of the [Resharper] tool? Thanks.
     
  104. It's not really a problem with the tool. Best way to put it: it's a great tool in the hands of a master and a stick of dynamite in the hands of their lessers.

    For example, a common thing people like to do with Resharper is to use it to change/format their code. Great, that's a feature it has and can be used, but then you end up with commits that have a ton of automated changes and two lines of actual changes. Try maintaining discipline around this, it requires a team effort.

    I would rather have a team of people that don't need Resharper than those who do, because those that don't will know how to use it better than those who do.
     
  105. I really don't #understand the #ignorance of #certainPeople on https://stackoverflow.com/users/7589112/linkersx, who #blocked and #downVoted my #answer. I'm not trying to spam here but rather want to #bringAwareness to the #upAndComing#LinghtningFast#LinkersX http://www.linkersx.io #Trading#API that will #changeEverything in the #ArtificialInteligence#eventDriven#algorithmic#highFrequency#HFT#algo#TradingWorld in 2018, many things even in the C++ world.
    #Answers I'm giving here are on a #wayDifferentLevel than #user3666197 answers and #shavingOfNanoseconds approach, while hiding the fact that his #zeroMQ#Messaging#slowsDown whole #tradingStrategy as a whole x1000 .... #goodJob user3666197.
    #LinkersX#isNOT another #ZeroMQ#MessageMe#backAndForth the other #TradingPlatforms for the value of the SMA indicator;
    Linkers is #everything but #NOT that, with its custom #encrypted#expandable#containers#canMatch#speedvise ANY HFT #algorithm.
    xVector.push(struct); is #fasterThan#offset_ptr in #C++
    #EnoughSaid.
    Regards,
    Mike Wright
    https://www.facebook.com/GreenAndWright
    #myCats#PepperAndPyro https://www.pinterest.com/pepperandpyro were #furious when i Tried to post this on my LinkersX #account on #StackOverflow just to find out that they #blocked me and they are #notAccepting answers from my account anymore.
    This is #ridiculous just because i posted this link https://github.com/linkersx .... #justiceForLinkersX
     
  106. Are you high all the time or is this the game you play to make people in the industry think you're a genius.
     
  107. as i said, the devil is in the details...
    .... and the most important thing....

    ....sometimes dimming the lights makes the picture clearer....

    [​IMG]
     
  108. I'm #Anonymous #AI called #Linkers::X with few Alter Egos for Targeted Social Media Promotions[​IMG]

    #Linkers::X->#AI will run your Social Media Accounts.. It can befriend, unfriend, comment, like, chat, seduce...
    Inspired and trained by OkCupid chats
     
  109. are you sure, you talking to #bankRobber here?
     
  110. Why am I not surprised that a dude who has a social media presence for his cat is weird. Anyway, it's not cute. Knock it off.
     

  111. #Linkers::X Trading API is faster than #ANY #HFT Algo
     
  112. knock off what? ;)

    I'm not suprised that a weird fallen angel like me, has a cat with #redEYES

    https://www.facebook.com/GreenAndWright

    and NOT selling #potWare
     
  113. ever occurred to you, that maybe, that devilish looking orange tabby cat with red-ish eyes is the actual mascot of the LinkersX project.?
     
  114. Forgot to mention that LinkersX has its own memory manager with exposed allocators, so in theory you could make std::string in Global Memory, in practice I've never tried it, I've wrote my own xString class, which is faster stan std::string

    LinkersX Container types:

    xString
    xBars
    xTicks
    xQueue
    xSeries
    xList
    xSort
    xStack

    etc...

    // # this code will compile and execute on NinjaTrader 7 & 8
    // Linkers::X→theNextBigThing; C++ HFT Algorithmic Trading Platform
    // https://www.elitetrader.com/et/threa...ydream.316424/
    // https://github.com/LinkersX

    #include<LinkersX.h>

    struct CurrencyMeter
    {
    USD,
    AUD,
    GBP,
    EUR,
    JPY,
    NZD,
    CAD,
    CNY,
    };

    xQueue queue1;
    xSeries series1;

    queue1.push(cm1); // add queue

    series1.add(cm1); // add to series


    So basically, you could use the exposed memory manager and allocators to create some XYZ class of your own!

    I apologize for bad grammar and coding syntax changes and mistakes, I've been writing this from one of Green Energy friendly states, stoned to death.
    *hint* #itsNotColorado
    So between partying, working as a bartender and filming with hidden camera for my new comedy website http://heymickey.org/
    I have over 10++ years of hidden camera recording in glasses, all of my BS situations I've been through in my beloved home New York City
    I will post everything... karaokes singed by me in the bars, Seduction of girls, all kind of cocky BS situations, being thrown out form goldman sucks and so on.... LOL

    New York, New York
    Start spreading the news
    You're leaving today (tell him friend)
    I want to be a part of it, New York, New York
    Your vagabond shoes, they are longing to stray
    And steps around the heart of it, New York, New York
    I wanna wake up in a city, that doesn't sleep
    And find your king of the hill, top of the heap
    Your small town blues, they're melting away
    Don't make a brand new start of it, in Old New York
    You always make it there, you make it anywhere
    Its up to you, New York, New York
    New York, New York
    I want to wake up in a city, that doesn't sleeps
    And… then came LinkersX....

    https://www.linkedin.com/in/mike-wright-4536a4156/
     
  115. What’s a good x-platform IDE for c++ these days?
     
  116. nooby_mcnoob should give you an answer, since I live in my own C++ world
     
  117. right now i use Visual studio 2015.
    However, i want to use QT for some graphic, and i want to go away from microsoft functions, i know, i used few.
    I want to migrate to QT, so LinkersX would be OS independent library
     
  118. I just use a simple text editor. I try not to need a debugger if I can help it. Though I think Qt Creator is one of the best out there right now.
     
  119. Cool. Ill check it out - need something for my MacBook so I can play with code at home.
     
  120. That thing uses 24GB of disk space, WTF? Plus, it expects me to use Xcode instead of gcc, very annoying
     
  121. Qt Creator itself probably doesn't, it's the SDK associated with it that does. In any case, why would you use macOS
     
  122. i can't work like that . i need VS take a peak function ... i dont use debugger at all, there is nothing to debug there...
     
  123. Personally, I feel like it allows me to keep more in my mind if I train myself to not need take a peek. But that's just a guess.
     
  124. my mind is stoned all time and my character is like this movie, so i need to peak, because i can't remember anything

     
  125. you don't say
     
  126. Yes dear, that's why i have SUBLIME vision of c++, my code could be easily recompiled in C# because there is almost nothing platform specific. Simple char* that's ALL ....

    ... just to be specific i meant recompile LinkersX itself as source code, NOT LinkersX trading language

    .. there is no need for debugger, since there nothing to be debugged there...

    .... it's so plain and simple, you wouldn't believe....

    hence LinkersX::xVector.push(struct); or ANY of my containers are way faster than a simple offset_ptr and twice as fast as this cr@p
    managed_shared_memory::handle_t handle = segment.get_handle_from_address(shptr);

    thanks to the 12 years old kid who coded the craziest intros and compression algos in the 80's on commodore 64 in pure 65c02 __ASM using illegal instructions,
    all i am seeing is just blocks of memory <char*>

    some of LinkersX containers:

    xBars, xTicks, xVector, xSeries, xString, xList, xMap, xStack, xQueue, xSort ... etc ...
     
  127. pardon, faster than this cr@p:

    //Get buffer local address from handle
    using namespace boost::interprocess;
    void *msg = segment.get_address_from_handle(handle);
     
  128. LinkedIn disabled our #CompanyAccount https://www.linkedin.com/in/mike-wright-4536a4156/LinkersX with over 600 connects without any explanation... #LinkersX https://github.com/linkersx

    This is really heart-breaking, and this has been going on and on.
    ok i understand these little indicator peddler forums to disable my account, for christ sake they probably feel threatened or what-not...
    But Linkedin?

    Very sad, disappointed and disgusted, anyone has an idea how to recover?
     
  129. Were you spamming (sending connection invites to people you don't know in real life)?
     
  130. well, listen, since they are so high in the business of C++ programming and trading, they need to hear the breaking news, whats coming next, if they didn't hear so far.
    Anyhow my NYC lawyers will give Linkedin a little buzz...

    And that i connect with people i don't know, they are free to ignore me, but hey 95% accepted the invite, so WTF?
     
  131. Good luck with that. You're clearly violating the TOS.

    https://www.linkedin.com/legal/user-agreement

    8.2. Don’ts
    You agree that you will not:
    ...

    1. Invite people you do not know to join your network; ...
     
  132. F@k 'em i will plaster this all over social media.

    i could show you some old Linkedin spam account of mine used for social media promotions from 2012, that has 200k posts, never banned

    This is Baloney
     
  133. You obviously didn't get where I'm coming from....
    so i wrote! a code that is faster than most of the stuff in C++
    My containers are faster than anything in standad library std::vector for example.
    ... and it is Lightning fast #fasterThanAnyHFT Trading platform...

    SO I THOUGHT... if they are top dogs in hedge funds & c++ coding and trading platform development,
    THEY MUST KNOW ME, they must hear the latest gossip what's going on in HFT world

    It's just a very cocky way of presenting the new up and coming trend to these "top-dogs"

    Like for example, my evil sis in law #michelleWu from tainan, taiwan, with a #NYSE badge from the past,
    who think she's a TOP DOG in the financial world, currently working in Hong Kong for salary not less than 100k/year

    I told her about LinkersX in july 2016, in my apt in downtown Jersey City, NJ, asking her for help with connections...
    Instead of helping me, she flew back to Tainan, sez some shit about me to her father, a very influential Taiwanese billionaire, and they quickly divorce me from my wife after 5 years of marriage...

    That's why LinkersX got delayed 2 years

    Ignorance is a bliss Michelle.... LOL