Switch/ Case Compile error  [SOLVED]

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

Switch/ Case Compile error

Postby arjfca » 29 Dec 2013

Hello

I'm trying to use the Switch / Case function to replace a series of "IF Then" in my code. No success yet..

The condition where price need to be between two values is causing me problem

Case <= Button_3_High and >= Button_3_Low : Button_3 = true;

Code: Select all

If vClickBarNbr = barnumber + maxbarsback then begin
HighestPrice = Getappinfo(aiHighestDispValue);
Lowestprice = Getappinfo(aiLowestDispValue);
UpperPart = HighestPrice - (.1 * (HighestPrice-LowestPrice));
LowerPart = HighestPrice - (.90 * (HighestPrice-LowestPrice));
Button_3_High = highestprice - ((HighestPrice-Lowestprice) *.45);
Button_3_Low = HighestPrice - ((HighestPrice-lowestprice) *.55);

Switch (vclickprice) begin
Case >= upperpart : Button_1 = true ;
Case <= Lowerpart : Button_5 = true;
Case <= Button_3_High and >= Button_3_Low : Button_3 = true;
end;
end;
Martin

User avatar
ABC
Posts: 719
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: Switch/ Case Compile error

Postby ABC » 29 Dec 2013

To my knowledge it is not possible to use logical operators in case conditions. Although the EasyLanguage Essentials guide suggests otherwise.

User avatar
Roman MultiCharts
Posts: 50
Joined: 28 Nov 2011
Has thanked: 21 times
Been thanked: 67 times

Re: Switch/ Case Compile error  [SOLVED]

Postby Roman MultiCharts » 08 Jan 2014

Hello arjfca,

The only way to acheive your goal is to separate cases.
Switch (vclickprice) begin
Case >= upperpart : Button_1 = true;
Case <= Lowerpart : Button_5 = true;
Case <= Button_3_High : Button_3 = true;
Case >= Button_3_Low : Button_3 = true;
end;

arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Re: Switch/ Case Compile error

Postby arjfca » 08 Jan 2014

Hello arjfca,

The only way to acheive your goal is to separate cases.
Switch (vclickprice) begin
Case >= upperpart : Button_1 = true;
Case <= Lowerpart : Button_5 = true;
Case <= Button_3_High : Button_3 = true;
Case >= Button_3_Low : Button_3 = true;
end;
OK
I had resolved my need by using a series of IF.

This Switch Case function was to be use to determine my Button status, so in my need I can't use your proposition

Happy New Year Roman

Martin


Return to “MultiCharts”