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 Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          566 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          330 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          547 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          548 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X