TradeBarClose with LifeTime

Posted By: Zheka

TradeBarClose with LifeTime - 06/05/22 15:26

This code:
Code
...LifeTime=3;  if (tod()==1300) enterShort();..
will generate this log :
[5237: Fri 22-06-03 13:00] (1.07165)
[EUR/USD::S23753] Short 1@1.07165 x at 13:00:00

[5238: Fri 22-06-03 13:30] 11.16 -1.31 59/49 (1.07295)
[5239: Fri 22-06-03 14:00] 9.65 -2.82 59/49 (1.07445)
[5240: Fri 22-06-03 14:30] 11.04 -1.43 59/49 (1.07305)

[EUR/USD::S23753] Expired 1@1.07305: -1.44 at 15:00:00

[5241: Fri 22-06-03 15:00] 11.03 0 59/49 (1.07230)
..

Exit happens at 1430 at the closing price of 1.07305 of bar 5240.... Yet, TradeBarClose is 5241 for this trade.

Posted By: Zheka

Re: TradeBarClose with LifeTime - 06/05/22 16:01

In addition, the TradePriceClose is different from the 'ask' even when all costs are set to 0.

[5237: Fri 22-06-03 13:00] 1.07320/1.07395\1.07040/1.07165 -0.0
[EUR/USD::S23753] Short 1@1.07165 x Bid 1.07165 at 13:00:00 (local 09:00)
Com 0000 Mrg 0.54 Net 0

[5238: Fri 22-06-03 13:30] 11.16 -1.31 59/49 1.07165/1.07385\1.07145/1.07295 -0.0
[5239: Fri 22-06-03 14:00] 9.65 -2.82 59/49 1.07295/1.07520\1.07250/1.07445 -0.0
[5240: Fri 22-06-03 14:30] 11.04 -1.43 59/49 1.07445/1.07485\1.07300/1.07305 -0.0

[EUR/USD::S23753] Expired 1@1.07305: -1.44 at 15:00:00
Opn 1.07165 Cls 1.07309 Spr 0.0 Slp 0.00 Rol 0.00 Com -0.00 Lif 4 Net -1

[5241: Fri 22-06-03 15:00] 11.03 0 59/49 1.07305/1.07365\1.07155/1.07230 -0.0

This is not related to LifeTime and happens similarly for Longs and Shorts, i.e. TradePriceClose>bar close price regardless of direction.
Posted By: Zheka

Re: TradeBarClose with LifeTime - 06/05/22 16:10

When Spread is set:

[5237: Fri 22-06-03 13:00] 1.07320/1.07395\1.07040/1.07165 -0.00004
[EUR/USD::S23753] Short 1@1.07165 x Bid 1.07161 at 13:00:00 (local 09:00)
Com 0.0536 Mrg 0.54 Net 0

[5238: Fri 22-06-03 13:30] 1.11 -1.40 58/50 1.07165/1.07385\1.07145/1.07295 -0.00004
[5239: Fri 22-06-03 14:00] -0.40 -2.91 58/50 1.07295/1.07520\1.07250/1.07445 -0.00004
[5240: Fri 22-06-03 14:30] 0.99 -1.52 58/50 1.07445/1.07485\1.07300/1.07305 -0.00004

[EUR/USD::S23753] Expired 1@1.07305: -1.53 at 15:00:00
Opn 1.07165 Cls 1.07309 Spr 0.00004 Slp 0.00 Rol 0.00 Com 0.05 Lif 4 Net -1

[5241: Fri 22-06-03 15:00] 0.98 0 58/50 1.07305/1.07365\1.07155/1.07230 -0.00004

TradeClosePrice is bigger than the 'Ask' price.
Posted By: Petra

Re: TradeBarClose with LifeTime - 06/06/22 07:31

2 hopefully helpful pieces of info:

- Short trades close at the ask, not the bid. So your setting spread to whatever value cannot have an effect.

- Lifetime lets the trade exit at next open, not at current close. So you were probably comparing the wrong prices.

Still, I cannot see how that exit price comes together, unless that was live. Then ask the broker. Otherwise, if you think something is wrong with it, contact support with the script and data for reproducing it, and we'll help.

And finally please post topics to the suited forum. This makes life easier. Questions go in the starting forum, bug reports in the bugs forum, neither of them belongs in the future forum.
Posted By: Zheka

Re: TradeBarClose with LifeTime - 06/06/22 09:41

I mentioned "even when costs are set to 0" just to say that Spread is forced to 0, and it could not have been somehow 'mistakenly' used in calculating the exit price ( even if it shouldn't for short trades anyway).

The difference between TradePriceClose=1.07309 and close/open=1.07305(ask) is exactly the spread from the asset list file.
Quote
Lifetime lets the trade exit at next open, not at current close. So you were possibly comparing the wrong prices.
- Logs are exactly to avoid 'possibility' and ensure 'certainty'. But my OP was not about the price; it was about the TradeBarClose.
With LifeTime, you get:
Quote
[5240: Fri 22-06-03 14:30] 11.04 -1.43 59/49 (1.07305)

[EUR/USD::S23753] Expired 1@1.07305: -1.44 at 15:00:00 < -in live, it will exit at 1430+...but TradeBarClose=5241.

[5241: Fri 22-06-03 15:00] 11.03 0 59/49 (1.07230)..
With if (tod()==1430) exitShort(); you get:
Quote
[5240: Fri 22-06-03 14:30] 11.04 -1.43 59/49 (1.07305)

[EUR/USD::S23753] Expired 1@1.07305: -1.44 at 14:30:00 <- same as above.... but TradeBarClose=5240.

[5241: Fri 22-06-03 15:00] 11.03 0 59/49 (1.07230).
In reality, its exactly same moment in time ( tick at or after 1430) and the same exit price, yet 2 different treatments (in TradeBarClose).
Posted By: Zheka

Re: TradeBarClose with LifeTime - 06/06/22 17:33

I posted here because it is supposedly a place for the 'beta' versions feedback. Ok - will be more deliberate in choosing threads.

Anyhow, I found the reason for the weird trade close price to be Detrend=TRADES. All ok with prices.

This leaves then the OP and the post above related to TradeBarClose with LifeTime.
© 2024 lite-C Forums