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

            As a heads up, these scripts are just examples. Each approach has different aspects and limitations and may place orders at different times. These scripts are not designed to perfectly produce the same results. Instead, these are educational examples designed to show how one would move a stop and limit order with custom logic.

            (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; 07-22-2020, 09:52 AM.
            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 bootize, Today, 08:37 AM
                0 responses
                4 views
                0 likes
                Last Post bootize
                by bootize
                 
                Started by _Zero_, 01-06-2020, 01:16 PM
                4 responses
                138 views
                2 likes
                Last Post globaljobber  
                Started by sukhob, Yesterday, 04:27 PM
                1 response
                20 views
                0 likes
                Last Post zacharydw00  
                Started by zacharydw00, Yesterday, 05:36 PM
                0 responses
                6 views
                0 likes
                Last Post zacharydw00  
                Started by podowitz, Yesterday, 04:18 PM
                1 response
                7 views
                0 likes
                Last Post NinjaTrader_ShawnB  
                Working...
                X