Articles & Videos & Calculators                 Product guide             Trading IQ Game with great prizes                  Support HomeSite Map - Testimonials


Beginners guide to Easy Language code. How to make indicators, functions, signals and strategies in MultiCharts power language editor


Programming is a subject which can put fear into those who are trying to learn it. Some aspects of it can be complex.

Here is this guide I will make some simple to understand examples so you can learn what each part does.

More code examples can be found  in the << MEMBER FORUM >>


Beginners example no1 ( Price up and down counter demonstration only)



vars: move(0),summove(0);

If close > close [1] then move = 1;

if close < close [1] then move=-1;

if close = close [1] then move=0;

summove= summation(move,length);



Copy and paste the code above into your development environment in Tradestation or MultiCharts as Indicator. Then click on compile, or verify.

This code detects if the closing price today is greater than or less that the closing price of yesterday. ( This can be put on daily charts or minute charts and the close[1] refers to the previous bar or previous day)

If you typed close[2] it would refer to the close 2 days or bars ago instead.

Then we have the summation of the last ( length 20 ) bars.

To see how it works, you can change this line of code plot1(summove,"up-downcount"); to this plot1(move,"up-downcount");  Then click compile.

You can then see your indicator plots a line which is either 1, -1 or 0 

The inputs written at the top represent values that can be changed by the user when plotting the indicator on the chart. Once you plot the indicator in its original form you can change the length to 50 or 20 or 100 to see how it affects the plot.

Variables are shown here as "vars" and these are values I created to store the values outputted by the 3 lines of code starting if close ...and the summove variable.

Summove= summation( move,length); This means the variable summove is created from adding up the sum of the last 20 bars ( or length period ) bars with all the 1 and -1 and 0 values.

You can experiment by playing around with different values.


Beginners example no2 ( Adjustable weighting percent blended moving average)



variables: slow(0),fast(0),blended(0);

slow= average(close,length1);
fast= average(close,length2);


if value1<0 then value1=0;
if value1>1 then value1=1;

value2= 1-factor;

blended= (slow*value1)+(fast*value2);



You can read the above code first before creating this indicator and see if you can see what it is doing.

There are two moving averages used with slow length of 50 and a fast length of 20, the input called factor is adjustable to assign a weighting to each one.

If factor is set to 0.5 it will add 50% of the slow average to 50% of the fast average and create a blended average of the two period.

To see maximum values of the slow average set factor to 1, to see the plot constructed entirely of the faster average you can set factor to 0.

You can experiment with values like 0.1 and 0.9 to see the affects of adjustments to the weighting.

Code tips

  • If you use the name value1 or value2 or value 99 as variables, then you do not need to declare the names of these at the top part.

  • Value2= 1-factor is a very neat way to get 2 variables to automatically assign 1% of one part and 99% of the other part so when added they will always = 100%

  • Limit the user error by restricting inputs by making the variables read them. ( The code for value1 does this after reading the factor input )

Code tricks to try

  • If you look at the slow and fast variables you will see they both use averages (average is this code means simple average).

  • You can try making the slow one into a weighted average or an exponential average and mixing these up to make your own blended average combination.


Beginners example no3 ( Simple binary trend indicator )

{This example is for making a plot that goes into sub graph 2 and does not overlay over the price as the 2 above examples do.}

inputs: slow_length(80),fast_length(12);

variables: binary_trend(0);

if average(close,fast_length) > average(close,slow_length)

then begin binary_trend=1; end else binary_trend =-1;

{commenting code is done by using these squiggly brackets around text}




This indictor decides the "binary trend"  which means it converts it to a number. Thus uptrend =1 downtrend =-1 and the initial value is assigned as 0.

Code tips

  • If you plot the 80 period moving average and the 12 period moving average on the chart you can check the trend indicator is working.

  • Using end else statements to reduce code length. EG above assumes that if the trend is not 1 then it must be -1.

Code tricks to try

  • If you try using another method to assign the trend is up or down and replace the code with your idea. EG. You use the stochastic oscillator with above 50 being uptrend and below 50 being down trend.

  • The equal to 50 can be caught by saying this. If stochastic is >=50 then count as uptrend ( psuedo code)



Beginners example no4 ( Simple length adjusting algorithm )



variables: used_length(0),monitor(0);

if close = highest(close,basic_length) or
close = lowest(close,basic_length)


then begin monitor= monitor[1]-1; end else monitor=monitor[1]+0.5;

if monitor < min_length then monitor = min_length;
if monitor > max_length then monitor = max_length;


This is the first stage of making an algorithm to control length applied to an indicator.

You can see that if you plot this indicator in subgraph 2 it ranges between 50 and 10 which are the max and min lengths allowed. ( But these are adjustable inputs )

If the price is making a new high or low for the basic length period it will slow down by 1 length increment for each bar that the condition is true.

If the price not making a new high or low for the same period it will reduce length by 0.5 length increment for each bar the condition is true.

Code tricks to try

  • If you try changing the values of the -1 and the 0.5 to larger or smaller amounts you can tune it to suit your requirements.

  • Below I will show you how to build this code into a length changing indicator.


Beginners example no5 ( Simple length adjusting weighted moving average )



variables: used_length(0),monitor(0),l_changer(0);

if close = highest(close,basic_length) or
close = lowest(close,basic_length)

then begin monitor= monitor[1]-1; end else monitor=monitor[1]+0.5;

if monitor < min_length then monitor = min_length;
if monitor > max_length then monitor = max_length;





You can see that another variable has been added which is a weighted moving average and the trick here is to replace the usual field of length with the algorithm monitor which is adjusting the length applied.

Code tricks to try

  • If you plot a 20 period weighted average next to it on the subgraph one. You can see how the code above length changing average is slower at some period and faster in other periods.

  • The above indicator is place in subgraph no1 overlayed with the price. Example code no4 is placed in sub 2.

  • You can observe the length changing algorithm in action and see how it affects the speed of the weighted average.


Beginners example no6 ( How to prevent division by zero errors )


Division by zero is a frequent problem experienced in programming. The answer is always infinity, so we have to prevent anything getting divided by zero in the first place.

There are two methods of doing this.

Method 1

If value1 = 0 then value1=value1+0.0000000001;

So we simply add a tiny number to it, which is so tiny it will not make too much difference to the outputs.

Method 2

If value1 <> 0 then value2 = value3 / value1

This forces the computer to ask if the value1 is 0 or not before doing its calculations. If it is 0 it will return the default value that was assigned to value1 in the variables when you created it.



Beginners example no7 ( How to use Fisher Transform )
Beginners example no8 ( How to use Hilbert Transform )
Beginners example no8 ( Understanding Goertzel algorithm )


More examples of using Easy Language code to create functions, indicators and signals that call from other functions


More code example can be found  in the member forum



Precision Trading Systems is provider of the following



  Precision Trading Systems is partnered with NinjaTrader & MultiCharts.


  Systems and Indicators for Tradestation, NinjaTrader and MultiCharts.


  Top quality paid & FREE trading systems and indicators for most platforms


  Members can receive some paid products completely FREE


  Members can receive FREE trading and betting capital on sign up


  UK Spread betting guide showing how I made a 25,543% return in 12 years


  Elite traders forum for sharing tips on how to use these products for best effect.


  Free to play Trading IQ Game with generous prizes from our sponsors.





Precision Trading Systems is partnered with

  • Products are provided for both these platforms.
  • These partners also sponsor the Trading IQ Game
  • Both these trading platforms are excellent