Why are we Stacking these Variables? - AmiBroker | futures io social day trading
futures io futures trading

Why are we Stacking these Variables?
Updated: Views / Replies:1,780 / 1
Created: by DonStar Attachments:0

Welcome to futures io.

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

futures io is the largest futures trading community on the planet, with over 100,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

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

Thread Tools Search this Thread

Why are we Stacking these Variables?

  #1 (permalink)
Dallas, TX
Trading Experience: Intermediate
Platform: ToS, TradeGuider, eSignal, AmiBroker
Broker/Data: TD Ameritrade/eSignal
Favorite Futures: Stocks
DonStar's Avatar
Posts: 68 since Dec 2011
Thanks: 28 given, 41 received

Why are we Stacking these Variables?

Hi ALL: I have a piece of code written in AmiBroker AFL that I am trying to unserstand.

xBarIndex= BarIndex();
x= xBarIndex;
xLastValue= LastValue( x );
This is the output I get from the debug window:
Last value of x = 520
Bar Index = 511

Okay, 520 is the last bar of data. No matter which bar I select the LastValue is always 520. BarIndex in this example is 511, but it changes to a different number when I select a different bar.

So my question is: why put BarIndex() into the variable (xBarIndex)?

And then why put xBarIndex into another variable (x)?

And finally, whay use x to compute LastValue? Why not just do this:
xLastValue( BarIndex() )

I'm sure there is a reason behind this and I would like to understand the logic.

Can anyone help me understand this?

Visit my futures io Trade Journal Reply With Quote
  #2 (permalink)
Asheville, North Carolina
Posts: 24 since Sep 2010
Thanks: 1 given, 15 received

You are dealing with poorly written code. BarIndex() returns an array in which the first bar is 0 in contrast to Barcount which is the number of bars (a single number) starting at 1. If this makes no sense, read the section of the Users Guide regarding arrays. So for the last bar BarIndex() = BarCount - 1.

All you need is one line: xBarIndex = LastValue(BarInddex();

You should read the Help and Users Guide for a full description of both and also look at the "Common Errors" section which discusses common errors using them.

In addition to reading Help and User Guide, put this little piece of code in a blank window and it will help you understand the difference as you click on different bars.

xBarIndex= BarIndex();
x= xBarIndex;
xLastValue= LastValue(BarIndex());//LastValue( x );
Title = "xbarindex=" + xbarindex + " x=" + x + " xlastvalue=" + LastValue(x) + " barcount = " + BarCount;

Last edited by colion; January 25th, 2012 at 09:23 AM.
Reply With Quote


futures io > > > > Why are we Stacking these Variables?

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Upcoming Webinars and Events (4:30PM ET unless noted)

futures io is celebrating 10-years w/ over $18,000 in prizes!

Right now

$250 Amazon Gift Cards with our "Thanks Contest" challenge!

Right now

Show us your trading desks and win over $5,000 in prizes w/Jigsaw Trading


Trading Nadex Touch Bracket Contracts Sized Like Micro Futures w/Nadex

Sep 17

The Spirituality of Trading w/Dr Brett Steenbarger

Elite only

Similar Threads
Thread Thread Starter Forum Replies Last Post
Global Variables In TS c12345 EasyLanguage Programming 7 October 14th, 2017 09:52 AM
Exposing variables kaywai NinjaTrader Programming 4 April 14th, 2011 11:58 AM
Set Profit and Loss Variables brightredmegaphone NinjaTrader Programming 20 December 10th, 2010 06:21 PM
Global Variables and Strategies in Ninja 6.5 TonyA NinjaTrader Programming 3 November 6th, 2010 07:50 AM
Print format for Forex variables arjfca EasyLanguage Programming 2 October 3rd, 2010 09:57 AM

All times are GMT -4. The time now is 04:36 AM. (this page content is cached, log in for real-time version)

Copyright © 2019 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