Combining indicators to make a new indicator
Author: WEALTHPRO25
Creation Date: 1/7/2016 9:51 PM
profile picture

WEALTHPRO25

#1
dear eugene,

can you please get me started on a code where i can combine upper and lower bollinger bands with vix, put/call ratio and rsi numbers, i want to able to multiply and divide these three indicators to come up with a new indicator. thank you for your help.
profile picture

Eugene

#2
Here's something to get you started:

1. Video tutorial on combining different Indicators on a chart. This is an easy way to create an indicator of an indicator.
2. Then you could "Push all indicators... into Strategy code" button to see how things fit together.
3. As addition, division etc. are not supported, check out a howto in the WealthScript Programming Guide > DataSeries > Series Operators: "How to: Multiply, Divide, Add, or Subtract a DataSeries by another".

Feel free to ask followup questions.
profile picture

WEALTHPRO25

#3
i went through the tutorial, read the wealth script programing guide, but i got as far as the code for lower bollinger band,
CODE:
Please log in to see this code.


now i want to take the lower bollinger band and divide by the cboe put/call ratio TOTALPC, multiply by roc of vix, divide by roc of up/down volume indicator

it would be great help if you can give me a sample code than i can start modifying it, thanks

profile picture

Eugene

#4
You have a lot to learn but there's no shortage of pointers and examples on the forums and in the guides:

1. On how to refer to the TOTALPC, check out:

+ GetExternalSymbol in the QuickRef
+ DataSeries > Accessing Secondary Symbols in the WealthScript Programming Guide
+ downloadable strategies inside WLP's "Intermarket" folder

2. ROC of VIX:

+ GetExternalSymbol
+ WealthScript Programming Guide > DataSeries > Series Operators: "How to: Multiply, Divide, Add, or Subtract a DataSeries by another".
+ External Symbol with Indicator

3. ROC of Up/Down Volume:

+ WealthScript Programming Guide > DataSeries > Series Operators: "How to: Multiply, Divide, Add, or Subtract a DataSeries by another".
profile picture

WEALTHPRO25

#5
i was able to get the external symbol for totalpc and roc of vix, however i am still having trouble with how to multiply, divide, add or subtract a data series by another data series and another symbol please help i looked at the welath script programming guide but nothing works an example for each would be greatly appreciated
profile picture

Eugene

#6
Show a brief piece of your code that you're having trouble with.
profile picture

WEALTHPRO25

#7
CODE:
Please log in to see this code.



please forgive my inexperience
profile picture

Eugene

#8
Inexperience is not incurable.

1. You can not just copy/paste blocks of code from different sources and expect them to work. Placement of everything past the Wiki sample code for BBandLower2 is wrong. This has to go inside Execute(). I strongly recommend you learn C# 101 if you want to make progress with this custom indicator project:

How do I start with C# ?

2. You haven't defined rocvix, rocupRatio and TOTALPC despite post #5.

3. The usage of square brackets in this place and in this manner won't work.

4. It's not possible to reference the BBandLower type as simply "BBandLower". First you have to define it (for example, see how it's done for "udRatio" in your code) or refer to it as BBandLower.Series(some parameters). Another illustration in the QuickRef > DataSeries Object.
profile picture

WEALTHPRO25

#9
CODE:
Please log in to see this code.


i have tried to divide bollinger band lower with updown ratio to get a volatility line, please help
profile picture

Eugene

#10
Sorry but shuffling blocks of code without real understanding won't work. Programming is not a cut & paste job. Don't try to solve all problems at once. Approach them one by one: syntax, external symbols, math ops, etc.

Despite stating the opposite, you don't show any attempts to learn and practice the external symbols although I was giving you advice on this subject earlier this year.

Concentrate on C# 101 in the FAQ, then go through the pointers above. This should keep you busy for some days or even a couple of weeks but it's a must if you wish to build custom indicators. When I see you're making real progress (vs. random moves), I know you're ready to move further.
profile picture

