Hi, everyone.
I am going to create the Heiken Ashi indicator. I found one example on this forum, but in this example author
uses 4 functoins - one for each parameter. For one, function for HHClose calculation, function for HHOpen calculation etc.
I want to use one one function that should return Bars object, and i want to use this new Bars for other functions. For
instanse, calculate the ATR from this new Bars. Could you please help me with it. Bellow you can find an schematic example
of my code and information with error.
function Ashi (Bars bar)
{
Bars b_Bar;
b_Bar = bar;
b_Bar.Hight = bar.Hight + ... // Here i have an error, that i can't change Hight attribute. How i should modify my code.
}
Best regard,
Pavel
Size:
Color:
A function returning a Bars object is no different from a method that returns a string, a boolean, instance of a class or anything for that matter. See any C# 101 book or online tutorial, as this is a prerequisite for programming in WealthScript.
P.S. Please take no more duplicate trials. Thanks for your understanding.
Size:
Color:
Thanks for the answer.
I read a book and i know how to return a Bars object. But i don't understand why the bellow code has an error and how i can fix it. Could you please help me?
---
Bars b_Ashi = new Bars (Bars);
b_Ashi.Hight[0] = 10;
I don't have an errors during the compilation, but i have an error during the execution: Index out of range. The follow construction doesn't help also:
b_Ashi.Hight = new DataSeries(Bars.Hight, "Ashi"); I have an error during the compilation.
Size:
Color:
Your code contax obvious syntax errors i.e. Hight to say the least. Since it has a snowball chance in hell of compiling successfully, we need to look at the whole code.
Size:
Color:
I just want to understand how it works and don't write a program, just an example.
1) I use standard AA data from WealthLab ADow 30;
2) The code is
CODE:
Please log in to see this code.
I have the follow PrintDebug message:
Bars(AA,Daily,0,10604)
Bars(AA,Daily,0,0)
As i can see that b_Ashi doesn't contain any information from Bars and i don't know how to copy it.
Size:
Color:
Of course it doesn't contain any information: you just instantiated a new, empty Bars object.
Check out the QuickRef example for Bars.SaveToFile. There's a self-contained code that builds, saves and charts a Heiken-Ashi Bars object.
To wrap it in a method returning a Bars object, all it takes a little bit of C# 101 skill.
Size:
Color:
Thanks a lot.
Size:
Color: