Trading few minutes before market close

Posted By: GreenBoat

Trading few minutes before market close - 04/27/17 16:21

I have a basic question about testing and life trading.

I would like to trade only once per day, every day at 15:50-15:55, 5-10 minutes before the market close.

I want to check today's Close price and if the price meets my requirements, I want to enter the trade, for the same price (+- slippage). In real trading, I would check actual price from a broker, few minutes before the market closes and then send orders. When backtesting, I don't know what was the price 5 minutes before market close (I have only daily data), but for testing purposes, I can say that it was the close price.
Posted By: GreenBoat

Re: Trading few minutes before market close - 04/29/17 08:19

I was thinking about it and I think that I can answer the question:

Zorro manual: "The strategy script is run at the end of every bar, and buy or sell commands are executed at the price of the begin of the next bar."

And BarOffset: "Bar start time offset in minutes. For daily bars, BarOffset determines the UTC minute into the day when the candle opens, and can be used to shift the bar begin to a certain local or global time."

I believe that the thing I am trying to do (trade few minutes _before_ the end of every bar, not after the bar) might work by setting the BarOffset.

Something like this (for SPY):
BarPeriod = 1440; // 1 bar is 24 hours
BarZone = ET; // SPY is located in New York
BarOffset = 15*60 + 50; // set the bar end to 15:50, 10 minutes before the market close

I think that this solves the problem with live trading, but I don't think it solves the problem with backtesting. I think that when backtesting, Zorro starts the trade at the open price of the next bar. I am going to test it. Anyway, it is probably good enough for testing and trading.
© 2024 lite-C Forums