Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Making decisions on Position Profit or Loss

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

    Making decisions on Position Profit or Loss

    I am getting error CS0019 on the code below. I am apparently trying to execute logic on
    a string. How do I convert Position.AvgPrice to something I can test value on? Do I just set a variable equal to the Position Avg Price? If so, does that have to be a DataSeries, or just a simple variable that takes on the avg profit value?
    Thanks
    DaveN


    Code:
    if(Position.MarketPosition = MarketPosition.Long
    && Close[0] < Position.AvgPrice

    #2
    Hello Daven,

    Position.AvgPrice is going to return a double value so you could use in calculations, or if you wanted to change the value of this number then you would want to set the value of Position.AvgPrice to another variable (a double) so that it can be modified.

    Here is a few links that goes over Syntax, and the AvgPrice that you may view.
    Syntax: http://www.ninjatrader.com/support/h...sic_syntax.htm
    Position.AvgPrice: http://www.ninjatrader.com/support/helpGuides/nt7/index.html?avgprice.htm


    Also here is a reference sample on using trade performance statistics that you may want to view.
    http://www.ninjatrader.com/support/f...ead.php?t=4084


    Quick note, I do see in your sample code that you are not using "==" to check to see if they are equal.
    Here is a link to our help guide on compile error code CS0019.
    http://www.ninjatrader.com/support/h...tml?cs0019.htm
    JCNinjaTrader Customer Service

    Comment


      #3
      Its the little things that nail you

      Thanks JC,
      It was the lack of the second = that caused all my issues. It is working fine now that I fixed that, thanks to your observation and references.
      DaveN

      Comment


        #4
        Hello daven,

        You are welcome, let us know if we can be of further assistance.
        JCNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by benmarkal, Yesterday, 12:52 PM
        3 responses
        22 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by helpwanted, Today, 03:06 AM
        1 response
        18 views
        0 likes
        Last Post sarafuenonly123  
        Started by Brevo, Today, 01:45 AM
        0 responses
        11 views
        0 likes
        Last Post Brevo
        by Brevo
         
        Started by aussugardefender, Today, 01:07 AM
        0 responses
        6 views
        0 likes
        Last Post aussugardefender  
        Started by pvincent, 06-23-2022, 12:53 PM
        14 responses
        244 views
        0 likes
        Last Post Nyman
        by Nyman
         
        Working...
        X