Plotting an indicator that includes a benchmark symbol
Author: mikesblack
Creation Date: 1/19/2016 9:46 PM
profile picture

mikesblack

#1
Hi I am unable to have the following code create a chart that includes a new symbol which was calculated. I called this (indicatot)r as seen below. Can you help me solve this?

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

Cone

#2
You declared "Bars Benchhmark;" but didn't do anything with it. It's just a Bars object with 0 bars and nothing else either.

Re:
DataSeries newMax = newMax(Benchmark.Close, 25);

First, Benchmark is not defined anywhere. Previously you had declared "Benchhmark".. note the spelling difference!

Second, you declared newMax to be a DataSeries (DataSeries newMax) but in the same statement you're trying to call newMax as a function, i.e., newMax(Benchmark.Close, 25);

What is the "newMax()" method call suppose to do with an empty Bars object and the integer parameter 25? And where is this function defined?
profile picture

mikesblack

#3
Thanks Cone,

I'll need to work through it. Do you have any resources or hints that can help me? If you are unclear about what I wish to do, please let me explain.

I want to create an indicator based off of an external symbol. // This is the Bearx fund.
Then add an indicator, newMax(c, 25) to that external symbol.
Next =>
Take the avgFriClose indicator that is based off of the symbol selected, and multiply that value with the value above.// newMax( Bearx C, 25)
That is called indicator.
indicator = avgFriClose(JPM C, 5) * newMax( Bearx C, 25)
Next=> Plot indicator


Ultimately I wish to build a trading system around this.
Thanks for your time.
profile picture

Eugene

#4
As it's a popular question I'm sure you'll find plenty of pointers. Just last week I answered a similar query.

+ GetExternalSymbol in the QuickRef
+ WealthScript Programming Guide > DataSeries > Accessing Secondary Symbols
+ downloadable strategies inside WLP's "Intermarket" folder
+ External Symbol with Indicator - re: operations with external symbol's data
+ many examples by prefixing your Google search query with "site:wealth-lab.com" e.g. GetExternalSymbol
profile picture

mikesblack

#5
Eugene Great ideas. Thanks!

Look below. When I add lines
CODE:
Please log in to see this code.
none of the charts show up; however if I comment these lines and replace Benchmark.Close with Close, I'll get both charts to show, but ONLY for the symbol selected. What I wish to do eventually is as I described in the last post is to plot the two indicators multiplied together. For now, I wish to plot the avgFri indicator for JPM and the NewMax for Bearx.
I'll look at the references you posted.

Thanks,
Mike

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

Eugene

#6
None of the examples instructs to use GetExternalSymbol in a class level variable. If examples sparsely use class level variables in general, this must be for a purpose. Don't use class level variables in WealthScript strategies unless you really know what you're doing. This affects system behavior. You don't want that happening in your particular case:

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

mikesblack

#7
Eugene, Ill start with the materials you suggested. Seems I need time to become familiar with what seems like an easy task. I'm frustrated feeling stuck.
Have you put on record the extent of help you will supply. E.g writing code. This will help me formulate the question I pose in the future. You guys are a good resource and hope not to become to become a nuisance.
profile picture

Eugene

#8
Okay here you go. Hope this quick example helps you become familiar with external symbols, their DataSeries, etc.:

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

mikesblack

#9
Thanks Eugene,

That is very helpful. I appreciate your help with this example.. I have committed my time to read through the weathlab script manual. It will take a bit of time,but so far I am beginning to understand the material. I realize it will take time working through examples, but clearly this is what I should have done years ago when starting to work with the program. Now with a solid base of understanding from my C# classes, the material makes much more sense. Let me know by p.m. if you feel I am asking for too much help. I would like to cooperate with you guys and contribute to this forums in the future.

Mike
profile picture

Eugene

#10
In a duplicate thread that directly resulted from this topic and for that reason has been deleted, mikesblack asked:


Hi Eugene,

Following my "NewMaxBearx-AvgFriClose, I added trading rules. Unfortunately the system does not work. When you have a chance, will you look at my code below to help get this system to work?

Thanks,
Mike



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

mikesblack

#11
Code revision compiles, runs , plots the indicator "ind" = avgFriClase * newMax; but produces no trades. Why?

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

Eugene

#12
QUOTE:
but produces no trades. Why?

Carefully review how your trading logic is aligned with regard to the curly braces. The placement is wrong.


QUOTE:
Unfortunately the system does not work. When you have a chance, will you look at my code below to help get this system to work?

Neither troubleshooting custom code nor system modifications or free tutorship are a part of the support deal. So that a technician's attention isn't monopolized when assisting with custom code, asking thoughtful questions and providing detailed error reports is a sign that the user makes some real effort. For your future reference, here's how.

As "doesn't work" just doesn't work for us, this mind-opening reading should help see things from a technician's perspective: How to Report Bugs Effectively > "It doesn't work". If there's an error, notice what the Editor's message frame or Debug window is telling you. Don't hesitate to look that error up in MSDN. Chances are you'll get it solved; otherwise you provide technicians something to work with. In relevant cases it makes sense to specify such details as single symbol or multi-symbol mode, position sizing, data loading settings, symbol(s) and data provider etc.
profile picture

mikesblack

#13
Thanks Eugene. I understand , appreciate your response and your needs. Thank you for the link and information about reporting bugs effectively. I expect that in time you will see proper etiquette and proper communications from me. In addition, I will curtail questions to only those that are relevant as per examples from other users on this forum. I shouldn't have expected you or Robert to provide extra tutoring. My apologies for crossing that line with the last few posts. As I am on break for a while from school( we have decided to move to Portland and temporally taking time off until we become established ), I have dedicated a great deal of time to learning Wealth Lab and testing ideas I had not had the opportunity to test as I was fully committed to my school work. My over zealousness perhaps made me somewhat careless about the kind of help you or Cone should provide me.

Thank you for your feedback regarding the logic as it pertains to the placement of curly braces. In addition thank you guys for the services you provide. Wealth Lab is an awesome tool and is even more amazing than when I started many years ago.

profile picture

Eugene

#14
Re: curly braces. I meant to say that the whole logic, buy and sell, goes inside the IsLastPositionActive block - leaving no chance for a buy. Hope this helps.
profile picture

mikesblack

#15
Thank you very much for that Eugene. I'm sure it will.
profile picture

mikesblack

#16
I used an example from the drag and drop to use to help me with this. Intuitively it makes sense; however applying this code on a single symbol or an index produces no buys or sells; however it compiles without error and plots the indicators. I hope that I understand your suggestion. Am I on track?

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

Eugene

#17
No, you're not. Error is not fixed: the entire logic is still locked inside the IsLastPositionActive block. You'll find details about this and "single position strategy template", which is a cornerstone of strategy creation, in the WealthScript Guide and QuickRef. Carefully compare the structure of your code with every other single-position code that is known to work until you're through with it.
profile picture

mikesblack

#18
Thanks Eugene, I actually just met with my C# professor over coffee and asked her about it. I now understand that the if(IsLastPositionActive) should only include the sell signal and not the buy signal. That is as simple as placing one more curly brace after the sell condition. The program is now producing trades. We'll see if it makes money ;). Thanks again for your feedback and for going above and beyond. That is very much appreciated. Lot's to learn, which will take time, but I am excited to learn all the new features of Wealth Lab. Hope you have a great week.

BTW , we just accepted a counter offer from the seller and should be closing on our new house in just a couple of weeks. Lots of exciting but busy times ahead for us..
profile picture

Eugene

#19
Glad you've found it.

Good luck with the move!
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).