How to save the bar that contains the highest/lowest value in a DataSeries?
Author: RickTg
Creation Date: 10/3/2015 5:49 PM
profile picture

RickTg

#1
Not being a C programmer and just trying to learn the Wealth Lab programming language, I would like some help with the subject matter. I have included a snippet of code that I am trying to develop.

As well as other compiler errors, I am getting 'the name highbar does not exist in the current context' for the code 'if (highbar < lowbar)'. Of course, I am getting the same error for lowbar.

What do I need to do to rectify this?

Thank you

Rick

CODE:
Please log in to see this code.
profile picture

Eugene

#2
There may be a more efficient pattern for your task but first please tell the forum what you're trying to accomplish, i.e. the rules in plain English.
profile picture

RickTg

#3
I heard about a supposedly good trading system that works with, among other factors, the following 2 formulae.

(# periods - # periods since highest high) / # periods

(#periods - # periods since lowest low) / # periods

When the first formula crosses the second formula upwards, BUY
When the first formula crosses the second formula downwards, SELL

I have reduced these formulae (I hope correctly) to just # periods since HH (LL).

My code snippet was just a rudimentary attempt to start learning the Wealth Lab language and to start coding the system. As my language knowledge increases, I intended to use crossover() and crossunder() as well as an array for the high and low # of periods. In that way, I could grow both the trading system and my programming skills concurrently. Then I could quickly test concepts I read or hear about in my research.

I hope this helps.

Rick
profile picture

Eugene

#4
Thanks. Hopefully I understood your idea - feel free to correct me if I'm wrong:

CODE:
Please log in to see this code.
profile picture

RickTg

#5
Eugene

That looks fantastic. On the surface it looks like it does the trick, but now I have to REALLY look at it in detail to understand the code.

Thank you very much

Rick
profile picture

RickTg

#6
I do not understand the following line of code.

CODE:
Please log in to see this code.


I understand the DataSeries h,l which sets up an array for each. But I do not understand why there is Close*0 for each of them. My first guess is that you are initializing both arrays to 0, but if my guess is correct, then why in this manner.

Thanks again.

Rick
profile picture

Eugene

#7
It's one of the ways to initialize a DataSeries. For example, please see the WealthScript Programming Guide > DataSeries > Filling a Custom DataSeries > How to: Create a DataSeries filled with zeroes.
profile picture

RickTg

#8
Thank you
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).