da420078
 ( 55.59% )
- ago
Thanks Glitch.
I found a couple lines I had to comment out.
They perform math operations that worked in 6.9 but don't translate directly to 7.

So, let's say I wanted to multiply an indicator by a factor of 10. How would I express that in v7? (in the section that runs prior to the main trading loop)
0
1,138
Solved
13 Replies

Reply

Bookmark

Sort
- ago
#1
QUOTE:
I wanted to multiply an indicator by a factor of 10.

Go to the QuickRef guide and select "TimeSeries". Then scroll down to "operator*" for multiplication. Click on that. Now where it says sample code, click that button. And now you have your example.

But I got your point. How does one know to search for "TimeSeries" in the first place? I guess you need to read the Help guide first to know that. All indicators inherit from the TimeSeries datatype along with all its vector arithmetic operators.
1
- ago
#2
Just to add to superticker's reply. Another way to multiply an indicator is to use the MathIndOpValue indicator. It caters to Blocks users.



Its companion MathIndOpInd indicator lets them add/subtract/multiply/divide an indicator by other indicator.
1
Glitch8
 ( 10.62% )
- ago
#3
RSI rsi = RSI.Series(bars.Close, 14);
TimeSeries mult = rsi * 10;
1
da420078
 ( 55.59% )
- ago
#4
Thanks all,
superticker - yes, exactly, one has to know at the outset that "TimeSeries" is the class one needs.
Ideally, and I do understand the resource constraints, of course, a searchable index would be useful. And even better, a conversion tool.
But if the majority of the WL user base is comprised of experienced C# coders, then the cost/benefit ratio of a converter is too high.
In my case, I wasn't ready to put in the work required to do any conversions, until recently I realized the trial period was ticking down.
Also, as Eugene points out, I have found creating blocks and looking at the underlying code to be useful, although the code is far more verbose than one would use if starting from scratch in C#.
Again, Glitch, many thanks.
0
fred99998
 ( 19.71% )
- ago
#5
And such a combination is impossible? Gives an error.

0
Glitch8
 ( 10.62% )
- ago
#6
Yes, nesting these kinds of indicators is currently not possible.
1
da420078
 ( 55.59% )
- ago
#7
Hi Glitch, still not able to get this to run without an "Execute Exception" error.
I wondered if I described a scenario whether you could show me the appropriate syntax.
Sticking with your example of creating a TimeSeries called "mult", let's complicate that slightly by saying we want the RSI of an external symbol to be multiplied by 10. (Just so that I can eliminate "external symbol" as a possible cause for error).
Can you show me example syntax of how to use that new TimeSeries in an "if" statement within the main trading loop, and the syntax to declare it in the Private Variables section.
Thanks for your time and patience.
0
- ago
#8
Can you show the code throwing that exception?
0
da420078
 ( 55.59% )
- ago
#9
Eugene,
After experimenting with getting an example similar to what I want in Blocks, this is of the form that I'm looking for.
However, the underlying C# code from the Blocks example won't compile without error.
0
Glitch8
 ( 10.62% )
- ago
#10
You can't nest Transformer Indicators unfortunately, there's a limit of 1 depth with them. We might overcome this in the future but now we have to live with this limit. So, you cannot apply a MathIndOpValue to another Transformer Indicator like SymbolInd.
0
da420078
 ( 55.59% )
- ago
#11
Okay, so would it be okay to ask if you could code up the above example just so that I can see where I'm going wrong with the syntax?
Many thanks!
0
- ago
#12
I'm at a loss as to why multiply the RSI of AAPL by 100? The result will always be greater than 20.

CODE:
public class MyStrategy : UserStrategyBase {       BarHistory bh;       TimeSeries rsi;        public override void Initialize(BarHistory bars) {          bh = GetHistory(bars, "AAPL");          rsi = RSI.Series(bh.Close, 20);          rsi *= 100;          StartIndex = 20; } public override void Execute(BarHistory bars, int idx) { if (rsi[idx] > 20)
0
Best Answer
da420078
 ( 55.59% )
- ago
#13
Thanks Eugene.
It's just an example to show the required syntax.
Now I can see what to do.
Many thanks.
0

Reply

Bookmark

Sort