Hi, good morning Not as full as last year last year there was a the other room was full as well, so I Have to step up my game now Please tweet about this session with the hashtag PHP UK and my Twitter handle.  I like to swim cycle and run I Work as a software engineer slash developer advocate for a company called get stream.io. I joined the company six months ago We built scalable newsfeeds and activity streams Can you show me some hands who has ever set up a follower relationship pivot table, right? You probably know that When your user base grows the pivot table gets enormously large And sometimes for some people like Twitter in the in the early days when they had a lot of fail whales Their pivot table was basically so big they couldn't handle Joining it with any other table because that would it would go out of memory And it would be super hard to fetch a timeline for some user So that's what we do We built scalable newsfeeds and timelines and notification feeds and activity streams So everything you see in some social app where you can follow people You can basically use our tool to build that feature and you don't have to think about pivot tables or memory or whatever So we have a page called Get streamed.io slash try the API It's super easy. I'll remember you after the talk as well You can sign up with github or register with github. It's totally free and you can browse to our API and see how it works But that's not what you came for you came for this you came for IOC container It's quite tricky Let me first preface this by saying what this talk is not about IOC when I talk about IOC I'm not using it as an acronym for International Olympic Committee That's not what it's about You might think IOC container Well, it's about Docker. No, that's not true either It's about inversion of control But to understand inversion of control we need to understand a couple of design patterns first So this is a quick quick quick five-minute lesson on design patterns And there's no better way to show off design patterns by showing some code So this is the first class. I want to show you it's a super simple service class and it has one method Calculates something it gets something from storage Calculates it does some calculations and returns the result. It's super simple. We all have dozens of classes like these But to get something from storage you actually need a connection with FTP so we do a first Design pattern here. We inject FTP into the service class Basically, you want something that's already configured and set up and inject that into the constructor So that's the second design pattern first. I talked about Dependency injection which is injecting a dependency something you depend on so this service class depends on FTP connection to work And the way we injected is constructor injection. So that's two design patterns just in the first few slides So the project rolls along and some some people come in and say well, we were hitting quite a lot of FTP traffic here Maybe once you want to add some caching. So developer comes in and says, okay, let's get this job done super quick Let's add a few lines in this service class where we actually do the FTP fetching So we cash some stuff and prevent the class from hitting the FTP over and over again now the QA engineer or whoever jumps into the room again and says well, we want to know how much of How much we actually hit this FTP server? So we add some logging Again a few lines to this simple service class, but now the service class does five different things It gets something from the FTP caches it Logs it to monologue or whatever this does some calculations and returns the result That's a lot of stuff going into one simple class. That's kind of a code smell, but okay, it works. So We'll just deal with it But later on we see that we depend a lot on FTP here We did depend on FTP to get some stuff. We cash what we get from the FTP We log what the what we get from the FTP That's that's a super easy refactor, right? Just get everything that has to do with FTP the storage thing and just extract it to a different class That's the first step. That's the first simple refactoring. We're going to do So we create a new FTP storage class and we just copy paste some code We give it a new method name Which is get and then a key or a file name, whatever you want to call it And we refactor the service class to inject the FTP storage class instead of the FTP Right, that's a super simple refactoring and now the service class is super clean It does one thing only and that's getting something from storage and return the calculation on that value The next step we can introduce is Introducing interfaces, right the service class depends still on the super detailed FTP storage class, which is super low level It's super. Yeah, super specific to this use case We might want to depend on something more abstract. Maybe a sort of storage interface, right? This is a super simple refactoring step again just introduce an interface Make the FTP storage implement the interface and refactor the service class to type in the storage instead of the FTP storage Right what we are left with is two classes and one interface the service class and FTP storage Class which implements the storage interface The next step is we can go back and refactor the FTP storage, which still does a lot of things It's fetch it's fetching from the FTP. It's cashing it and it's logging it. That's still three things in one class So if you're striving for single responsibility, we can refactor that By using this storage interface we can start Introducing some decorators This is the first one the cashing decorator implements the same storage interface It's super simple And it's basically going to wrap another storage class Doesn't have to be an FTP storage could be a login decorator as well So we inject the login decorator which wraps an FTP storage in here We also take a cashing implementation so we can actually remember what it's what it has returned in the past The same thing is true for the login decorator. It just wraps any kind of storage Yeah interface Typed thing could be the cash Decorator could be the FTP storage decorator could be an s3 Amazon s3 implementation So if you now look at the FTP storage, it's it only has one responsibility left and that's to get something from the FTP So I showed you a lot of code But now I want to show you how the different classes and interfaces work together in the beginning We started with this we had a service class which dependent on an FTP storage, which is dependent on an FTP class If you look at this graph all the arrows go up But the class at the top is like the most specific class that's the most Low-level implementation that you have in this entire graph, which is Completely the opposite of what you want You want the low-level implementation to be at the bottom of your graph and to go to have all the arrows go upwards so after The refactoring we end up with this graph We end up with a service class which depends on an interface which is high level and And then we have an FTP storage class which is low level at the bottom of the graph which in In itself depends on FTP which is still lower level than the service class the service class that does no longer Care about what the search is is it an s3 search interface? Is it the is it the caching decorator? Is it the login decorator? It doesn't matter So all of these low-level implementations and decorators They're all lower level than the service class which depends on any kind of these implementations So if we put them side by side you see that the FTP class has become Has moved from the top of the graph to the bottom of the graph So yeah, the design patterns I was talking about are dependency inversion instead of depending on a Low-level implementation you're going to depend on a high-level abstraction So all arrows are going up and your low-level implementations are going down in the dependency graph The second Design pattern is dependency injection. You're going to inject whatever you depend on for example the storage interface Through a constructor injection. So that's that's a form of dependency injection Some sometimes people use DI as the acronym for dependency Inversion and it's actually the same acronym as dependency injection But they're actually two different design patterns. So keep that in mind And then the last one actually works together with the top two and that's inversion of control Inversion of control IOC basically means You're no longer going to Let the service class new up a FTP storage like this And the beginning we had this We created a new service and we inject an FTP and at the end we had this Which is pretty much a lot of code Which we don't want to write and that's where the IOC container comes in, right? So instead of calling all of this or newing up all of this inside the service class We're going to reverse that and say well, whatever it is.  I'm going to pass off control to the container and I'm going to say well container you're up It's it's your task to tell me what is going to be injected inside the service class So I'm going to reverse the the method the object creation to let the IOC container itself do the object creation for me So that's inversion of control When we use a container and say well get me a service class object It's going to look up what it what needs to be done to create this service class object First it's going to create the FTP Storage class then it's going to wrap it with the log decorator then the cache decorator and then inject all of that Well the cache decorator instance, which is wrapping all the other instances into the service class note that the object that the service class is Being injected with is actually the cache decorator and not the FTP storage But because the cache decorator implements the storage interface the service class doesn't matter It doesn't care what's being injected. So that's IOC inversion of control Helps you with composing all of these objects that the IOC container help you with composition Now enough with a gang of four Design patterns here Let's talk about the the actual implementations we can find on packages So there's a ton of frameworks and all of these frameworks come with their IOC container There's symphony dependency injection Illuminate, which is a Laravel container RRDI is a Zen framework pimple leak container and most of these implement Some kind of interoperable interface. So there's container interrupt slash container interrupt Which is now deprecated in favor of the psr11 psr slash container package or interface so last year on Valentine's Day They basically deprecated container interrupt in favor of psr11 So that's some love for the phpfig this is what the the interrupt container looks like right now it just Extends the psr container. So it doesn't add anything to it And this is what the psr container looks like it has two simple methods The first one is the get method which returns the result resolved object or should return the resolved object And the second method is just a Boolean method. So it just returns. Yes or no I can I can resolve this or I cannot resolve this right Now let's let's talk about how this container works right the internals That's what you are all Interested in I hope so The first way a container could work is by and doing by doing something called Automatic object resolution That's just some fancy words for saying it's going to look at the At the constructor and see what needs to be injected. So to be able to create this send invoice class You need to look at the constructor because that's how you knew up a new object so the constructor has a mailer argument which is type in that mailer now We're going to do some construction injection here I use a container to do that and if we use the php leak container we can tell it to use a Reflection container and this reflection container is using a php native feature called reflection And the reflection API goes like this You pass in the class name to a reflection class object You get the constructor and you get the constructor parameters And then you can loop those parameters and get those to get the type hints the type hinted classes of those constructor arguments and The container is going to do that recursively. So if you go back to this This sent invoice class the sent invoice class needs a mailer object But if the mailer object needs something else in in that constructor It's going to resolve those objects as well So it's going to crawl down the dependency graph and find all the objects or all the type hints resolve them from the container by doing automatic Resolution and then it's going to inject it back into the sent invoice class so it's going to do it recursively and Basically all of the all of the ISC containers have it The symphony IC container has it the Zen Zen framework container has it Laravel leak container So that's the super easiest way Just tell it to do automatic resolution and you don't have to help it Just give me the send invoice class It's going to look at the constructor arguments and recursively resolve those objects Obviously it only ends when there's one constructor without any arguments so it can you up that object and roll Go back up the dependency graph to inject everything into the send invoice container But I just basically told you to Depend on an interface instead of a low-level implementation, so we're going to need to help the container sometimes So if we would have type in that the sent invoice class with mailer interface We're going to need to tell the container which interface or which implementation to inject into the send invoice class so The first situation is where we need to help the container is when we type in an interface and we actually need some concrete class to be To be resolved to inject there the first way to solve this is to use aliasing Right, we're going to tell the container. Well, whenever This an object is needed with this interface Use this concrete class In Laravel it looks like this container alias mailer interface uses concrete mailer Implementation and symphony. We can do the same thing with set alias and in most other Most other Containers we can use something called a anonymous function which is used to resolve this So we can say well leak container I'm gonna add a anonymous function here Which you can call whenever someone needs a mailer interface object and Whenever someone needs a mailer interface object call this anonymous function and I will return you the result Which you need to inject So we basically ask We basically tell the container Here's another anonymous function and trust me. I'm going to return a mailer interface type object Um, so we can create a super simple one-line anonymous function that says container get mailer class It just returns the Returns back to the container to say well, here's the actual implementation. You want to in you want to be injecting the second situation is When a constructor has arguments and one or more of those arguments are not type-handed for example You won't yeah, you have a constructor with two arguments and one is type-handed one is not then basically the Reflection container or the reflection class doesn't have any type hints the container doesn't know what to inject into that constructor So we're gonna have to define those dependencies and simply we can do this We can say register mailer at argument We can call that at argument method multiple times to say well This is the order of the arguments you want to inject into that constructor whenever you instantiate the mailer class for basically any any other container you can again use these This struct of anonymous functions So for the pimple and the leak container you can say well whenever mailer interface is resolved Call this anonymous function. So it's the same principle here it's kind of a factory method or a Anonymous function closure or whatever you want to call it and you basically tell the container well, trust me If you call this function, I'm going to return you an object with this interface The next situation is When a class is type-handed, I want to return I want to inject an object But the next time this I want I want something to be resolved. I want to return the exact same object This is useful for injecting a translator something with a global state translator has the the locale Which is global for the entire application Or an entity manager? You only want one entity manager to be used into into your entire application or an event dispatcher Something that you want to share all over your application and you want to have the exact same object. So sharing an instance In Laraville, it looks like this you do a container share and No, you do you do a container singleton and in the leak container you do container share And the symphony it says Register and then set shared to true And basically any container has this feature Some have this Sharing feature as the default some have it Disabled by default so it depends on the container. You're actually using but you can define per dependency Whether you want to reuse the same resolved object or not the next situation is When you have Different classes and they basically have the same type hand for example file system interface But you want to inject different implementations or different configured objects So For example, you have a file system interface and you have a bunch of controllers a photos controller a PDF controller But you want them to have a different configured file system interface object To do this we can use something called contextual binding I found I found this feature in Laravel. I don't know if any other containers have this but I'm I'm I'm pretty sure there's some other containers which have this but in Laravel. It's super easy Basically, I do this I Go to the container and I tell it there's different file system interface objects that you can resolve And I'm going to name them The first one I'm going to name filesystem.photos filesystem.files filesystem.pdf filesystem.avatars And I give them different names so When there's a photos controller, I can say When photos controller needs file system interface give it filesystem.photos and I do the same thing for different controllers So depending on the context in this case the photos controller I'm going to inject a different item from the container based on The name I gave it so this name is the same name I gave it when I registered it on the container, so I said container add filesystem.photos Whenever someone resolves filesystem.photos give it this this implementation or this this instance and That's how you are you basically register different items and You tag them or you give it the name filesystem.photos and you inject it in the right place You can still do this in in different containers as well. For example in the leak container. I just use a default Anonymous function and I say well when filesystem Well when photos controllers is resolved I want to get container get filesystem.photos and I want to inject it as a first argument It's as simple as that the next situation is When you are resolving something for example an event dispatcher or a Entity manager from doctrine you want to do something right before you inject it somewhere For example, you want to resolve some you want to register some some listeners for the entity manager in doctrine I Still want to resolve it in a normal way, but right before I'm injecting it I want to register some stuff for this we can use a solution called container events Some some implementations call it inflectors some call it hooks you can call it a Post resolving or pre-resolving hook or event And I like it the most in the leak Implementation and the leak container has something like this container inflector and then you give it a class name And whenever an entity manager is being resolved Right before injecting it into where it needs to be injected It's going to call this class this anonymous function first and it's passing in the entity manager as the first argument The first and only argument. I can then call some methods on it For example get configuration get the entity listener resolver and registers register some entity listeners And this is being done right before the entity manager is being injected somewhere Of course when I share this entity manager, this is only going to be resolved This is only going to be called once otherwise. I'll be registering the same model listener over and over again Which is not useful In larval it looks like this. You say container resolving and Then you give it in an anonymous function and it's going to use the same reflection API found in PHP Where it's going to look at the first argument of this anonymous function and it's going to see oh well Whenever an entity manager is resolved. I want to call this anonymous function because it takes an entity manager I Use this feature a lot And I use it for different purposes the first one is to inject something that Would otherwise require a connection with the global state or the global container For example an environment if you want to know the environment where you're working like local or staging or production That's just that's such a super simple string That I actually created an interface and a trade which I just add to some classes that need the context of the of the environment and Then I tell the container well whenever something is being resolved with this interface Environment aware interface. I'm going to inject the environment into the into the object. This is just an example But you can use it for more more than one thing you can use it for Injecting a command bus or injecting an event listener just add an interface Event listener aware and a trade event listener aware or event dispatcher aware and whenever something is being resolved with this Either one of these interfaces. I'm going to actually inject the event dispatcher or the command bus That's for me. It's a super super simple way to define dependencies and to inject them with a well, this is actually a different kind of This is a different kind of dependency injection instead of the injecting it through the constructor I'm going to inject it through a method. So it's method injection. I know some people are against this, but I like it so The next Thing I like to use this for is for Injecting soft dependencies Now sometimes a class needs a dependency, but it doesn't always need it for example If you have a miller class Sometimes you want to queue a mail you want to just put it on the background job So to be able to do this you need a dependency on a queue class But it's not always that you need to queue class so You want to new up the mailer, but you don't want it to know about the queue class before it's actually going to use it So it's a soft dependency. You don't want to open up a connection with your with your message bus or something So what I'm going to do here is I'm going to inject a Anonymous function which can be called by the mailer whenever it needs a queue So it's a anonymous queue resolver which I'm going to inject with method injection with a Set queue resolver Method on the mailer. So whenever the mailer needs to queue it already has an anonymous function It can call to resolve the queue class from the container But it doesn't need to have a connection with the container because it has a anonymous function Which it can call to create a queue class so quickly quickly injecting stuff injecting stuff dependencies But I also use it to inject It's basically like the environment variable It's injecting configure it can configurable variables so a Lot of frameworks have something called a config class which it can use to To get some config variables So sometimes the people that Classes depend on the config class of the framework Which is basically injecting your framework in into your custom domain code And I think personally that that is a code smell. So what I like to do differently is I want to inject those config Things into the classes without actually injecting the config class as a whole so Whenever this is just an example whenever this validator is being resolved There's a typo here When the validator is resolved, I want to get something from the config and inject it through a method so this validator I would add a Set allowed file types method on it, which I can use to inject config variables So whenever the validator is being resolved, I'm going to use method injection To let the validator know.  So I get the config class from the container I get the allowed file types and I inject it through method injection so That's how to help the container but now I want to Yeah, where do you put all this when do you put all the aliasing and the contextual binding and the Resolving the callbacks and they and the container events were to put all this There's another container interrupt Project called service provider Which basically says well, you can put it in these service providers and they can tell the container What needs to be resolved and how it needs to be resolved? There's a similar thing called service provider in leak slash container and Laravel also has service providers in symphony You can do the same thing in configuration files or in factories and in zent you can do the same thing with Factories as well and config and all all these kind of things So every project has its own way of telling the container how to resolve something, right? So We just told the container how to resolve something, but when are we going to use it? What and how are we going to use it? Basically, I prefer to use the container only in a limited set of Classes or in a limited set of places in my entire framework or application. I Don't want to inject the container in every single class of my application. I don't want to make it global I just want to use it in a limited set of places for example in the factory or In an event dispatcher or in a router or command bus Basically in places where you need to call other code But you don't know up front what what what the code is going to be for example, I want to call a I want to call a controller an HTTP controller But I don't know yet how to resolve this controller So I'm going to inject the container and I'm going to say well container now give me an instant shaded Photos controller or an instant shaded send invoice listener So it's just in a limited set of places where I'm going to actually use this container so the first The first and simplest way of using this container is to get something from it So as I showed you before the psr 11 container interface has two methods And the first one is has the second one is get and the first one just it's a boolean Can you resolve something with FS? Our file system and second one is well now actually give it to me, please The second way and this is not something that's in the psr interface, but that's Getting an object, but I want to use some arguments there For example, I want to get the file system object But here's an array of arguments. It's like passing in CLI arguments if you do a bad bash command So give me the file system File system object, but here are some arguments I use this to to get a file system object, but Give me the images one. I use this to to quickly define the file system that images But always call the same file system Resolving and give it an argument. So I would redefine the same block For a fast system images fast system that photos fast system that PDFs fast system that files something like that. So Another way to use a container and this is something that only a limited set of containers have is calling functions and Using the container to call an anonymous function To look at to inspect the arguments of the anonymous function and to automatically resolve those so for example In this line, I have an anonymous function with one argument could be multiple So whenever I call this anonymous function I Want the container to automatically? Resolve a mailer object and use it to call this anonymous function So this is what it looks like in leak in the leak container and in the larval container and basically those three things here are all Anonymous functions, so this simple array with two items Is also an anonymous function you can use this like any other closure So the listener object has to be resolved Has to be an actual instance with a method handle so You can basically say well, this is a closure Which is a simple array with two items instance and a method name you have to call on it And then it's going to use a reflection API to find the arguments of the anonymous function And the bottom one is also an anonymous function given that listener is a class name which has a static method handle A lot of people don't know this but all three of these are Anonymous functions So it's going to use a reflection function Which is a class in and it's in native PHP You don't need to install anything for it. You can get the callback whether that's Listener colon colon handle or the simple array form or an actual defined anonymous function And then you can get the parameters loop over those Look at the type hints and resolve those from the container itself And then there's another way to do this in larval It's going to wrap an anonymous function This anonymous function can have multiple arguments. It doesn't matter. It's going to return a anonymous function without any arguments So you can inject this into any other Legacy code base and say well, I still want to use the container, but I still want to use my legacy code base So this is in intermediate form where I can inject Closures without any arguments and I still want to use container to resolve stuff And this is this is what it looks like. It's a public function wrap give it a callback with some arguments And just return an empty anonymous function, which will call the same container So this is the wrap function is a function of the container itself Call itself with this callback which will in then in turn Find all the all the all the arguments and the type hints of the callback and resolve it The next feature I want to talk about is tagging And I want to warn you first Tagging in symphony is not the same as tagging in larval Tagging in symphony is just a way of documenting stuff and in larval. It's actually adding tags To items in the container so you can resolve all those items at the same time For example, I use I I use this file system that images and fast is not PDF. So up and I Can use the container or at least a larval container to get all the fast system tagged items from the container and loop over those So if I have fast images, I want to tag it with file system If I have file system that photos I want to tag it with file system, too And now when I ask the container now give me all the instances that are tagged file system It's going to give me an array of all those resolved instances Then I can loop over all those instance instances Which I hope are the same interface, of course, and then I can do something with them I want to maybe clear them or I want to Copy them to S3 or whatever This with this tagging. It's a super neat feature I can basically get all the same typed in instances from a container in But again, I want to warn you if you Google it and you want to use the same feature in symphony tagging means something completely different in symphony Since I have some time left I want to show you some bonus lights I Want to show you how to resolve circular dependencies so I told you the container can do something recursively until it hits a Constructor with zero arguments and then it can roll back up to the dependency dependency graph and inject stuff But what if There's a mailer class which depends on the queue interface or the queue implementation and the queue implementation depends on a mail Implementation or with some more intermediary steps. So if there's a circular Yeah, a circular thing in your dependency graph, you might have a problem or your container might have a problem For example, the mailer depends on the queue and the queue depends on the mailer Your container will probably fail and say well I Looped over this many many times and I couldn't resolve it Because it's recursively it's going to keep a counter and stop at like 100 or something And the way to stop this from happening is to use something called. Well, I showed you before It's basically making one of those Implementations or one of those dependency that dependencies a soft dependency. So instead of making the Mailer have a hard dependency on the queue. I'm going to make the mailer have a soft dependency on the queue So I'm going to add another method on the mailer class, which is the set queue resolver Which we we can then We can then use to tell the container. Well, whenever the mailer is being resolved So this is a container event again or an inflector We're going to say well whenever the mailer is being resolved right before returning it Here's an anonymous function to tell the mailer whenever you need a queue Hey, you can use this anonymous function. And if you call it, I promise you I will give you a queue interface object so That's basically it. That's a that's a bonus light. I want to quickly recap here So if you use dependent if you use dependency injection and depend dependency inversion and IOC and all of those Design patterns you might want to use a IOC container to compose all those objects because all those objects or all those classes are super small They have one responsibility single responsibility principle And it's super hard to compose all of that and to do that you use the IOC container to To compose them and to call a new service class or to create a new service class and the container will know how to compose that But you want to help the container by using aliasing and container events and soft dependencies and method injection and all those things to be able to compose all of that And if you do that, you have super small usable unit testable classes and Everything depends on high-level abstractions and not on low-level implementations and when you When you draw the beautiful design graph or the Dependency graph you will see that you have a lot of interfaces on top and a lot of low-level implementations on the bottom You can also resolve circle circular dependencies with soft dependencies By making one dependency a soft dependency instead of two hard dependencies which make a circular Loop inside your dependency graph. So, yeah, thank you


Welcome traders, that's 2pm UK, British summertime, almost coming to an end for you guys over there. Here in Southern New Yorker today, it's 27 degrees in the sunshine. Okay, let's, let's get going here. Before we get started, quick audio and visual test. If you can hear me, and you can see my screen, the welcome screen, the technical welcome screen. We'll type a Y into the chat box, so that I know we have all the end visual ready to roll. Good stuff. Before we start presentation, important for today, risk disclaimer. Obviously, we all should be aware of the risks associated with trading CFDs through Ticknell UK or Ticknell Europe Limited. But equally important for today is that any views expressed by me are solely mine, they are not indicative of all representative of those held by Ticknell UK or Ticknell Europe Limited. For those of you who are here for the first time a brief introduction to myself. My name is Patrick Manley and after I graduated from King's College London I joined a city PLC consulting firm. I met some of my colleagues and went on to successfully co-found an exit to consulting startup which was focused on C-suite's executive search for technology businesses. I essentially had a front row seat to the dot com bubble witnessing people make and lose a fortune in the market sometimes quite literally overnight. So I decided to explore my curiosity for markets with some capital to play with and some time on my hands I started day trading the S&P 500, or probably more appropriately day gambling. As a beginner's luck I racked up some pretty solid gains however, as is often the case, my beginner's luck run out and as the market phase changed I began to average down into what were going to be pretty significant losing positions. I gave back all my gains and ultimately took a sizable six figure financial hit. This was a gut wrenching and sobering experience is an understatement at best. I really had to stand back and figure out if it was feasible for me to make a living from the markets. So I decided to get serious about trading and I sought out a mentor with an excellent trading track record, working with my mentor for a period of 18 months to two years. It was a time during which I ups not just my technical game in terms of researching developing extensively back and forward testing strategies that crucially suited my personality, all of which were underpinned by a rigorous risk management risk management approach. Most importantly though during this period of mentorship, I significantly developed my mental game. And probably most importantly there, I made the watershed shift from being a highly goal orientating individual focused really just on financial gains to becoming purely process orientated. So what does that actually mean? Well, it means I had to stop focusing on what I could make from the markets and start focusing solely on managing my mindset to allow me to consistently execute my trading strategies, oftentimes in the face of negative feedback from the markets in the form of losing trades. But once you become process orientated and have a professional trading mindset, and you accept and understand the true nature of trading being a numbers game in which you're simply playing the probabilities, you lose the emotional investment and that hellish emotional rollercoaster of living and dying by the outcomes of individual trades. I'm no longer concerned with the outcome of individual trades or even a small string of trades. My focus is on the next 100 trades, because I know if I focus on excellence in execution, my edge will demonstrate itself over an extended series of outcomes. My multi-strategy approach has delivered profitable annual returns since 2008. In 2013, I've also been managing investor capital through a managed account service delivering again annual positive returns. I'm currently responsible for managing a multimillion dollar portfolio. Since 2010, I've mentored hundreds of private traders of all experience levels from complete novices to former CME floor traders in developing the technical and mental skills to read consistent returns from the markets. In addition to my fund management and mentoring, I'm engaged in other market orientated projects, I guess you call them. I am, as you may know, a resident market expert exclusively providing market and trade analysis to Ticknell, providing an in-depth daily market outlook, breaking down the fundamental and technical drivers for the day ahead. I also provide daily technical trade setups for two, three, well, sorry, probably more like through the five markets now. You can actually track those through trading view here. You can subscribe to the Ticknell ideas account here and you can see I post pretty much daily now setups through this account and you can track the trade development as price action develops. So strongly suggest you use actually I'll post that link for you into the chat here. There's a link there that will give you direct access to that group. And then more recently, I am and also charged with running Ticknell's rapidly expanding even strategy group. Let me change the slides and see perhaps. It's a group, that's a free group where I provide daily specific trade plan for the cash US trading session for the day ahead. Since its inception from April this year, I've delivered over 1200 points of upside and just this week, well it's been starting on Monday, we've actually launched a telegram channel. This is for traders who have a funded Ticknell futures account. What this will give you is access to the channel, which has institutional research posted there on a daily basis, we're covering all the E-mini, sorry, the E-mini and E-micro products right in front market indexes through commodities, forex and crypto contracts. You'll also get access. I run two automated trading models, specifically trading the E-mini S&P 500 and also in the gold futures market. I'm syncing up those algorithms to provide real time trade alerts into that telegram channel. And what you'll also get as well in that telegram channel is live stream sessions during the opening hour of the cash trading session for the E-mini S&P, where I'll be sharing in real time my observations and analysis and sharing my trades, calling my trades in real time as well. So for those that are interested, you need to message me your Ticknell futures account number, and then I'll provide you with a link that means you can access that channel. Like I say, we're launching, the full launch is going to be on Monday. So that's something else you might want to think about taking a look at if you're interested in those products. Let me, I'll post the link for the Facebook channel. You can access the free trade on every day anyway. That's posted as a video before the cash session opens in the US. So that gives you a flavor of where I'm coming from. Let's now take a look at the charts. So we are going to start here with the S&P 500. In the Facebook group, you know, been pretty bullish on the S&P, certainly after we got this pullback, and once we held that support area at 4319, we were looking for the break of this internal descending trend line resistance to set up the extension higher. And we've seen that play out. We're now coming into a pivotal test here of the prior all-time highs. What I would bring to your attention, and what I certainly pay attention to is we have got a bit of divergence here in play, a little bit of a stretch in terms of the short-term momentum. We've had a big rise over the past week. So what I think we're potentially heading into is probably some profit taking. Maybe we just take out the prior all-time highs, but certainly only watching for this momentum divergence to be addressed. So if we're not raising that all I'm suggesting is that we can see a tradeable correction here. Certainly to my mind what I'd be focused on would be the equality objective. Let me just blow this up a bit and you can see exactly what I'm talking about. And I talk about the equality objective. We've got this swing here is prior correction. So if we overlay that swing there. So what we could see to my mind anyway is as we get up into these highs that we get a pullback equal to the last correction. That would take us back into this 44.31 area. And you can see we've got a lot of volume traded through that zone. And so that would be a natural area for prices to pull back after making new high. And then we watch there. What are the horizontal bars? They're volume. They're volume bars, volume profile. So what we're looking at then is this pullback into the support zone. And then we'll be looking for bullish reversal patterns. And certainly we could think about if we're just working on simple wave theory here, we would have five equals one. So depending upon where we find our high, maybe we just take out for our highs. Then what I'm looking at is this sort of scenario where eventually we actually into into the back end of, sorry, and guys, if you've got questions, can you just make a note of them. And at the end of the presentation, I'll open up a Q&A and I can walk through that stuff with you. You can put them into the chat, but I just won't answer them during the session. I'll answer them at the end. So feel free to type any questions you have or pay an instrument you'd like me to take a look at. I may not cover in my deck here and I'll jump into that at the end. So that's what I'm looking at a pullback from wherever we potentially find a top here. And then we're going to be looking to re-engage on the long side to join in with what I anticipate is going to be a run higher into the year end that seasonality is very favorable into the Christmas and a new year. So we'll see how we'll see how this plays out but certainly I'm looking for an interim peak to be put in in the coming sessions. So that was a trade setup. We were tracking, we got the move into the support zone here, but this bullish outside reversal candle, which was the trigger on the long side through that 14,780. And we've taken out the descending trend line resistance. So we have, we've traded it up into the, this prior highs here and we're seeing a bit of resistance come in now. So what I'd be a similar story really to the S&P, we overlay this corrective leg here. So what we're looking at now will be a pullback potentially from current levels in the NASDAQ. And we get a retest of the broken descending trend line resistance to active support. We've got a monthly pivot there, 15,000 is the level there. So any pullbacks into that zone, we're going to want to watch for bullish reversal patterns to re-engage on the long side. So NASDAQ, its pattern currently would suggest a, if we're looking at just a simple wave theory here of the fifth wave even the first wave, we'd actually have a retest. So this brings us into the price cycle highs here up into 15,734, but trade as posted in the, in the trade view ideas is running 500 points plus in profit. So it's, it's working nicely there. So we're going to remove that, avoid confusion. The DAO, DAO has an interesting pattern here in terms of an expanding, expanding megaphone type top scenario could be developing here for the DAO. So what we'll be watching, what I'm going to certainly be paying attention to with the DAO is, is do we get this scenario where we trade up into the ascending, projected ascending trend line resistance and then get very steep pullback into the projected descending trend line support to complete then what would actually be a bullish consolidation pattern to take us up into, up into new highs there in the DAO. The DAO has been a bit weaker than, well, Russell has been the weakest but the DAO has lagged the S&P and, and so, and the NASDAQ in the run up and has put in more of a consolidation pattern which suggests to me that coming out of coming out of this consolidation, we could see the DAO actually take the lead here. We'll just have a look at the Russell, I think we've got the Russell here, because that, yeah, take a look at the Russell as well, because that's a nice consolidation pattern. And this one suggests that we should see a fifth wave extension. So again, working on the premise that any fifth wave objective at a minimum is going to be equal to the first wave. And that gives us, we can use this consolidation base to give us a target on the other side there of 27,000 in the Russell. So a couple of ways you play, couple of the ways to potentially play this, why are they going to retest this descending trend line resistance again, and then get a pull back into the base once more, watch for bullish reversal patterns engage on the long side. Or we're actually, we take it out, we take out these highs, and then we recheck the broken sending trend line resistances support, and then that acts as the base to catapult things higher up into the, up into the target zone. And then from the volume distribution, this is the highest traded volume area over the past 18 months so this is, this is, this is to my mind at this stage in ways and accumulation pattern, and, and then we look for an extension to the upside and we iterate them up into the, up into the target zone. Alternatively, obviously, and there is always, there's always an alternative is that we actually fail to break to the upside. And then what we'd be looking for be a breach of the trend line support here. But this, we get back in here and we take this out. And then what we'd be watching for is the first pullback to test that prior support zone as resistance, and that could set up a move then down. We'd be rechecking the yearly pivot of these, these prize over here. So two scenarios, my preferred scenario at this stage given the seasonality and how we're set up at the moment is that is that we run this up into the fifth wave objective here at the 27,000 level. And I would say there are a couple of areas to just monitor for your potential entry points there. Do know that we do have this active momentum divergence at the moment so it's, it's not crystal clear, which way we're going to go but like I say because of the seasonal aspects and, and the current market positioning. What we see is a break through this descending trend line resistance, and the momentum study here to, to break out as well and then that would be the green light for, for long positions and taking, taking this higher to its fifth wave objective. The one in here is the DAX. They're looking for bullish reversal patterns from the test here of the 14,700 got those and the trade triggered at 15,280 and has run up 300 points or so here, but pay attention now because we are sitting right at this, this descending trend line resistance potential scenario they're developing so I mean I still, I'm still interested in this to, to extend higher, and if you're not in the trade, certainly what you can be thinking about is any closing breach of this descending trend line resistance is an opportunity to add to long positions. And, and ultimately what we're looking for is a recheck of this broken descending trend line resistance here you can see it. One to third touch, fourth touch rolled over. If we get through there then I'd look for us to recheck that from below and potentially extend up into the ascending trend line resistance up into the 17,300 area so there's still room to run in this one to my mind and certainly in a long position, then there's an opportunity to add on a closing breach of the descending trend line resistance. DXY, I'll tell you step on the futures chart. So the DXY has, has Julie pulled back from the yearly pivot double top scenario, have some momentum divergence there let's just draw this in a few, see what I'm talking about. Now we're testing some pivotal support, and this is really going to see now if the dollar can can pick things up here, we've obviously still got that background market dynamic of taper talk coming out of the Fed, we've got the important platform scene eating November 3rd. And, and you know if they come through and give us solid indication of when tapering is going to commence and potentially talk about rate moves, then I think there's another high to come in the dollar index, and that will kind of be the by the rumor sell the facts scenarios so pay close attention to newswires at the moment, and how the Fed are setting up into this, into this ever seen eating, because I think that could, that could be the catalyst to drive us into this one more, one more high in terms of the, in terms of the dollar index, and then we'll see if the bears can go back in and take things lower. Certainly, I think we can think about a minimum correction equal to this leg here from wherever we eventually find our, our peak here but we've been trading pretty nicely within this pitchfork channel for now so while support remains 90 to 80, you can see that's the highest volume price as well for this past 18 months, then whilst we've maintained support there, then we can still expect or I'm expecting the potential for one more high in the dollar index. Gold. The pitchfork trade that I highlighted again I posted that on the trading via account, started to work well, broke the internal descending trend line resistance after holding this pivotal test off the pitchfork, and then we've, we've run into some resistance at 1780, trying to see them get through that, if we do get through that the area of huge interest to me and could be significant, especially if we think the dollars and make one more high is, is a test here this third test, and I always pay very close attention to the third test of this 10 in trend line at 1836 now, that could actually set up the move for the big corrective target down at 1520 so we'll see how gold trades into that zone. Silver interestingly has led the charge through its internal trend line resistance so what I'll be looking for now with silver is probably runs into some resistance here in the midpoint. So, maybe a 475, maybe a deep inverse head and shoulder scenario to set up an equality objective and when I talk about a quality objective what I mean is, wherever we get our swing high here will be looking for an equal leg, so that will put us up in 2560 and then this descending trend line resistance may cap things for silver but if we get through there, then we start to think about range resistance up to 30 again in terms of silver. So crude oil, this is an important one at the moment, and it's important. Certainly because of its implications, if you I don't know how many of you were trading 2007 2000 2006 2007, and it was the surge and crude prices that ultimately was the initial catalyst to take the markets down heading into 2009. Now we're seeing quite a surge here and crude at the moment, obviously, we have seen, you know, pretty much a run across in all of these energy based energy related commodities but crude is the one I'm paying really close attention to and I'll show you some targets now we have in play. So again, thinking in terms of simple wave analysis and the idea that fifth wave should equal the first waves this is our first wave, this is our one to this was our third wave, we have a perfect equality objective test complete way forward to 6255. So what we do is we measure from 6255. And that gives us a target there of 9445 and it coincides with this assembly trend line resistance and that will be the third test. So I'm going to pay really close attention. So what I've been looking for is a pullback and then the wave equal to our first wave. So I don't anticipate we get some sort of pullback in the current in the current area. Just put in a little channel here as well. So if you think about a pullback into the 8182 level, and then that sets up the extension to the upside to challenge this, this 9445 area. So that if we get up into those prices, that's going to put a bit of a lean on on the equity markets. And so this could be the catalyst for a pullback in terms of the equity markets but for now, we're looking to engage on the long side. Again, what we do want to be cognizant of is we have momentum divergence and play here so what I don't anticipate happens here is we get the pullback, we find support. And so that allows the momentum study here, psych indicator to roll over a bit maybe test the midpoint. And then as price extends up into that fifth wave target, what we'd actually look for would be another attempt into the second trend line resistance in terms of psych indicator. And then triple divergence and triple divergence oftentimes will lead certainly to a pause correction and even reversal so as that if this plays out as I anticipate, then what we'd look for would be a nice three wave move then down into test support back into the prior next year at 76 handle. So crud is one that's on the radar. There's an opportunity I think potentially building on the long side, looking for this fifth wave objective and then we will pay attention to the momentum dynamics and see if we get an opportunity to put a fade in there and trade this back down into the third wave high here and that ascending trend line support. So the coin obviously in the news making news, we have been talking for a while now about this 75 handle in terms of Bitcoin so what I'd be looking for here, we've just taken obviously take out stocks above the market. Nice setup, get into this pitchfork resistance and pullback like something like this would be ideal, and then sets up the extension into that 75 target. We couldn't even extend higher here because if we're going to suggest that we're in the third wave at the moment, then we'd actually get a five equals water sorry five equals one that would take us up into projected ascending trend line resistance. We can start thinking about 80,000 there in terms of in terms of Bitcoin, looking at this pattern and setup. Most of the high volume know there is the 57,250 so any pullbacks into that 57,250 zone will certainly draw attention and will be an opportunity to reload on the long side, and then we look for the test of the ascending trend line resistance up to 80,000 heading into the back end of this year even. Let's just take a look at some of these majors now wrap it up, Euro dollar, looking for the Euro dollar to looking for another low basically the Euro dollar, and then I think we can see a more meaningful correction so watch for any test of the descending trend line resistance weekly range resistance. So this is 11685. This is where I've been looking for reversal patterns that short positions couple actually just want to highlight a couple of scenarios I'm watching here, the Euro Kiwi, I'm going to just pull up a weekly chart here as I posted this in the trading view. We are following. We are testing here a really big weekly trend line support, and it's got a couple of structures there at this 162 handle. So what I'm going to be watching now on the daily is, is for reversal key day reversal. And then they close back through a prior days high essentially so we've made the new low, and then we get that close through the prior days high, and that would give us an opportunity on the long side to play for at least a bounce back into the 165 handle. Similar story here in the sterling Aussie. We're testing now I'd highlighted this again through that through the trading view accounts. We're testing an equality objective here and we've got this ascending trend line support. So you see if we can get a bullish reversal pattern from this area set long positions and certainly think about a retest of descending trend line resistance 18665. Another one that's also of interest to me is the dollar South African Rand getting a nice reversal here today. And if we can close back through yesterday's highs, I think there's a long set up here. And then we want to be thinking about a retest of this neckline, if we can get through there on a closing basis, then the quality objective at 1607. And the, the actual inverse head and shoulders scenario here has a technical target up at 1758. Well, certainly the Euro key with the sterling Aussie and, and this South African Rand are ones that I'm going to be watching on a closing basis. Also, just over a run out of time here, all these ends are sitting right at some pivotal resistance this is the Kiwi and looking getting a reversal here. Certainly for me anyway, because we've been in this bullish extension what I'd be thinking about now is Kiwi yen, and I'll be looking at this tomorrow morning certainly if we get a bearish close here, looking for an Asian range break scenario but I've been looking for this type of pattern to play out with Kiwi yen so there's certainly a tradeable corrective move here from below 81 sixties back down into the 7990 area. And we've got similar stories in the Aussie and the Aussie and hasn't does he has potentially a double top here, but no, no divergence site. I pass on the Aussie and I prefer the Kiwi and Swiss yen. It's got a bit more work to do to check its trend line there so we pass on that one the cad yen. And then it's sitting right at its trend line here so their attention to some of these yen's I'll be updating these. I'll be updating these in the trading view account over the coming sessions but I see a bunch of opportunities developing in those in those pairs specifically. That's, that's me for now those are the markets I'm tracking the opportunities I see the in terms of the main trade that I've got running at the moment is short short the dollar, and I've rolled down stocks on that to just above three day high 9395. But I've got a bunch of these indexes running as well. And I'm watching those, those four experts that I've talked about just then as as opportunities in coming sessions. So without said. So, let me open this up for questions. Let me first of all take a sip of water guys. So bearish the green candles are bullish. Yeah, these candles are a little bit different to normal candles I use a five periods and volume weighted average price. And so prices trading above the five period volume was average price that we color color green, and if it's below that we colored red is the is the deal there. Then I'm sure he says more, but I use fiddle trace and put extensions and never use the pitch walk. To I know, yeah, I mean, again, then 15 years of staying at these charts I could, I don't I wouldn't actually need to put the pitch walk on I just do it really so that people can see, but again, if you think about I use this knowledge before, if you think about a plumber or an electrician.  Because it's the same being a trader. I, you know, I have probably 10 or 11 tools that I use depending upon the market condition and depending upon almost to a high degree now for me for because I've been doing this for a long time. So that's subconscious pattern recognition I can see what what tool will be most effective for the current market setup so that's kind of that's kind of how I apply or use the pitch fork. So does it, is it kind of measure of sport music.  It to me, it's simply, it's giving you a good reference points of it's giving you a good reference point of dispersion within a trend and when I talk about dispersion. What I'm saying here here is that this midline for just to look at this midline here price rotates pretty nicely into it away from it into it away from it into it breaks it and back to it. Then back to it. So that would be the midpoint or easily is is is the reference point the median point and price hasn't really dispersed, meaningfully, or certainly we think about this thing 100% and that being 100% price hasn't really moved 100% out of that range. So what would be significant here will be a close above the midpoint of the bigger channel, because then what you can think about and statistically, and there's a high probability that you will then go up and test the upper parallel certainly you think about this parallel first as a first target and then this is your second target. So the way it's traded people trade differently the first pullback to the lower parallel is a long position that targets the midpoint. And then you take profits there and you wait to see, do we retest the lower parallel yes we do, and then we break out to the side and off we go. Yeah, I'm. I trade predominantly predominantly Cornelia the daily chart. So this is daily time frame stuff here. The, it works on it works on. It works like anything else. If it's, if it works on one chart, and it's, it's consistent, then because of the fractal nature of markets, it must work on all timeframes. Okay, the difference is, you get this on a minute chart or a five minute chart you're going to make a lot of decisions and understand the price movement of the instrument your trading in super quick time. Okay, I don't like being rushed in decision making I prefer to take my time, understand the context and parameters, and then I, then I, you know, that's how trade basically so for me I'm looking at the daily and the hourly time frame, and I'm looking at these, these instruments, obviously I traded the futures on a lower timeframe but that's using different tools, and a different process that allows me to, to effectively make decisions there and make decisions quicker. How do you trade multiple time frames. So the multiple time frames approach, I treat in the futures in the many futures group, telegram group, I mean, I'll be trading predominantly hourly and five minute charts. So I use the dual time frame aspect of the hourly and the five minute charts. And I say the majority of my, let's say CFD trading is done on the daily timeframe. The reason why with the futures I'm able to use a lot of time frames is some specific market internals that I use that allows, allow me to make solid hyper ability decisions on those low time frames. Do you have a link to an online resource where I can learn the basics of trading. Henry, I will. If you, if you drop me an email Henry I'll put my email in here. If you want to drop me an email, and I'll point you in the right direction. Are you going to trade based on. I trade on technicals and I am well versed in the fundamentals. To my mind, everything that's known in the market is in the price, the current price. And so, if you understand the fundamentals, you can then understand what the catalyst may be for the technical pattern to play out. That's how, that's how I think about things in terms of fundamentals. So I, you know, I have an abundance of knowledge with respect to the fundamentals but my prime driver for executing the trade is always a technical pattern. So yeah, Henry, can you see my email address there, patrick.money at techno partners.com, you drop me an email, and I'll, I'll point you in the right direction. We've, we've run. How did you become world versed in fundamentals. Yeah, there, if you again drop me an email and I'll point you in the right direction for some resources community. Okay, so I am going to wrap this session up here. Thanks very much for your time everyone. I hope you've, I hope this has helped, and we will will reconvene at the same time next week and like I say, feel free to join any of those groups that I've highlighted there. And, and certainly if you've got a future's account, be sure to, be sure to join me in the telegram channel where you will get real time access to me and my trading. Okay guys, thanks very much everyone and I'll catch you sometime next week.