 Meanwhile, we can look at the code a little bit. The API that is recommended to be used for beginners is the simplified API. There's also the core API, which is more capable, but also more complex. And you can do many, many things with the simplified API. That's why we recommend it to be used first. So after opening some file, you can see that the JTK module is not defined. So let's click here to set it up. And you can simply select the version that gets recommended. We don't need this. We don't need this. For some reason, Gradle is still importing this project. So I am not sure why this is, but I'm just going to cancel it and restart the IDE. OK, I've restarted the program, and it took a while before all the importing and indexes were calculated. Now it is done here. You can avoid downloading pre-built shared indexes like this. All right, so let's compile this code into a JAR file. A JAR file is essentially packed, compiled Java code, which is then imported into Bookmap. How to compile this code? This is done using Gradle, and you can either open build.gradle here and find the JAR task and run it here like this or open the Gradle tab and under Tasks, build, double-click the JAR task. Let's do this, and the code is being compiled now. The resulting file is written under build lips. So this is the JAR file that is the output of this compilation, which can be imported into Bookmap. Let's try out one of these indicators, and one very simple indicator is this last-trade-demon-ohistory, which just updates the integrator's value whenever a trade happens. This code basically has a callback onTrade, and the indicator, which is specified in this field, is updated with the trade's price. So let's test it. I'm going to connect to one of the connectivities, one of the exchanges. So let's say the Kraken futures exchange to their Ethereum perpetual instrument, and I'm going to add the indicator by clicking this button or going under Settings and Configure Edits, here I'm going to click Add and select the JAR that was built by us previously. And there are several indicators that are present in this JAR file. The one that I'm interested in now is the one whose name is specified here. So last-trade-live, let's see where this indicator is located. Last-trade-live, right? Okay, the indicator is now loaded, and I'm going to enable it. And once I enable it, it gets displayed here. And as we observe the next trade happening in the market, the indicator should get updated. All right, so a trade happened here at this price, and from now on the indicator's value is going to be this last-trade. And let's wait for another trade to happen. Okay, another trade happened, and the indicator was updated. Of course, this is extremely simple and trivial indicator. You can write any custom logic you want here. Now let's write our own indicator, and for example, we can write an exponential moving average indicator, which is pretty simple to calculate, so let's do that. Let's create a new Java class here called maybe EMA. The first thing that we have to do is add a few annotations. Let's say that I open one of the other indicators and I simply copy the annotations that are required here. The first one is layer 1 simple attachable, second one is the name, so I'm going to rename this to simply EMA, and the third one is the version. This is used for compatibility reasons. The best thing is that you simply use the latest one that is currently available. In my case, at this moment, it is 2. We have to implement the first interface, which is called custom module, that is going to give us two methods that are called. One is the initialize and another is the stop method. The initialize method gets called whenever the indicator is loaded and the stop method gets called when it is unloaded. What do we want to do here? We essentially want to set up our indicator line inside of the initialize method, and we can basically ignore the stop method. How do we initialize the indicator? We have to first define it as a field, so we're going to make a new private field that is of type indicator, and let's call it the EMA indicator. Inside the initialize method, let's construct this indicator by doing api.register indicator. Let's call it EMA1 or just EMA, and the second parameter is going to be the place where the indicator is displayed. Graph type has two values, essentially primary and bottom, and let's say that we want to display this indicator in the primary chart, which is what makes sense for an explanation moving average. Let's also display the color for this indicator, and let's set it to, let's say, green, and be careful here that you import the color type from java.awt, not from any of the other packages. Right, so now the setup is done. Now we have to calculate the indicator value and display it. What we're going to do is implement two interfaces. One interface is going to give us the ability to observe all the traits that are happening in the market, and the second one is going to be called intervals. Let's implement the first one, which is called the trade data listener, which has one method on trade, and this on-trade method is called whenever a trace happens in the market. The first argument is the price, and the second argument is the size. So what we're actually going to do here is track the last price in a new field that we don't yet have. Let's create this private double last price. It's going to have a value of not a number at the beginning. Then let's implement the second or the third listener, which is the interval listener. This interval listener is going to have two methods. In the first one, the get-interval method, we specify the frequency of our interval. We do this by doing intervals. Specifying the value, let's say, that we want our interval to be one second. This second method is called whenever the interval expires or takes place. This is going to be called one time per second, because this is what we defined here. What do we want to do here? We want to essentially do two things. We want to update our EMA value, and we want to draw the indicator on the screen. So how do we update the EMA value? We're going to have another field here called private double EMA value, which is going to be not a number at the beginning. Essentially, what we're going to do is update this value every time an interval happens. The first time that this interval value gets called, the value of EMA value is going to be not a number. When that happens, let's simply set the EMA value to the last price. The subsequent calls should simply update the EMA value according to the EMA formula, which is basically the previous EMA value times the alpha parameter plus the new price, the last traded price, times 1 minus alpha. And we're going to define the alpha field shortly. One thing that we also have to check is that at the beginning we don't necessarily have any trade price yet because maybe it takes a while before the first trade occurs. So let's add another check if the last price is not a number, meaning that no trades happened yet. Let's simply skip this calculation. From the first trade onwards, we'll be calculating the EMA values. Now that we have calculated the EMA value, let's simply draw it on the screen using the EMA indicator field. This is done by calling the add point method and inputting as the first parameter the value itself. Okay, so now this should work. We only have to specify the alpha value. For the beginning, for the start, let's simply hard-code it here at the top and let's say that the alpha value should be, let's say 0.99 maybe. Okay, let's build our jar file here. Let's connect to one of the instruments and let's load our indicator. Okay, here's our EMA indicator. So the EMA indicator is going to be calculated whenever the first trade happens. So this is here. And now the EMA indicator gets recalculated every second. Now if I unload the indicator and add it again, I'm going to see that the value is only going to be calculated from the time I loaded the indicator onward. So I loaded it somewhere here, right? Now I need to wait for the first trade to happen until the first trade happens, the indicator's value is not a number. And after a while, once we see the first trade, the indicator is going to be calculated. Okay, now the trade happened and now the indicator is calculated every second. How to calculate the value also for historical data? Let's for sure with how to calculate it for the part from whenever we connected to this instrument onward. This is done simply by implementing the historical data listener like this. Nothing else is needed. We can rebuild the jar, unload the old jar or unload the old indicator instance, add it again. And now the value is calculated from the time we connected to this instrument onward. How to calculate also the indicator for this part? The backfill part, we call it. To do that, simply implement another interface which is the backfill data listener. Like this. Let's rebuild the jar, unload it, load the indicator again and now the indicator is calculated for the entire period including the backfill data. Of course, if I subscribed with more historical data I would be able to see even longer periods of data. Okay, now let's see how we can change this setting, this alpha value to not be hard coded but to instead be something that the user of the program or of the indicator can change. To do that, we are going to add a notation to this field called parameter annotation and this annotation requires a few arguments which are the name. We can call it simply alpha and we need to specify the step which is let's say 0.001 What's the minimum value? It's probably zero. The maximum is one and reload on change should probably be true which is also the default so I don't even need to set it up. The value that is specified here is the default value. So I'm going to rebuild this jar file, unload it here, wait for it to finish building, okay, edit. So we get an error here, why? Because all the parameters have to be objects so primitive values like double don't work do not work and what's the fix for this? Simply change your primitive value into an object, a wrapped object. So I'm going to again build this jar file load it again. Okay, now the alpha parameter here is in the settings. Let's say that I set it to 999 maybe there's a slide back where after I type the value here the apply button doesn't yet change so I need to click something here. Okay, and after I change this value and click apply the indicator gets recalculated here. Let's say that I change the value to a smaller value, hit apply, and now the indicator is recalculated again. Let's say that I want to have two EMA indicators one would be green, one would be blue and as a trader I would be observing the relationship between the two, maybe one would be like a long term EMA indicator one short term EMA indicator, what do I need to do? I need to simply make another indicator field, make another EMA value field, add another alpha parameter register the second indicator as well specify its color and then whenever the interval is calculated or is called calculate also the second interval. This is it, thank you for watching if something is unclear please ask a question in the comments Thank you.