help needed in coding a variable in afl. - AmiBroker | futures io social day trading
futures io futures trading


help needed in coding a variable in afl.
Updated: Views / Replies:538 / 7
Created: by milkysahai001 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 dont 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
 

help needed in coding a variable in afl.

  #1 (permalink)
Trading Apprentice
Agra+India
 
Futures Experience: Beginner
Platform: MultiCharts, AmiBroker
Favorite Futures: Stock Futures
 
Posts: 42 since Sep 2016
Thanks: 17 given, 3 received

help needed in coding a variable in afl.

i am trying to code a variable HaOpen (my modified open for Heikin Ashi) which depends on HaClose (modified close).

HaOpen is basically ((HaOpen[previous]) + smooth * ( HaClose – HaOpen[previous])), but the first value when the calculation starts HaOpen[previous] will be undefined or null, therefore to avoid that situation i want to define first value of HaOpen[previous] as HaClose and afterwards it will take HaOpen[previous] value by itself.

now, i tried coding it on multicharts, where the code is running flawlessly:
value1= IFF (vOpen[1] > 0, vOpen[1], vClose);
vOpen= ((value1) + smooth * ( vClose - value1));


in Amibroker i tried this:
if
(typeof (HaOpen) == "undefined")
{
HaOpen = HaClose;
}
HaOpen = Ref(HaOpen, -1) + smooth * (HaClose - Ref(HaOpen, -1));

which is giving different values of HaOpen in Ami and Multicharts on same data even when values of HaClose are the same.

i tried these 3 too:

value1 = IIf(Ref(HaOpen,-1)>0, Ref(HaOpen,-1),HaClose);
HaOpen = value1 + smooth*(HaClose-value1) ;


Value1 = IIf(IsNull(Ref(HaOpen, -1)), HaClose, Ref(HaOpen, -1));
HaOpen = Value1 + smooth * (HaClose - Value1);

HaOpen =Nz(Ref (HaOpen, -1) )+ smooth * (HaClose - Nz(Ref(HaOpen, -1)));

but all efforts are going in vain as it is asking to initialize HaOpen first, when I am initializing it to anything, it is not updating the new value of HaOpen and instead taking the value initialized throughout the chart.


I made an excel worksheet applying the excel formulae to get what i want and the results are matching completely with multicharts, but not with amibrokers leading to a lot of frustration. :|

Somebody please help. If you don't understand this please ask me. Thanks in anticipation!!


P.S: I am a newbie in afl coding and trying my best.

Reply With Quote
 
  #2 (permalink)
Trading Apprentice
Denver CO USA
 
Futures Experience: None
Platform: NT, JForex, Mql4 & 5
Broker/Data: FXCM
Favorite Futures: Forex
 
Posts: 32 since Sep 2016
Thanks: 0 given, 13 received

Use the function Nz. Tests for null or undefined if so sets to second value.

HaOpen = Nz(HaOpen, HaClose);

Reply With Quote
 
  #3 (permalink)
Trading Apprentice
Agra+India
 
Futures Experience: Beginner
Platform: MultiCharts, AmiBroker
Favorite Futures: Stock Futures
 
Posts: 42 since Sep 2016
Thanks: 17 given, 3 received



maryfromcolorado View Post
Use the function Nz. Tests for null or undefined if so sets to second value.

HaOpen = Nz(HaOpen, HaClose);



maryfromcolorado,

Not working. its asking to initialize HaOpen first.

Reply With Quote
 
  #4 (permalink)
Trading Apprentice
Denver CO USA
 
Futures Experience: None
Platform: NT, JForex, Mql4 & 5
Broker/Data: FXCM
Favorite Futures: Forex
 
Posts: 32 since Sep 2016
Thanks: 0 given, 13 received

I am just looking at documentation. It should work.

https://www.amibroker.com/guide/afl/nz.html

You can use the other function then

HaOpen = IIf( IsFinite( HaOpen), HaOpen, HaClose);

