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,513 / 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 90,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

Reply
 
Thread Tools Search this Thread
 

Why are we Stacking these Variables?

  #1 (permalink)
Elite Member
Dallas, TX
 
Futures 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.

 
Code
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?

Reply With Quote
 
  #2 (permalink)
Trading Apprentice
Asheville, North Carolina
 
Futures Experience: Advanced
Platform: AmiBroker, Dynamic Trader, Metastock, FreeStockCharts, TradingView
Favorite Futures: stocks, options
 
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 10:23 AM.
Reply With Quote
The following 3 users say Thank You to colion for this post:

Reply



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)

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

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


All times are GMT -4. The time now is 09:10 AM.

Copyright © 2017 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
Page generated 2017-12-11 in 0.10 seconds with 19 queries on phoenix via your IP 54.226.227.175