Switzerland
Experience: Intermediate
Platform: Tradestation, Python
Trading: Forex
Posts: 12 since Aug 2014
Thanks Given: 2
Thanks Received: 1
|
Can someone please tell me why am I not geting any print in the output window of the following command:
if (Position.MarketPosition == MarketPosition.Long && entryOrder != null)
Print(entryOrder.AvgFillPrice.ToString());
this is the whole context:
protected override void Initialize()
{
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Submit an entry limit order if we currently don't have an entry order open
if (entryOrder == null && CurrentDayOHL().CurrentOpen[0] > PriorDayOHLC().PriorHigh[0] && ToTime(Time[0]) > ToTime(8, 30, 0) && ToTime(Time[0]) < ToTime(8, 46, 0))
{
/* The entryOrder object will take on a unique ID from our EnterLong()
that we can use later for order identification purposes in the OnOrderUpdate() method. */
entryOrder = EnterLong(1, "MyEntry");
}
/* If we have a long position and the current price is 4 ticks in profit, raise the stop-loss order to breakeven.
We use (7 * (TickSize / 2)) to denote 4 ticks because of potential precision issues with doubles. Under certain
conditions (4 * TickSize) could end up being 3.9999 instead of 4 if the TickSize was 1. Using our method of determining
4 ticks helps cope with the precision issue if it does arise. */
if (Position.MarketPosition == MarketPosition.Long && entryOrder != null)
Print(entryOrder.AvgFillPrice.ToString());
if (Position.MarketPosition == MarketPosition.Long && entryOrder !=null && (Close[0] >= entryOrder.AvgFillPrice + (80 * (TickSize / 2))))
{
// Checks to see if our Stop Order has been submitted already
if (stopOrder != null && stopOrder.StopPrice < entryOrder.AvgFillPrice)
{
// Modifies stop-loss to breakeven
stopOrder = ExitLongStop(0, true, stopOrder.Quantity, entryOrder.AvgFillPrice, "MyStop", "MyEntry");
}
}
}
|