Concerning AtClose execution price
Author: akuzn
Creation Date: 12/4/2013 9:27 PM
profile picture

akuzn

#1
Good day.


Didnt find direct answers in refs and in wiki. So pardon me if any.

Examle:
CODE:
Please log in to see this code.


2 questions only about backtesting:
1. After execution LastPosition.EntryBar is equal to bar, not bar + 1; But cosmetic triangles are on bar+1;
I was thinking that trade will be executed or not on bar+1 . In real time seems it works like this.
So why in Position entry bar is bar, not bar + 1?
2. How trade is executed if order is placed on bar+1 at the price Close? is there check of range [high.low] or it will be executed anyway at Close?

Why i am asking that - trying to tune some code and was surprised that on bar + 1 Low was 40503 and Close of previous bar was 40500 and WealthLab was long. How it can be?

Never thinking about it before because i was always using average price, but now have to do fine tuning.
profile picture

Eugene

#2
1. In real time, an Alert is to be fired on bar+1 which doesn't exist yet. In backtest mode, the bars are available.

2. Answered in the User Guide > Reference > Glossary: Basis Price. For AtClose signals, the basis price is the previous bar's close price i.e. (bar). Execution happens at the closing price of the bar of entry (bar+1), of course. There were talks to change the order of things here and take the basis price from the entry bar's close but no resolution followed.
profile picture

akuzn

#3
But in above example next bar was 3 ticks higher. That means in real time there wont be execution of such order.

Another problem for example if i use strategy monitor wich takes some seconds to act. If Close[bar] wont be in the range between [high[bar+1] and low[bar+1] the trade placed for execution on bar+1 wont be done.

if i use some average as execution price difference between this average and next bar range can be even bigger.

How to avoid this?

Is there only one way - write needed backtest code manually?
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).