Hi,
Could you please help me to translate this code, namely the "FindNamedSeries"?
CODE:
Please log in to see this code.
Thanks a lot
Size:
Color:
If I didn't know your objective I'd suggest you look up
FindNamedSeries and especially HasNamedSeries (also
NamedSeries) in the QuickRef, the
Bars object section.
However, knowing that you're not interested in NamedSeries but are merely trying to translate
Total Cyclic Package, the answer is very different:
CODE:
Please log in to see this code.
As you see, you don't even need no
FindNamedSeries.
Size:
Color:
I'm sorry, but could you explain me which code you're translating with these two lines?
Size:
Color:
From your script in translation, of course.
Just give it a little thought:
QUOTE:
//-----------------------------------------------------------------------
//- FUNCTION: ForwardFillWithValue
//- This function is used to fill a series with whatever value is desired
//- forward with the input series, 'series'.
//-----------------------------------------------------------------------
The "5" in my code snippet is the "whatever value"
The "
DataSeries ds" is the output of the ForwardFillWithValue.
You don't need no ForwardFillWithValue. Just create a new series and fill it with the value ("val" in your terminology). The
shortest way to do it is shown above. Hope that helps.
Size:
Color:
Your two lines code translates the function ForwardFillWithValue? With the same names, can I substitute my old code to
CODE:
Please log in to see this code.
? It doesn't specify the startBar...
Size:
Color:
Give it a try, and if having the startBar is really required, just create an extra loop by Bars from StartBar to Bars.Count-1 to assign the fixed value to the DataSeries. Just as the original code does.
Size:
Color:
Thanks. With the new explanation I understood better! But for maintain the values for bars before StartBar in Data Series "Series" we need
CODE:
Please log in to see this code.
, right?
Size:
Color:
Almost; in the loop it would be ForwardFillWithValue[bar] = Series[bar].
Size:
Color:
ok, thank you. Regarding the code from "Total Cyclic Package", is it right the translation to
CODE:
Please log in to see this code.
from
CODE:
Please log in to see this code.
and to
CODE:
Please log in to see this code.
from
CODE:
Please log in to see this code.
?
Size:
Color:
The DataSeries should be shifted to the right >> (not to the left <<).
Size:
Color:
Are you sure? I'm asking because in the WL4 QuickRef, we have for the OffSetSeries function: "Offsets the specified Price Series by a certain number of Bars and returns the handle to a new Price Series. Use a negative offset value to shift the Price Series to the right on the chart. Shifting a moving average to the right often leads to cleaner signals. " So I think that DataSeries should be shifted to the left (because (p2-1)/2>0 ). Thank you
Size:
Color:
Please note that we are talking Wealth-Lab v6 here, and the QuickRef for the DataSeries Object contains unambiguous instructions on properly shifting a DataSeries.
Size:
Color:
Hello, nobody have the translation from "Total Cyclic Package" referred before from WL4 to WL V6? I've been trying but without sucess yet.
Thanks
Size:
Color:
When manually converting a complex script like
Total Cyclic Package v3.0 (Centered SMA), a good technique is to break it down into smaller pieces so that you can concentrate on a manageable chunk of code. Start with a DataSeries, or with a segment, verify that it works, then proceed to the next one.
P.S. Just noticed that I left your question regarding Correlation unanswered. Yes, the translation seems right except that I'm not sure about the "+1" part since it's missing in the original code.
Size:
Color:
ok, thank you. Regarding the offset, when I have the following code, what is the lenght of serie ma202: (Lastbar - (p2 - 1) / 2) or (Lastbar - (p20 - 1) / 2)?
CODE:
Please log in to see this code.
Size:
Color:
All DataSeries contain the same number of values as bars in the chart. Otherwise please clarify the meaning of "length".
Size:
Color:
So, regarding the last code,
- serie SMA.sERIES(AVG,P2) have "Bars.Count = Lastbar" bars, with the first p2 bars with value 0
- series ma2 have "Lastbar" bars, with the last (p2-1)/2 bars with the value 0, and with the first (p2-1)/2 bars with value 0, and the same for ma202 if p20<p2.
Thank you
Size:
Color:
No. Shifting a DataSeries does not affect the number of bars in it -- only the values are being moved.
Size:
Color:
Could you confirm this translation? WL4 Round uses the "Bankers Rounding", is WL6 using it too?
WL6
CODE:
Please log in to see this code.
WL4
CODE:
Please log in to see this code.
Size:
Color:
QUOTE:
Could you confirm this translation?
As I don't have WL4 installed for quite a time now, I'm leaving the task of comparing results produced by the two scripts up to you.
QUOTE:
WL4 Round uses the "Bankers Rounding", is WL6 using it too?
To find out simply visit the MSDN website and look the
Round method. It's answered there.
Size:
Color:
Hi. I need to calculate the serie cor, to obtain cor[ebar], for each j, from sbar to ebar. However, with the code below I obtain allways the same cor[ebar]. How can I clear the values in the serie cor in the end of the "for (j)"? With this problem solved, I have the Cyclic Package completely translated. Thank you.
CODE:
Please log in to see this code.
Size:
Color:
Ideally, a Value method would be available for this, but the documentation syntax doesn't even correctly specify the Series method either. Anyone who is motivated could work on the Value method for this indicator... it's open source you know!
Size:
Color:
Are you talking about this: public double Correlation(double[] x, double[] y, int n)
?
Size:
Color:
Size:
Color:
But for find a correlation as a value? Or for all Cycle package? Now, I only need a method for clear the "cor" serie after the code below, for to calculate a new "cor" serie, with another j.
CODE:
Please log in to see this code.
Size:
Color:
Out of curiousity, what's the point in adding that +1 even though it's not in the source chartscript and your loops operate with the same start/end values?
CODE:
Please log in to see this code.
QUOTE:
However, with the code below I obtain allways the same cor[ebar].
Substitute the
Correlation with a vanilla series like
SMA. Does the problem persist? If it does, the problem might be elsewhere.
Size:
Color:
Yes, it does. I know that problem isn't in the calculation of correlation, it is because in the cycle "for j" the serie "cor" is allways the same, for j=sbar, ..., ebar, but it dependes of serie "sine1" that is different for each j. I think a method for clear the "cor" serie in the end of cycle "for j" solve the problem. May be a similar code to RestoreScale, but only for one serie. Coul you help me please? Thanks a lot.
Size:
Color:
I'll second Cone's idea and suggest you to calculate Correlation on-the-fly in this part of the code. The easiest way to do it is by adding the CORREL method shared by DartboardTrader
in this thread (click) in his post dated 3/30/2009 3:33 PM. So, use it simply as you would use Correlation.
Value if it existed.
Size:
Color:
Eugene,
Thanks for the sugestion, I tried that, without sucess, though. However, I obtain good results for this part of the code with the Bars.Cache.Clear(), dispite the long time running.... Is it a good solution, or should I try once again the CORREL method by DartboardTrader? Thanks
CODE:
Please log in to see this code.
About your curiosity, in the original code we have float number from cor:=Correlation( cycle1, sine1, sbar, ebar ), so that the period for calculate the correlation is since sbar until ebar (including, I supposed) which corresponde to ebar - sbar + 1 bars (if sbar = 1 and ebar = 1, we have the correlation of two series with only 1 entrance each).
Size:
Color:
I'd do it using the CORREL function but whatever works for you is automatically fine with me. ;)
Size:
Color: