How to use Loop in EasyLanguage & PowerLanguage
loop in easylanguage cover tradestation

Share This Post

Share on facebook
Share on linkedin
Share on twitter
Share on email

Today you will discover how to use the loop in EasyLanguage 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 if you need to use more candles then five.

We can write this code using a loop in EasyLanguage for TradeStation and MultiCharts. With the loop, you can repeat certain desiginated 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 loop instruction.

This is the code with loop in EasyLanguage for TradeSTation and MultiCharts

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 use the loop in EasyLanguage also 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

EasyLanguage Tutorial & PowerLanguage Tutorial – Part 01

CONNORS RSI STRATEGY

MACD Indicator – Moving Average Convergence Divergence – Tutorial

Tutorial EasyLanguage – How to use the PaintBar

HOW TO USE THE AVERAGE TRUE RANGE

EasyLanguage Tutorial & PowerLanguage Tutorial – Part 01

TradeStation Tutorial

Market Correlation | Stock Market – Bond – Commodities

EasyLanguage & PowerLanguage Tutorial – The Inputs

Coppock Curve Indicator

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Leave a Reply

My name is Luca. I grew up in Italy. I have a degree in law and I’m an independent trader since 2007. I’m a systematic trader and sometimes, I trade using options strategies with US ETFs and Stocks.I have built hundreds of automated trading systems and indicators for TradeStation, MultiCharts and MetaTrader.I started this blog in 2017 to share what I learned in the financial market.

Subscribe To Our Newsletter

Recent Posts