EasyLanguage for Loop – MultiCharts and TradeStation

Today you will discover how to use the EasyLanguage Loop for TradeStation and MultiCharts.

A loop is a code instruction that repeats a sequence until a specific condition is met.

It’s a fundamental programming idea that is commonly used in writing programs.

Suppose we have to create an indicator called ShowMe that highlights 5 consecutive lower lows.

Vars:
   Signal (false);

Signal = Low<Low[1] and Low[1]<Low[2] and Low[2]<Low[3] and Low[3]<Low[4] and Low[4]<Low[5];

If Signal = True then

Plot1(Low-Low*0.01);

This can be a very stressful code to create:  Imagine using more candles than five.

We can write this code using a loop in EasyLanguage for TradeStation and MultiCharts. With a MultiCharts for loop, you can repeat certain designated actions infinite times.

The most common loop is the for-to loop. With this loop, you can execute code repeatedly until the loop count reaches a certain value.

The program increases the loop by one at the end of each cycle.

We set the starting and the ending value of the loop, and then it is complete.

Variables:
   count(0);

for counter = 0 to 5 begin

Print(“Value of ‘count’: “, count);

end;

//> Value of ‘count’: 0.00
//> Value of ‘count’: 1.00
//> Value of ‘count’: 2.00
//> Value of ‘count’: 3.00
//> Value of ‘count’: 4.00
//> Value of ‘count’: 5.00

Now we can modify our Show Me Lower Lows indicator with this MultiCharts for loop instruction.

RELATED ARTICLES:

Multicharts for loop Tradestation EasyLanguage code

Inputs:
   LookBack(5);

Vars:
   x(0),
   Signal (false);

Signal = True;

For x=0 to LookBack-1
Begin

Signal = Signal=True and Low[x] < Low[x+1];

End;

If Signal = True then

Plot1(Low-Low*0.01);

This is the TradeStation or MultiCharts charts with our Show Me indicator.

Loop-EasyLanguage-PowerLanguage-for-TradeStation-MultiCharts

You can also use the loop in EasyLanguage to compare many values and find the higher or, the lower.

myValue = -999 ;

for x = 0 to 200 
begin
if High[x] > myValue then
myValue = High[x] ;
end ;

To learn how to build an indicator in EasyLanguage and PowerLanguage for Tradestation or Multicharts, start here.

Resources:

WIKIPEDIA

More from Finance Strategy System