PureBytes Links
Trading Reference Links
|
Alfredo wrote:
> I need to compute the amount I paid for a stock at market.
> So, when I get an entry signal I write:
>
> Value1 = DollarstoShares(Cash);
> Buy Value1 Contracts at market;
> Cash = Cash - (Value1*@EntryPrice(1));
>
> and when I get an exit signal I write:
>
> exitlong at market;
> Cash = Cash +(CurrentContracts*@ExitPrice(1));
I never use any of the built-in position functions (currentcontracts,
entryprice, exitprice, marketposition, etc). The problem is that they
don't update until the bar after the position is filled. And systems
only update on the close of the bar. So, in the example above, on daily
data, you could get
Monday - issue the market order
Tuesday open - fill the order
Wednesday close - the position functions update
Better to code your own vars to keep track of that stuff. You can use
"open tomorrow" for backtesting but it obviously won't work realtime as
you don't know what the open tomorrow will be.
Sorry, no more time today. I'm long the emini and feeling the heat. :-)
--
Dennis
|