NexusFi: Find Your Edge


Home Menu

 





Embarrassed at the simplicity, but I don't get it - C# basic syntax


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Crassius with 2 posts (0 thanks)
    2. looks_two Big Mike with 1 posts (1 thanks)
    3. looks_3 trendisyourfriend with 1 posts (2 thanks)
    4. looks_4 sam028 with 1 posts (2 thanks)
    1. trending_up 2,806 views
    2. thumb_up 5 thanks given
    3. group 2 followers
    1. forum 5 posts
    2. attach_file 0 attachments




 
Search this Thread

Embarrassed at the simplicity, but I don't get it - C# basic syntax

  #1 (permalink)
 
Crassius's Avatar
 Crassius 
Shenandoah Valley, VA
 
Experience: Advanced
Platform: NT8
Broker: NinjaTrader introduced to Dorman
Trading: ES, CL, 6E, ZN
Posts: 14 since Jan 2011
Thanks Given: 5
Thanks Received: 3

At best I'm teaching myself a little programming by hacking away building indicators, but basically, I'm stumble around trying different things till something works.

I have looked through google etc, and I don't understand why this statement doesn't work.... I must be missing something so basic none of the articles I have read have helped me figure out what is wrong, and why what looks perfectly logical to me just won't compile.

I want to execute a series of statements only if the current bar is within a certain range... this comes up alot when initializing indicators.... so in my ignorance, I write..

if ( CurrentBar >=5 & <=7 )
{
statement
}

Would some kind soul explain to me why that doesn't work, and what I should use instead?

Follow me on Twitter Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
Futures True Range Report
The Elite Circle
Are there any eval firms that allow you to sink to your …
Traders Hideout
Better Renko Gaps
The Elite Circle
Exit Strategy
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
59 thanks
Funded Trader platforms
36 thanks
NexusFi site changelog and issues/problem reporting
25 thanks
GFIs1 1 DAX trade per day journal
19 thanks
The Program
18 thanks
  #3 (permalink)
 
trendisyourfriend's Avatar
 trendisyourfriend 
Quebec Canada
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: ES, NQ, YM
Frequency: Daily
Duration: Minutes
Posts: 4,527 since Oct 2009
Thanks Given: 4,171
Thanks Received: 6,018


Have you tried by simply repeating the variable name 'CurrentBar':

if ( CurrentBar >=5 & CurrentBar <=7 )
{
statement
}

Also, i think you need to double the & operator like this : &&

So your instructions should go like this:
if ( CurrentBar >=5 && CurrentBar <=7 )
{
statement
}

In short, you double everything as the computer is dumb and we need to repeat everything twice ;-)

Reply With Quote
Thanked by:
  #4 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629

It's more
 
Code
                            
if ( CurrentBar>=&& CurrentBar<=)
{
statement


Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
Thanked by:
  #5 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,398 since Jun 2009
Thanks Given: 33,173
Thanks Received: 101,537

Join us tomorrow for a webinar on NinjaScript:


Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #6 (permalink)
 
Crassius's Avatar
 Crassius 
Shenandoah Valley, VA
 
Experience: Advanced
Platform: NT8
Broker: NinjaTrader introduced to Dorman
Trading: ES, CL, 6E, ZN
Posts: 14 since Jan 2011
Thanks Given: 5
Thanks Received: 3

Many thanks...

Follow me on Twitter Started this thread Reply With Quote




Last Updated on February 22, 2011


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts