Peeking script
Author: robesz
Creation Date: 8/29/2010 1:24 PM
profile picture

robesz

#1
I brought ATRStop into GapFiller script but unfortunately then script starts looks into the future. How to convert to avoid it?

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

Eugene

#2
It peeked from the very beginning. You can't use a series i.e. triggerLong/Short which is calculated based on the closing price, to buy at open of the same bar. Change bar to bar+1 everywhere including the exits. (To avoid going index out of bounds, make sure that the bar is less than Bars.Count-1). Check Programming Trading Strategies > Peeking > Order of Trading Signals in the WealthScript Programming Guide: your stop order should preface the AtLimit order.
profile picture

robesz

#3
Thx Eugene, after your suggestion script now works as intended (I hope).

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

Cone

#4
There are still problems:

1. You need to process your exits in this order: AtMarket, AtStop, and finally AtLimit. See the Programming Guide: Programming Trading Strategies > Peeking > Order of Trading Signals

2. The script looks ahead a bar to the next Opening price, i.e., Open[bar+1], and while that's acceptable in backtesting because it can be traded [with difficulty], you have to make adjustments to your script so that it does not cause an error when processing the last bar of the chart. However, for sure you cannot compare Open[bar+1] to triggerLong[bar+1] because the latter is based on the Close DataSeries, which you can't possibly know until the Close of the following day.

On the other hand, sure, you can compare today's Open to another DataSeries based on Closing prices. If this is what you intended, then you should write Open[bar] <= triggerLong[bar].

Note! Eugene's bar +1 comments apply to trading signals, not DataSeries. In general, you should never try to access a DataSeries on bar + 1.
profile picture

robesz

#5
Thanks Cone

Now everything is clear
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).