OmniTrader Professional Forum OmniTrader Professional Forum
forums calendars search
today this week
register logon control panel Forum Rules
You are currently browsing as a guest.
You should logon to access more features
A Self-Moderated Community - ALL MEMBERS, PLEASE READ!
Vote for Members who contribute the most to your trading, and help us moderate content within the Forums.

  Current location        Thread information  
OmniTrader Pro Resource Forum
OmniTrader Pro Technical Support
Formatting for Conditional Loops
Last Activity 11/2/2018 2:25 AM
1 replies, 244 viewings

Jump to page : 1
Now viewing page 1 [25 messages per page]
back reply
Printer friendly version

^ Top


Posts: 16

Joined: 1/31/2016

User Profile
Subject : Formatting for Conditional Loops
Posted : 10/12/2017 3:43 PM
Post #29664

Not entirely sure how the formatting for the conditional loops are. I know how the if statement works, but the for statement, IIF, etc. I'm not sure.

Some examples with explanations would be highly appreciated.


If [condition] then
end if

Just wondering how it works with the other statements.

[Edited by ZMTLock on 10/12/2017 3:45 PM]

^ Top
Jim Dean

Posts: 3147

Joined: 3/13/2006
Location: L'ville, GA

User Profile
Subject : RE: Formatting for Conditional Loops
Posted : 10/12/2017 4:07 PM
Post #29665 - In reply to #29664

The complete form for if/then is ...

if condition1 then
elseif condition2 then
... more elseif's if desired
end if

The first line, second line, and last line are required ... others are optional.

A simplified form is also allowed:
If condition then expression
... no else or endif required

The syntax for iif() is:

iif(boolean condition, expressionT, expressionF)
... where a True result for the boolean (logical T/F result) condition causes the "expressionT" to be used, and a False result causes the "expressionF" to be used.

The IIF can stand alone, in a Filter Block or Color Chart, etc field that is expecting a true/false result, IF the two "expressions" themselves produce boolean logic T/F results.

Alternatively, the result of the iif() can be assigned to a dimensioned variable:
X = iif(...)

Further, iif's can be nested:

X = iif(cond1, exp1, iif(cond2, exp2, iif(cond3, exp3, exp4)))
... but BE CAREFUL with this and manually test the result ... there are certain oddball circumstances in which either the "cond" fails to parse properly, &/or the "exp" fails. I use nested IIF's quite often, but I always test them.

Finally ... none of these things are "conditional loops". The if/then/else/endif is a conditional structure with two conditional clauses. Similar terminology for IIF examples.

A "loop" is a repetitive, iterative process controlled by For/Next or Do/Until or a few other VBA syntactical options.

Further questions of this nature are best researched by googling "VBA" plus whatever your query is ... trust the Microsoft answers if available.

[Edited by Jim Dean on 10/12/2017 4:09 PM]

Jump to page : 1
Now viewing page 1 [25 messages per page]
back reply

Legend    Action      Notification  
Forum Moderator
Registered User
Unregistered User
E-Mail this thread to a friend
Toggle e-mail notification

Nirvana Systems
For any problems or issues please contact our Webmaster at