Isn't there an initialization section where you could set HaOpen to 0 and then test for that ?

Reply With Quote
The following user says Thank You to maryfromcolorado for this post:
 
  #5 (permalink)
Trading Apprentice
Agra+India
 
Futures Experience: Beginner
Platform: MultiCharts, AmiBroker
Favorite Futures: Stock Futures
 
Posts: 42 since Sep 2016
Thanks: 17 given, 3 received


maryfromcolorado View Post
I am just looking at documentation. It should work.

https://www.amibroker.com/guide/afl/nz.html

You can use the other function then

HaOpen = IIf( IsFinite( HaOpen), HaOpen, HaClose);

Isn't there an initialization section where you could set HaOpen to 0 and then test for that ?


maryfromcolorado,

i had previously tried :
Value1 = IIf(IsNull(Ref(HaOpen, -1)), HaClose, Ref(HaOpen, -1));
HaOpen = Value1 + smooth * (HaClose - Value1);

but again the initialization issue.

when referring to the previous value of HaOpen it is taking the value of whatever i am initializing it to.

say, if i initialize it as HaOpen = HaClose; then in the next line of HaOpen =Nz(Ref (HaOpen, -1) )+ smooth * (HaClose - Nz(Ref(HaOpen, -1))); it takes the value of HaClose everytime HaOpen is referred to and likewise with zero.

Reply With Quote
 
  #6 (permalink)
Trading Apprentice
Denver CO USA
 
Futures Experience: None
Platform: NT, JForex, Mql4 & 5
Broker/Data: FXCM
Favorite Futures: Forex
 
Posts: 32 since Sep 2016
Thanks: 0 given, 13 received

Sorry I don't know enough about AmiBroker to help further without a lot of investigation.

Reply With Quote
 
  #7 (permalink)
Trading Apprentice
Agra+India
 
Futures Experience: Beginner
Platform: MultiCharts, AmiBroker
Favorite Futures: Stock Futures
 
Posts: 42 since Sep 2016
Thanks: 17 given, 3 received


maryfromcolorado View Post
Sorry I don't know enough about AmiBroker to help further without a lot of investigation.


maryfromcolorado,

its okay. thanks for your inputs.

Reply With Quote
 
  #8 (permalink)
Trading Apprentice
Melbourne, Australia
 
Futures Experience: Advanced
Platform: Ninja
 
Posts: 6 since Jun 2010
Thanks: 0 given, 1 received

You can't use a variable before it is initialized because the values in it would be junk.

The only way to do what you want is a loop.

HaOpen[0] = HaClose[0];
for(i = 1; i < BarCount; i++)
{
HaOpen[i] = HaOpen[i -1] + smooth * (HaClose[i] - HaOpen[i -1]);
}

Reply With Quote
The following user says Thank You to johny for this post:

Reply



futures io > > > > help needed in coding a variable in afl.

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

RandBots: AutoTrading Bots to diversify your trading

Oct 24
 

TopstepTrader: Profiting Without Risking Your Own Money

Oct 26

Building Open Source Indicators for NT8 w/Fat Tails @ Lizard Indicators

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
help needed in coding some variables in easy/powerlanguage! milkysahai001 MultiCharts 3 November 16th, 2016 04:49 AM
Static Variable from Pre-defined variable jrobinson3002 MetaQuotes MetaTrader MQL Programming 1 April 15th, 2015 09:15 PM
Little coding help needed Abde NinjaTrader 8 April 10th, 2014 11:45 AM
Strategy Coding - help needed - ORB & Trailing conditions RodS The Elite Circle 24 December 8th, 2010 08:30 AM
Stochastics coding help needed! RodS NinjaTrader Programming 33 October 24th, 2009 05:58 PM


All times are GMT -4. The time now is 05:44 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-10-24 in 0.11 seconds with 35 queries on phoenix via your IP 54.162.152.232