BuyAtLimit[bar] seems to BuyAtOpen
Author: kbellare
Creation Date: 6/8/2013 8:51 PM
profile picture

kbellare

#1
I'm using the foll code to simulate "same-day/mid-day" response to signals by buying/selling on the average of the bar High/Low range instead of Buying at Open[bar+1].

The strategy however opens positions at Open[bar] instead of at the Limit price of (High[bar]+Low[bar])/2. Why is that?


CODE:
Please log in to see this code.

}


thanks
Kiran
profile picture

Eugene

#2
Before anything else, you should realize that this code is bluntly peeking into the future. As in real life, you can not check for the bar's High, Low and Close price and buy on this bar. By the time you know these prices, the market has already closed. Consequently, it has to use bar+1 to stay realistic.

Now, please re-open the User Guide at Strategy Window > Backtesting Strategies > 100% of Equity Sizing, acquaint yourself with the basis price concept and find out which price is used as the basis price for entering a Limit order:

CODE:
Please log in to see this code.



P.S. Since this is the 2nd time we'll be moving your question from this forum, please post questions similar to this one in the "WealthScript" forum. "Trading Strategies" is reserved for discussing strategies as entities, their algorithms, rules, code implementation. This is not the same as how Wealth-Lab (WealthScript) operates, and there is no disclosed strategy behind your post. tia.
profile picture

Cone

#3
In case it's not clear, AtMarket, AtLimit, and AtStop orders should be executed on bar + 1, not on the current bar.

In other words, bar represents the trade interval that just completed, so it is actually in the past. You can use the information from bar (and any information prior to it) to signal a trade on the next bar, i.e., bar + 1.
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).