• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

PriceOs.cs expecting ","

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

    PriceOs.cs expecting ","

    {
    EnterShort(Convert.ToInt32(DefaultQuantity), "");


    If (Position.MarketPosition == MarketPosition.Long)
    {
    SetStopLoss(CalculationMode.Price, Low[2] - Ticksize);
    }

    Error expecting "," after If (Position.MarketPosition == MarketPosition.Long)

    Any thoughts?

    #2
    Hello pplowman,

    Are you using a capital I on the if statement?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      That was it! Thanks !!

      How do you reset SetStopLoss when MarketPosition.Flat?

      Comment


        #4
        Hello pplowman,

        When using Set methods, these cannot be unset. This means it is important to set these before you place an entry order.

        Alternatively, use an Exit method instead of a Set method.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Could you send some sample code by chance?

          Comment


            #6
            Hello Community,

            I've had to make changes to these scripts once again.

            With NinjaTrader 8, order objects returned from an order method may not be an equal object to the order object for the same order in OnOrderUpdate.

            From the help guide:
            // Assign entryOrder in OnOrderUpdate() to ensure the assignment occurs when expected.
            // This is more reliable than assigning Order objects in OnBarUpdate, as the assignment is not guaranteed to be complete if it is referenced immediately after submitting.

            Below is a publicly available link to the help guide.
            https://ninjatrader.com/support/help...rderupdate.htm

            This is especially noticeable in Market Replay.

            The NinjaTrader 7 versions can be found in the post linked below.
            https://ninjatrader.com/support/foru...604#post478604

            (Update Sept 12, 2018: Small change to ProfitChaseStopTrailUnmanagedExample logic cancelling stop and target to start flat. Changes to all three with prints.)

            (Update April 16, 2020: Changed initial target placement price to use ProfitTargetDistance instead of hard coded 10)
            Attached Files
            Last edited by NinjaTrader_ChelseaB; 04-16-2020, 12:03 PM.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              I am learning from these examples. thanks

              Question: whats the benefits and drawbacks for using the SET methods vs ExitOrders in the context of trailing stops ?

              Comment


                #8
                Hello dadarara,

                Ease of use.

                Set methods you can set before the script starts and not have to code for them.

                With exit methods you would need to write the code of when to submit them and if wanted design trailing logic.
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by mtamaku, Today, 06:54 PM
                0 responses
                7 views
                0 likes
                Last Post mtamaku
                by mtamaku
                 
                Started by Lumbeezl, Today, 06:32 PM
                0 responses
                4 views
                0 likes
                Last Post Lumbeezl  
                Started by ozziyhtomit, Today, 05:24 PM
                0 responses
                3 views
                0 likes
                Last Post ozziyhtomit  
                Started by AnotherWorkingHomeless, Today, 08:45 AM
                0 responses
                20 views
                0 likes
                Last Post AnotherWorkingHomeless  
                Started by RumHam, 07-02-2020, 12:14 PM
                2 responses
                36 views
                0 likes
                Last Post smtraderca  
                Working...
                X