SmartQuant Discussion

OnPosistionOpened() and orders.AvgPrice
Page 1 of 1

Author:  King0 [ Wed May 18, 2011 10:08 pm ]
Post subject:  OnPosistionOpened() and orders.AvgPrice

Thanks to Anton I almost have a working program. :) But I am having a problem accessing the fill price from my entry.
   public override void OnPositionOpened()
      if (OCAExitEnabled)
         double profitTarget = entryOrder.AvgPrice+LimitOCA;
         limitOrder = SellLimitOrder(FGBL,Qty, profitTarget, "Limit OCA " + OCACount);
         limitOrder.OCAGroup = "OCA " + Instrument.Symbol + " " + OCACount;               

         double lossTarget = entryOrder.AvgPrice+StopOCA;
         stopOrder = SellStopOrder(FGBL,Qty, lossTarget, "Stop OCA " + OCACount);
         stopOrder.OCAGroup = "OCA " + Instrument.Symbol + " " + OCACount;               

It doesn't like entryOrder.AvgPrice It's almost like it can't access that variable or is not declared for OnPositionOpened. The program gets in on a limit price. It then sets a target and a stop. The Target is 6 ticks (LimitOCA), the stop is 4 ticks (StopOCA). But it cant add/subtract those amounts from entryOrder.AvgPrice. The program compiles fine. but has a strategy error on:
double profitTarget = entryOrder.AvgPrice+LimitOCA;   

Any suggestions?

Author:  Baraz Sergey [ Fri May 20, 2011 9:54 am ]
Post subject:  Re: OnPosistionOpened() and orders.AvgPrice

The program compiles fine. but has a strategy error on:

What kind of error do you see? I guess it is NullReferenceException, if so - please make sure the entryOrder object is initialized before OnPoisitionOpened handler gets called.


Author:  King0 [ Fri May 20, 2011 6:52 pm ]
Post subject:  Re: OnPosistionOpened() and orders.AvgPrice

Thank you for your help Sergey. I tried that. But I think I narrowed the problem down to poorly captured historical data (my own fault). If I run it real time it works fine. However it may not be the captured data but a problem with the times dont match up properly on my data. i.e. the products on Eurex I go from 11pm to 1pm but the cme/cbot go from 3:30pm to 2pm

Page 1 of 1 All times are UTC + 3 hours
Powered by phpBB® Forum Software © phpBB Group