WEALTHPRO25

#11
i will do all the items you have requested, i have been able to get external symbols and plot them on the chart, if only one time you can give me an example of just one item that is division of bollinger lower band with up/down ratio and plot this line, i have always been able to learn better with examples, i can review all the material you have suggested and correlate it with the example code you would provide, thanks
profile picture

Eugene

#12
Your example will be a D.I.Y. excercise this time:

1. Take the Up/Down Volume Ratio sample code from the original thread

2. Where applicable, insert this definition of BBandLower:
CODE:
Please log in to see this code.

Hint: Placement may vary - just not inside the for loop.

Optionally you can plot it for better visibility as suggested in the online manual for BBandLower.

3. With the QuickRef and WealthScript Programming Guide chapters on DataSeries open, insert this definition where applicable:
CODE:
Please log in to see this code.

Of course this has to be placed after both series have been defined and calculated.

To visualize the series you may insert this bit where applicable:
CODE:
Please log in to see this code.


The challenge here is to get everything in its place and without any errors. Please feel free to ask me followup questions as soon as you're able to get excercise bit working correctly. Until then, good luck with your study!
profile picture

WEALTHPRO25

#13
thank you i got it, it compiles as seen below,but how do i get this indicator to be on the chart of the stock, for example when we click on the moving average indicator it draws on the chart of the stock not separately above the chart.

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

Eugene

#14
See PricePane in the QuickRef.
profile picture

WEALTHPRO25

#15
got it, can you please give me the code to convert bars to dataseries, thanks
profile picture

WEALTHPRO25

#16
CODE:
Please log in to see this code.


this code does not allow for bars from external symbol vix and totalpc to be multiplied with bbl
profile picture

Eugene

#17
QUOTE:
this code does not allow for bars from external symbol vix and totalpc to be multiplied with bbl

This is because you're trying to skip studying C# 101 for real. Follow links in the Wiki FAQ to learn about curly braces and what effect they have on the visibility of variable. Once done, fix syntax and grammar errors.

QUOTE:
got it, can you please give me the code to convert bars to dataseries, thanks

Scrutinize the example for "Method 1" in WS Programming Guide > DataSeries > Accessing Secondary Symbols > "How to: Access DataSeries of Secondary Symbols".
profile picture

WEALTHPRO25

#18
ok i reviews and did my homework as you requested now i have the following code but the value of my indicator is zero what do i need to change in the code if i multiply bbl and updown ration i get the correct data but when i multiply vix and totalpc i get zero

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

Eugene

#19
CODE:
Please log in to see this code.

That only gets you a pair of brand new spanking DataSeries initialized with zeroes. What does one get when multiplying by zero?
profile picture

WEALTHPRO25

#20
then what should be the code
profile picture

WEALTHPRO25

#21
ok i got vix go work but how do i get totalpc to work, need help with the code

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

WEALTHPRO25

#22
now i was able to compile but i got an error when i tried to chart

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

WEALTHPRO25

#23
i got it to work

now is it possible to incorporate from index options new high minus new low, percent above 50 sma of .spx and percent above 200 of nyse into the above code multiplying the lower bollinger band
profile picture

Eugene

#24
Nice to see you've made good progress!

With your new knowledge, incorporating an index from Index-Lab is not different from the work that you've already done. An index is just another external symbol. So you can refer to it, for example, as:
CODE:
Please log in to see this code.

Where "%NHMNL_DOW_30" refers to the actual symbol name of your index and "Index-Lab Daily" to the IL DataSet name where it can be found.

Multiplying the index symbol's "close price" by Lower BB boils down to something like this:
CODE:
Please log in to see this code.
profile picture

WEALTHPRO25

#25
i have placed the following code
CODE:
Please log in to see this code.

and i keep getting the following error DataSereis could not be found, eventhought i have updnvolratio in my indexlab, please help
profile picture

Eugene

#26
Fix syntax errors. There's no such thing as "DataSereis".
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).