Does anyone know specifically what code snippets I would have to have in my indicator so that the anaSuperTrendU11 trend direction could be revealed?
I have looked at the anaSuperTrendU11 code, and here is the following BoolSeries related code:
So I'm trying to specifically access the anaSuperTrendU11's public BoolSeries UpTrend. Would someone be willing to help me understand what specific code snippets I would need to have in my indicator to access the UpTrend value (ie, 0 or 1)?
Thanks for your help. I really appreciate it.
Last edited by aventeren; October 2nd, 2013 at 01:11 AM.
Broker/Data: Mirus (Broker), Continuum (Data), Dorman (Clearing)
Favorite Futures: Futures
Posts: 202 since Mar 2013
Thanks: 426 given,
A Night's Sleep...
So I slept on this last night (albeit not very much with a 2 week old newborn baby boy who doesn't quite fancy sleep like I do), and I thought it might help to point out the following:
1. I'm not so much interested in having a fish given to me as I am in learning how to fish. In other words, my hope is that by learning how to grab a value from another indicator, I will be in a better position to do this next time--plus, my hope is that others will come across this post in the future, and they, too, will become fisherman instead of fish mongers.
2. I intuitively know how to do this, as I already have called the EMA indicator into my indicator. To pull in the EMA, I used the following code:
So I know generally that to call another indicator, I need to know the correct overloads (in the case of the EMA, evidently it just has one overload variable called "int period"). So that leads me to my next clue.
3. The anaSuperTrendU11 appears to have the following required inputs: anaSuperTrendU11(int basePeriod, double multiplier, int rangePeriod, bool reverseIntraBar, anaSuperTrendBaseType thisBaseType, anaSuperTrendU11OffsetType thisOffsetType, anaSuperTrendU11VolaType thisRangeType) (+1 overload).
Therefore, because I was trying to plug the BoolSeries value into a list, I first created the list in my variables section:
I then dumped the BoolSeries value into the list by doing this:
I then printed the result to an output window using this:
And lo and behold, she works.
So cool, I'm that much closer to being a fisherman.
Hopefully this post will help others. I guess the most important thing to realize when you are trying to grab the values from another indicator for use in your own indicator is to remember the following:
1. Open up the indicator that you are interested in pulling values from, and find the value that you are interested in. In my case I was interested in "upTrend".
2. Then go to the Properties section in that indicator, and see what the public name for the value would be. Please note, I have learned that variables used within an indicator begin with a lowercase or _ (ie, "upTrend" or "_UpTrend") and public variables begin with a capital letter (ie, "UpTrend"). Therefore, find the capital letter variable (this is the one that you will type into your program, in my case it was "UpTrend") and make sure that the lower case version of this variable matches up with the value you want (in my case I was looking for the value stored in "upTrend", so this was the correct variable).
3. Note what type the public variable is within the Properties section. In my case, the anaSuperTrendU11's Properties for "UpTrend" was:
Therefore, I knew that the value that "UpTrend" (the public variable) was going to return to my program was going to be of type Bool (ie, true or false).
4. Now jump back to your program and go to the line where you are interested in grabbing the other indicator's value. Now just type in the name of the indicator with a single "(". In my case, I just typed in "anaSuperTrendU11(" and that should pop up the inputs that .NET is looking for on the indicator that you are interested in. In my case, I noted what these were in the top half of this post (item #3 where I discussed overloads). Grab a pencil and a piece of paper, and jot these down, because these will be important.
The most important things to note here, is what inputs have a simple type (i.e., "int", "bool", "double", "etc) and what inputs require an indicator specific type that is defined in the indicator you are trying to pull from (i.e., "anaSuperTrendU11BaseType").
On the "simple" input types, you'll just have to type a number (for the type int and double inputs) or a simple true or false for the type bool inputs.
On the indicator specific inputs, you'll have to type in the whole indicator type followed by a dot and then the indicator input that you are interested in. Which leads me to my next step.
5. If you have indicator specific inputs that are required, now you need to go back to the indicator that you are trying to pull values from, and note the type names and the type inputs (ie, "anaSuperTrendU11BaseType.Median"). This is where you would change the indicator's inputs to alternative types defined in the indicator. In the case of anaSuperTrend, @FatTails had created multiple options for customization with BaseType, OffsetType and VolaType. You would find what is available to you by scrolling down in the indicator you are interested in pulling values from and noting what you can choose from. So in the case of BaseType on the anaSuperTrendU11 indicator, Fat Tails is a freaking all star and he gave us the option to chose from:
Like I said, Fat Tails is an all star.
So in any event, just note what you want. So if you were interested in using the LLMA value in your indicator, you would type in "anaSuperTrendU11BaseType.LLMA".
The most important thing to note here on our fisherman quest is to realize that you need to type in the indicator specific type followed by a period and then the type.
6. So now that you know what .NET is looking for, start typing in each required indicator input followed by a comma. Each time you type in a comma, you should notice that the little helper window will advance to the next input. When you get to the last input, close it with a ")".
7. Now before you leave this line, you have some more work to do. Remember when I had you go to the Properties section and find out the public variable name (ie, the variable name with a capital letter, which in my case was "UpTrend")? Now you're going to use this to actually pull the value into your program by typing a period and then the public variable name--and if you are interested in the current bar's value you would type a "" or if you were interested in the previous bar's value you would type a "", etc. So in my case, the whole line looked like this:
8. So that is how you get the value from another indicator into your indicator. What you elect to do with this value is up to you. In my case, I dropped the value into a list so that I could access the value later for back testing. But you might want to store this value into another variable that you are using in your program to make a calculation or a logic decision or whatever. But at this point, you will have a value from the other indicator that is of the type specified in the Properties section (in my case, "UpTrend" was of type BoolSeries, so the value was either a "true" or "false").
I'm starting to learn that coding is like fishing: you need a lot of patience and a few sandwiches, but you can generally catch a fish.
The following 8 users say Thank You to aventeren for this post:
I'm trying to figure out how to add a condition to a strategy using the anaSuperTrend. Sometimes, the trend lines are breached but the market won't stay on that side of the trend line that was breached.
Example: Stop line is at 93. Market closes above 93 so the trend flips to long. However, the market doesn't stay above 93 so it was a false trend change signal.
I'd like to add a condition in my strategy to reference the previous stop line and tell it to ignore signals if it doesn't stay above for a long or below for a short.
There is a single plot that represents the stop line, and that stop line can be
- either above price (stop for short position)
- or below price (stop for long position)
If you want to reference the previous stopline you can access it via anaSuperTrendU11.StopDot. Now, if you wish to ignore signals when the trend has changed, then you can use the BoolSeries anaSuperTrendU11.UpTrend, which holds the value "true" for an uptrend and "false" for a downtrend.
The condition (anaSuperTrendU11.UpTrend == true && anaSuperTrendU11.UpTrend = false) stands for a trend change from downtrend to uptrend. Accordingly the condition (anaSuperTrendU11.UpTrend == false && anaSuperTrendU11.UpTrend = true) represents a trend change from uptrend to downtrend.
The following 3 users say Thank You to Fat Tails for this post:
So, if I understand this correctly, anaSuperTrendU11.StopDot would tell NT that you're referencing the previous value of anaSuperTrendu11, regardless of how many bars have passed since that value occurred?
Thank you, FatTails
The following user says Thank You to bstzgr for this post:
I'd like to make sure I understand you correctly. I want to write a condition in my strategy that will ignore a trend change IF there's been a false signal.
Let's say the trend line is at 93. The market closes at 93.01 and the trend flips to long. Over the next few bars, price drifts back below 93 and stays there. It was a false signal. I am not interested in attempting to go long until the market is back above 93, the previous trend line.
I've added these lines as conditions. The top one shows that the trend is long. The second one (from what I understand) shows that the previous trend line is below the close of this bar.
I'm coding an entry which trades in the direction of the trend. When there's a false trend change on anasupertrend, I do not want to trade in that direction. In a long situation, if the market doesn't stay above the previous trend line then it's a false signal. What's the best way for me to accomplish this? I thought I'd just need the value of the previous trend line but I don't know how to get that.
I've attached an example chart.
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).