NexusFi: Find Your Edge


Home Menu

 





What does VarName.Set(1, VarName[1]) do?


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one jvbehar with 4 posts (0 thanks)
    2. looks_two eDanny with 1 posts (0 thanks)
    3. looks_3 Xeno with 1 posts (0 thanks)
    4. looks_4 Big Mike with 1 posts (0 thanks)
    1. trending_up 2,305 views
    2. thumb_up 0 thanks given
    3. group 3 followers
    1. forum 7 posts
    2. attach_file 2 attachments




 
Search this Thread
  #1 (permalink)
jvbehar
Miami, Florida USA
 
Posts: 5 since Dec 2010
Thanks Given: 0
Thanks Received: 0

Hello All: What does this statement do?

VarName.Set(1, VarName[1])

Is the "1" an initialization value of some sort?

Thank you for any guidance you can provide.


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
SEC Chairman Calls for New Golden Age of SEC-CFTC Regula …
Traders Hideout
The May 31 Binary: 60% Trump Declares Iran Ops Over, Onl …
Prediction Markets & Event Contracts
GDP Day: The First Economic Reckoning -- Pahlavi at 6.55 …
Prediction Markets & Event Contracts
CME Raises Energy Futures Margins After Iran-War Volatil …
Commodities
CME Group Fee Schedule Changes Hit All Four Exchanges -- …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #3 (permalink)
 Xeno 
UK
 
Experience: Intermediate
Platform: Ninja
Broker: Mirus/Zen
Trading: Futures - bonds, currencies, index
Posts: 288 since Oct 2010
Thanks Given: 70
Thanks Received: 274


The "1" is an index into an array called VarName.

VarName[1] means the element in the array which has index 1.


Reply With Quote
  #4 (permalink)
jvbehar
Miami, Florida USA
 
Posts: 5 since Dec 2010
Thanks Given: 0
Thanks Received: 0

Xeno, thank you for your reply. This is from the attached Ninja script for the SuperTrend Indicator. I was refering to the first "1", in the line

VarName.Set(1, VarName[1]) (the [1] reference here is to "the value at prior bar")

There are no arrays defined as far as I can see. There are references of similar structure with a single dimension such as

VarName.Set(VarName[1]);

so to see the two arguments is throwing me off.

I am experienced in EL and am trying to convert from the NT script.

Thank you for again for your attention.


Attached Files
Elite Membership required to download: Supertrend Code.txt
Reply With Quote
  #5 (permalink)
 
eDanny's Avatar
 eDanny 
East Rochester, NY
 
Experience: Intermediate
Platform: NT
Posts: 329 since Jul 2009
Thanks Given: 18
Thanks Received: 425

This is referencing a plot. The first 1 means plot one bar back and the [1] means use the value from one bar back in that plot. This is usually used to join two different line plots together when the color changes else you might get a one bar blank spot.

Dan


Reply With Quote
  #6 (permalink)
jvbehar
Miami, Florida USA
 
Posts: 5 since Dec 2010
Thanks Given: 0
Thanks Received: 0

Danny, got it, thank you very much!


Reply With Quote
  #7 (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,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,557


jvbehar View Post
Xeno, thank you for your reply. This is from the attached Ninja script for the SuperTrend Indicator.

If your intention is to convert SuperTrend to EL, check here:


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 X Visit my NexusFi Trade Journal Reply With Quote
  #8 (permalink)
jvbehar
Miami, Florida USA
 
Posts: 5 since Dec 2010
Thanks Given: 0
Thanks Received: 0

Mike, thanks for tip. That is actually where I started. I ran your code but the display was nothing like the NT indicator that supposedly does the same thing. I could not really tell why, hence I needed to convert line-by-line directly from the NT script to see where the discrepancy was. I believe the code difference is minor but the resulting display differences are not.

If you are familiar with Ninja script I would appreciate if you take a quick look at the attached, maybe something will jump out at you.

Thank you in advance.

JBehar


Attached Files
Elite Membership required to download: Supertrend Code.txt
Reply With Quote




Last Updated on December 5, 2010


© 2026 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 - Downloads - Top
no new posts