priceClose() - How to use actual bar close in live trading?

Posted By: MaskOfZorro

priceClose() - How to use actual bar close in live trading? - 04/27/17 07:34

priceClose() used in a TMF returns the last tick, but my backtests are using 1-minute bar data, not tick data.

This means when trading live, if I have a trading rule like if(crossUnder(Price,low)) ... where vars Price = series(priceClose()) and low is some threshold, it's triggering trades on the tick at any time, whereas in the backtest it's only triggering trades if the closing price of the 1m bar meets the criterion. This creates a big discrepancy between what the live trading is doing and what the backtesst is doing, no?

How do I replicate the backtest way in live trading? i.e., I want this rule to trigger only on the actual close of the bar if that price has crossed the threhold. i want it to work on bar data, not tick data.
Posted By: jcl

Re: priceClose() - How to use actual bar close in live trading? - 04/27/17 12:10

If you use the price of the current tick in a TMF, you must indeed backtest with T1 data. But if you use only the close of the current bar, M1 data is sufficient - at least I would not know a reason of a "discrepancy".
Posted By: MaskOfZorro

Re: priceClose() - How to use actual bar close in live trading? - 04/27/17 14:24

Originally Posted By: jcl
If you use the price of the current tick in a TMF, you must indeed backtest with T1 data. But if you use only the close of the current bar, M1 data is sufficient - at least I would not know a reason of a "discrepancy".


But how do I get the close of the current bar in live trading? It's a price feed coming through metatrader and it's changing tick-by-tick. How do I do this M1? priceClose() gives me the latest price and it's giving trade signals mid-bar - I don't want that. e.g. If the close at 15:00 is below the theshold and the close at 15:01 above, then enter the trade. I don't want trades going off in the middle of the bar at the exact tick that the crossover happens - I want to wait until the close of the bar and if it's still over, trade - if it's slipped back under, don't.
Posted By: jcl

Re: priceClose() - How to use actual bar close in live trading? - 04/27/17 16:50

priceClose() is no feed from metatrader, but simply the close price of the recent bar. You won't enter trades in the middle of a bar unless you do that intentionally, for instance by using a TMF or entry limit.
© 2024 lite-C Forums