Newby: Compilation error

Questions about MultiCharts and user contributed studies.
arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Newby: Compilation error

Postby arjfca » 24 Nov 2010

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

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Newby: Compilation error

Postby TJ » 24 Nov 2010

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: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Re: Newby: Compilation error

Postby arjfca » 24 Nov 2010

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

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Newby: Compilation error

Postby TJ » 24 Nov 2010

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 then
plot10(High, "H") {note NO ; at the end of statement}
else
plot10(Low, "L"); {note ; at the end of statement}

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

Code: Select all

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

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Newby: Compilation error

Postby TJ » 24 Nov 2010

more examples:

All about loops
viewtopic.php?f=16&t=7351


Return to “MultiCharts”