TRenko screener
Author: Rebelion
Creation Date: 11/11/2012 9:34 AM
profile picture

Rebelion

#1
Sorry, guys, I'm a newbie in Wealth-Lab and not a guru in the programming.

I have same troubles with TRenko.
What's the mechanism of TRenko object updating? Do I need to recreate TRenko object each time I get new bar (minute bar for example)? How should I store Alerts I have in the Strategy Monitor and on the Chart?
Thnxs a lot.

Best regards,
Dmitriy.
profile picture

Cone

#2
QUOTE:
What's the mechanism of TRenko object updating?
It should be instantiated each the time the script executes. For an example, see strategy: Renko Basic [Rev A]

Re: recreate
The script is executed once each time a new bar is received (or if you press Go or F5).

Re: Alerts
Alerts are not "stored". They represent action on a bar that is in the future and not available in the chart. You must be talking about something else?
profile picture

Rebelion

#3
No, I meant that should I recreate TRenko object I created at first Executive() method run? Does this class consist the same mechanism of automatically updating or not?
About Alerts. If I'm not mistaken each time I recreate TRenko object all Alerts are erased. But if I use trading loop instead of using Bars.Count-1 bar (in the screener system) I get no Alerts in the Strategy Monitor when I run my strategy with the same parameters in the Streaming mode (I get signals on the chart, but no signals on the Strategy Monitor Alerts subwindow). In the time I use last bar with recreating TRenko object I have alerts I got from the system mystically dissapear each time I've got new renko column...
What should I do for working right with TRenko in the Screener mode?

Thnxs.
profile picture

Cone

#4
I don't know what you mean about the auto updating. Each time chart data are loaded, the Execute() method is called. In an intraday streaming window and in the Strategy Monitor, the same thing happens except that a new bar is added to the data each interval. Each run essentially starts fresh with no memory of the previous run; data are reloaded and the strategy recalculates.

In a quick test here, I see the same results (7 alerts on 11/12/2012 for the Nasdaq 100, Daily data) in the Strategy Window as in the Strategy Monitor using the Renko Basic Rev A strategy. I don't see how it's possible to get different results if the data and parameters are the same, but if you provide more details about your test, I'll take a look.

Alerts are expected to disappear if the strategy does not generate them for the most-recent bar. Again, I'm not sure if your idea of an Alert is the same as ours. Please provide a specific example. If you don't want to show your strategy, demonstrate the problem with the Renko Basic Rev A strategy. Specify the symbol, interval, date range, and paramenters used.
profile picture

Rebelion

#5
I use this dummy code I wrote based on Renko Basic [Rev A]

CODE:
Please log in to see this code.


(I specially mark the part "StreamingStrategyRun() unreacheable in this example.
I have signals on the Chart Window, but no signals in the Strategy Monitor (in the Streaming mode using Finam Data provider).

When I make StreamingStrategyRun() reacheable (by changing "true" on "!IsStreaming" in the code above) and use streaming data, I get signals in the Strategy Monitor, but not in the Chart Window. And after the same time signals I got mystically dissapear from the Strategy Monitor.

A little remark - I use MSVS for debugging code. May it be connected with this fact?

Other general questions (sorry, guys, but I strongly need to make myself well-informed in this question, because my first strategies will be based on Renko) - what's the mechanism of Renko object updating? Does I strongly need to recreate Renko object each time I get new minute bar (I work with minute data) and Execute() method runs? Is the same time created Renko object a static object or Renko has an own internal mechanism of updating each time next bar come? If I recreate Alerts, does all Alerts I've already got gonna be erased? And I strongly need to run trading loop again for get it back.

Sorry for my stupid questions and my bad English too. :( I'm just a newbie...
profile picture

Eugene

#6
Please use CODE tags when posting code.
profile picture

Rebelion

#7
Little comment - I use Renko Basic [Rev A] through Finam Data Provider (without any changes) and got the same result - no signals in the Strategy Monitor, just in the Chart Window...

Update.
Renko Basic [Rev A] generates signals in the Strategy Monitor, but after the same time they dissapears... Why?..
profile picture

Eugene

#8
Be careful with class-level variables. Unless it's made on purpose, it's a good practice to define variables inside the Execute method body and leave the ctor for CreateParameter calls alone.
profile picture

Cone

#9
QUOTE:
..generates signals in the Strategy Monitor, but after the same time they dissapears... Why?..
Alerts disappear when the strategy no longer generates a signal, simple as that.

Now let's go for the errors in your script:

1. StreamingStrategyRun: int bar = Bars.Count - 1;
This is fine for a screener, but IsLastPositionActive will never be true because the script will never create a position (you're not processing any history to do so). It can only generate an alert.

2. BacktestingStrategyRun: for (int bar = startBarPosition; bar < Bars.Count - 1; bar++)
If you stop on the second to last bar, properly formed signals like SellAtMarket(bar + 1, LastPosition); can never create an Alert since you're not processing the last bar. The for loop must run to bar < Bars.Count;

Here are three errors, for example in your BacktestingStrategyRun:

3. Even if you fixed #2, the following malformed statements cannot generate Alerts:
SellAtLimit(bar, LastPosition, Close[bar] - priceLagValue);
ShortAtLimit(bar, Close[bar] - priceLagValue);
ShortAtLimit(bar, Close[bar] - priceLagValue);

These statuements are the definition of "peeking". Always pass bar + 1 to Market, Stop, or Limit orders (unless you're intentionally trying to prove some non-causal theory).

Finally, although it's considered "legal" to execute AtClose orders on the current bar, these too will never generate an Alert. For more, see the wealthScript Programming Guide > Programming Trading Strategies > Alerts > How to: Alert for AtClose Signals.
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).