Profile Picture

Bid / Ask Price

Posted By ywlee 3 Years Ago
Message
Posted Friday July 25 2014
Hi

As per an earlier post by another member, I wish to execute the buy/sell based on the bid/ask price.

Per Daniel's reply in the earlier post, it was suggested to use Bars.PartialItem.Bid and Bars.PartialItem.Ask instead of Ask.Current and Bid.Current.

However when I use this in the code, I get the "Object reference not set to an instance of an object" error.

PositionSettings ps = new PositionSettings();
ps.OrderType = OrderType.Limit;
ps.LimitPrice = Bars.PartialItem.Bid;

Thanks!
Posted Friday July 25 2014
I do not use bid/ask prices but a does your data contain bid/ask prices?
Posted Friday July 25 2014
I should have mentioned that I using it in a live trading environment which has bid/ask prices.
Posted Friday July 25 2014
Bid and Ask properties are doubles. What is null, Bars or PartialItem?

Does Bars.Current.Bid, for example, produce any values?

What live broker plugin are you using?

As a short term fix, until you or RightEdge can track down why it is null, you could try a work around. Create a _Bid and _Ask property in your script symbol class and set these properties in the symbol script’s NewTick method, e.g., if (tick.tickType == TickType.Ask) _Ask = tick.price. Then use these to set your limit price.
Posted Saturday July 26 2014
I was following the advice given by Daniel in this post:

http://www.rightedgesystems.com/forums/Topic13129-7-1.aspx?Highlight=partialitem

Broker is IB.

Thanks for the suggestion on the workaround. Will try that out.

Posted Saturday July 26 2014
Quick question:

How do you implement the NewTick method?
phg
Supreme Being (44,673 reputation)Supreme Being (44,673 reputation)Supreme Being (44,673 reputation)Supreme Being (44,673 reputation)Supreme Being (44,673 reputation)Supreme Being (44,673 reputation)Supreme Being (44,673 reputation)Supreme Being (44,673 reputation)Supreme Being (44,673 reputation)
Posted Saturday July 26 2014
In C#:
public override void NewTick(Bardata bar, TickData tick) { ... }

This is an event handler that gets called for each tick.

-Pete

See also Yahoo group about applying RE.

Posted Saturday July 26 2014
Thanks Pete!


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems