Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Position.AvgPrice

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Position.AvgPrice

    Greets,

    I am trying to 'capture' the price of the entry, when the order is placed, for further use.

    Code:
    [FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]private[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]double[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#000000] MyEnterP125 = [/COLOR][/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#000000];[/COLOR][/FONT]
     
    [FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]protected[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]override[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]void[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] OnBarUpdate()[/FONT]
    [FONT=Arial]{ sThisPrice.Set(Position.AvgPrice);[/FONT]
     
    [FONT=Arial][FONT=Arial]{ [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]if[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] ( (Position.MarketPosition == MarketPosition.Flat) && (timeSeries[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]] >= [/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]) )[/FONT]
    [FONT=Arial][COLOR=#008000][FONT=Arial][COLOR=#008000]// Try to go LONG[/COLOR][/FONT]
    [/COLOR][/FONT][FONT=Arial]{ [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]if[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] ( WatchToGoLong == [/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]1 )[/COLOR][/FONT]
    [/COLOR][/FONT].................
    [FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]if[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] ((iOrderL5 == [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]null[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] || Historical) && iQuantity5 != [/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial])[/FONT]
    [FONT=Arial]{ iOrderL5 = EnterLong([/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial], iQuantity5, sENTRY5L);[/FONT]
    [FONT=Arial]MyEnterP125 = sThisPrice[[/FONT][FONT=Arial][COLOR=#800080][FONT=Arial][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]];[/FONT]
    [FONT=Arial]Print([/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]"Entry Price PT125 "[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]+MyEnterP125);[/FONT]
    [FONT=Arial]}[/FONT]
     
    [/FONT]
    I also had tried

    MyEnterP125 = Position.AvgPrice;

    (without using the DataSeries.Set etc) ... everything compiles but I only get '0'
    (as in MyEnterP125 = 0; ) at the print during the strategy run on whatever attempt that does compile ...

    Obviously missing something ...

    Any assist is appreciated!

    Thanks,
    Jon
    Last edited by Trader.Jon; 03-21-2011, 01:52 AM.

    #2
    Your brackets look funny. Are you sure that you have posted the correct code?

    Comment


      #3
      MyEnterP125 = Position.AvgPrice
      This instruction is correct, but you cannot execute it in OnBarUpdate()
      immediately after executing an Enter..().
      You can place it in OnExecution() or query it on the next bar.

      Baruch

      Comment


        #4
        Originally posted by koganam View Post
        Your brackets look funny. Are you sure that you have posted the correct code?
        I only posted the relevant portions for clarity and not all the brackets were carried forward.

        Thanks for the feedback.

        Jon

        Comment


          #5
          Originally posted by Baruch View Post
          This instruction is correct, but you cannot execute it in OnBarUpdate()
          immediately after executing an Enter..().
          You can place it in OnExecution() or query it on the next bar.

          Baruch
          Baruch,

          Thanks, I will give that a try.

          Jon

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          56 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          143 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          160 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          96 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          276 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Working...
          X