# Newby: Compilation error

Questions about MultiCharts and user contributed studies.
arjfca
Posts: 1276
Joined: 23 Nov 2010
Has thanked: 722 times
Been thanked: 222 times

### Newby: Compilation error

Hello again

Compile failed at the "Else" part ???
Message:
syntax error, unexpected 'else', expecting 'End'
errLine 35, errColumn 7, errLineEnd 35, errColumnEnd 7
causal study: (Function)

This part is to test if the variable TLLow is the lowet Low within 5 periods. If it is, them TLLOw should be equal to the lowset low within 5 periods

Code: Select all

`if Step1 then begin   //If Step2_Step1_S1   If Low >= TLLow then begin //If Step2_Step1_S2   // Dont test the same low      // Price to be higher than TLLOw within 5 periods.  Meaning TLLow as to be the lowest price within 5 periods      If Lowest(Low, 5) = TLLOw then begin // If Lowest(5)_S3         step2 = true;       else              Step2 = False;          Step1 = False;       end; //If Lowest(5)_E3     end;  //If Step2_Step1_E2    end;  //If Step2_Step1_E1`

Any help appreciated
MT

TJ
Posts: 6827
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 978 times
Been thanked: 1967 times

### Re: Newby: Compilation error

try these:

Code: Select all

`if Step1 then begin   //If Step2_Step1_S1   If Low >= TLLow then begin //If Step2_Step1_S2   // Dont test the same low      // Price to be higher than TLLOw within 5 periods.  Meaning TLLow as to be the lowest price within 5 periods      If Lowest(Low, 5) = TLLOw then  // If Lowest(5)_S3      begin    {note: you need a matching BEGIN and END block}         step2 = true;      end      else      begin    {note: you need a matching BEGIN and END block}          Step2 = False;          Step1 = False;      end; //If Lowest(5)_E3     end;  //If Step2_Step1_E2   end;  //If Step2_Step1_E1`

or

Code: Select all

`if Step1 then begin   //If Step2_Step1_S1   If Low >= TLLow then begin //If Step2_Step1_S2   // Dont test the same low      // Price to be higher than TLLOw within 5 periods.  Meaning TLLow as to be the lowest price within 5 periods      If Lowest(Low, 5) = TLLOw then  // If Lowest(5)_S3         step2 = true   {note no ; }      else      begin   {note: you need a BEGIN and END block for multiple statements}          Step2 = False;          Step1 = False;      end; //If Lowest(5)_E3     end;  //If Step2_Step1_E2   end;  //If Step2_Step1_E1`

arjfca
Posts: 1276
Joined: 23 Nov 2010
Has thanked: 722 times
Been thanked: 222 times

### Re: Newby: Compilation error

Many thanks again TJ.

I'm mixed up with statements
If else end, end;
When to use ";" or when to use "End" instead of "End;"

I will read more about it as I do mix VBA style programation with EasyLanguage.

Martin

TJ
Posts: 6827
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 978 times
Been thanked: 1967 times

### Re: Newby: Compilation error

arjfca wrote:Many thanks again TJ.

I'm mixed up with statements
If else end, end;
When to use ";" or when to use "End" instead of "End;"

I will read more about it as I do mix VBA style programation with EasyLanguage.

Martin

";" indicates the end of an instruction. eg. at the end of a statement.

eg #1

Code: Select all

`plot10(Low, "L");  {note ; at the end of statement}`

eg #2 the whole thing is considered one instruction!

Code: Select all

`if condition = true thenplot10(High, "H")  {note NO ; at the end of statement}elseplot10(Low, "L"); {note ; at the end of statement}`

eg #3 add ; to the BEGIN/END block.

Code: Select all

`if condition = true thenbegin    plot10(High, "H");  {note ; at the end of statement}    plot20(Low, "L");  {note ; at the end of statement}end;`

TJ
Posts: 6827
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 978 times
Been thanked: 1967 times

more examples: