Monthly Archives: January 2014


Multicharts Tutorial – Lesson 04: If statements and conditional branching

Multicharts Tutorial - Lesson 04: If statements and conditional branching Learn how to execute code expressions based on conditions In today's lesson you will learn how to control your program flow and make it execute parts only when certain conditions are met. This is where if statements are used. You can find them in basically every high level programming language and they are the engine that drives each program. If statements can for example be used in coloring a moving average differently based on its relation to the close of a bar. If you want to close all open positions after a certain time, an if statement will come into play. In case you want to trigger an alert when a predefined condition is met, you will also use an if statement for that. This list could go on for quite some time, but I think you already understand that if statements are not only very useful, but also very important. No programming tutorial could be complete without going over them and a good understanding is essential before we can move to more complex things. if...then... The "if...then..." statement is the simplest form of a conditional statement. The condition is tested and if it's true the following code statement will be executed. If the test is false nothing will be done as the following code statement will not be executed. When I say the test is true, don't get confused and think you are limited to testing conditions that include "true" only. In case "ii" is a numeric variable and "MyCondition1" and "MyCondition2" are boolean variables these are three valid "if...then..." statements. In case of the first statement the code checks for [...]

Multicharts PowerLanguage Tutorial – Lesson 03: The while loop

EasyLanguage & PowerLanguage Tutorial - Lesson 03: The while loop Learn how to properly use the while loop in your programming Welcome back for the next lesson in our way to become fluent in Multicharts, Easylanguage and PowerLanguage. If you haven't read the previous lessons yet, I would suggest to start here. A new lesson will build up on the previous lessons and starting at the beginning will ensure you have a solid foundation. Lesson 02 showed how you can easily calculate a simple moving average and plot it on the chart. We used a "for loop" to sum the values over the previous bars that should compose the average. Today you will learn another type of loop and how to use the editor to print information to the output bar. In the first lesson we took a look at the main window within the PowerLanguage editor. When you open the editor it will probably show three different parts. If it looks very different on your end chances are that you changed the appearance under "View". Make sure that the "Output Bar" is checked as we will use this during the current lesson. Switch to the "Output" tab in the bottom window. This is where the PL editor will display information coming from print statements within your code. We will take a look at how this works now. Create a new indicator with a name of your choice. Again I am using a name that is easy for me to find within the editor and that displays the purpose of the indicator. We want the print statement only to appear one time in this demonstration. Easylanguage offers a convenient reserved word for [...]