• 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
            Hi pplowman,

            I've got a few examples that I've had to make corrections to.
            Attached Files
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              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.)
              Attached Files
              Last edited by NinjaTrader_ChelseaB; 09-12-2018, 10:01 AM.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                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


                  #9
                  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 timcjpfx, Today, 06:22 AM
                  2 responses
                  11 views
                  0 likes
                  Last Post timcjpfx  
                  Started by welson, Today, 08:26 AM
                  2 responses
                  10 views
                  0 likes
                  Last Post NinjaTrader_PatrickG  
                  Started by brucerobinson, Today, 08:27 AM
                  2 responses
                  6 views
                  0 likes
                  Last Post brucerobinson  
                  Started by Leeroy_Jenkins, Today, 07:45 AM
                  1 response
                  7 views
                  0 likes
                  Last Post NinjaTrader_PaulH  
                  Started by 1001111, 02-22-2020, 09:10 AM
                  5 responses
                  38 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Working...
                  X