Syntax - what do question marks do? - futures io
futures io futures trading



Syntax - what do question marks do?


Discussion in NinjaTrader

Updated
    1. trending_up 888 views
    2. thumb_up 3 thanks given
    3. group 2 followers
    1. forum 1 posts
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Syntax - what do question marks do?

(login for full post details)
  #1 (permalink)
Bradford, UK
 
Experience: Beginner
Platform: NinjaTrader
Trading: Gold
 
xigreek's Avatar
 
Posts: 9 since Oct 2011
Thanks: 10 given, 2 received

Hi everyone

I was trying to code a new indicator and I started by one I'd downloaded from somewhere or other a long time ago...

It contains the following code - the syntax is something I'm not really familiar with - can anyone explain what this code does?


lasthi = hi[0] = useHiLo ? High[0] : Input[0];

I've never used questionmark in my code before and I'm not entirely sure what the colon is doing either!

Thanks.

Started this thread Reply With Quote

Can you help answer these questions
from other members on futures io?
Short Interest Ratio indicator?
ThinkOrSwim
ZigZag with Depth and Backstep
EasyLanguage Programming
Webinar: Finding your own way in trading w/Adam Grimes
The Elite Circle
Automatic pattern research with NT
Elite Algorithmic NinjaTrader Trading
Help Needed: TOS Options Chain IV & IMPL MOVE Calcul …
ThinkOrSwim
 
 
(login for full post details)
  #2 (permalink)
Market Wizard
Berlin, Europe
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,855 since Mar 2010
Thanks: 4,238 given, 26,731 received


xigreek View Post
Hi everyone

I was trying to code a new indicator and I started by one I'd downloaded from somewhere or other a long time ago...

It contains the following code - the syntax is something I'm not really familiar with - can anyone explain what this code does?


lasthi = hi[0] = useHiLo ? High[0] : Input[0];

I've never used questionmark in my code before and I'm not entirely sure what the colon is doing either!

Thanks.

The expression replaces if ..... then ....else. The meaning is
 
Code
if(useHiLo)
    lasthi = hi[0] = High[0]
else
    lasthi = hi[0] = Input[0];

The code executed when the expression "useHiLo" is true follows the question mark, the code that is executed when the expression "useHiLo" is false follows the colon.

You can look it up in the C# online reference.

Reply With Quote
The following 3 users say Thank You to Fat Tails for this post:


futures io Trading Community Platforms and Indicators NinjaTrader > Syntax - what do question marks do?


Last Updated on March 4, 2013


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
 

Importance of Finding Your Own Way w/Adam Grimes

Elite only
 

Journal Challenge w/Jigsaw

April
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts