• 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

questions from New Subscriber

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

    questions from New Subscriber

    Hi

    A couple of questions maybe osomebody can help me with:

    1) How do I determine if a price tick is the first tick of a new bar

    2) How do I move a stop loss

    3) How do I specify the no of fx mini contracts

    Thanks



    Paul



    #2
    imported post

    Paul,

    1) Seethe Help Guide FirstTickOfBar property (this is only of value when CalculateOnBarClose == false)

    2) Are you submitting a stop loss via SetStopLoss() or ExitLongStop() or ExitShortStop()

    3) Any of the Enter() or Exit() methods have an optional quantity parameter or if not passed in, you can set the quantity when adding a strategy to a chart in the strategy dialogue window.

    Ray
    RayNinjaTrader Customer Service

    Comment


      #3
      imported post

      Hi Ray



      I don't know - just looking at how to do it. Basically I want to place a market order with an initial stop loss then on the first tick of each new bar I want to move the stop loss to n pips from a moving average based level. Also if a certain other condition gets hit I want to close the position and obviously remove the stop loss. What would be the best way to implement this.



      Thanks for your help



      Paul


      Comment


        #4
        imported post

        Here is a snippet for the OnBarUpdate() method thatis an example that will do what you want.
        // This method will create a stop loss order 10 ticks from entry on incoming fill from an entry order
        if (Position.MarketPosition == MarketPosition.Flat)
        SetStopLoss(CalculationMode.Ticks, 10);

        // Go long if close is greater than 15 ticks above the 50 period SMA
        if (Close[0] > SMA(50)[0] + 15 * TickSize)
        EnterLong();

        // If long, change the stop price to 1 tick below the 50 period SMA
        if (Position.MarketPosition == MarketPosition.Long)
        SetStopLoss(CalculationMode.Price, SMA(50)[0] - TickSize);

        // Exit if close is less than 15 ticks above 50 period SMA and have been in trade 30 bars
        if (Close[0] < SMA(50)[0] + 15 * TickSize && BarsSinceEntry() >= 30)
        ExitLong();
        RayNinjaTrader Customer Service

        Comment


          #5
          imported post

          Does this then mean that a stop loss can be changed once set for a trade?

          Part of my confusion on this is that your example...

          // If long, change the stop price to 1 tick below the 50 period SMA
          if (Position.MarketPosition == MarketPosition.Long) SetStopLoss(CalculationMode.Price, SMA(50)[0] - TickSize);
          ...is obviously for use in the OnBarUpdate() method, whereas the help file description of SetStopLoss() says it "should be called from within the strategy Initialize() method."

          So, have the rules changed on this? And what happens if additional SetStopLoss() calls are made for subsequent OnBarUpdate() calls? Will each one replace the last? And can we selectively replace the stop losses by specifying a "fromEntrySignal" parameter on each SetStopLoss() call?

          Comment


            #6
            imported post

            KBJ wrote:
            Does this then mean that a stop loss can be changed once set for a trade?
            Yes.

            Part of my confusion on this is that your example...
            // If long, change the stop price to 1 tick below the 50 period SMA if (Position.MarketPosition == MarketPosition.Long) SetStopLoss(CalculationMode.Price, SMA(50)[0] - TickSize);
            ...is obviously for use in the OnBarUpdate() method, whereas the help file description of SetStopLoss() says it "should be called from within the strategy Initialize() method."
            Documentation will be updated with the next release.

            So, have the rules changed on this? And what happens if additional SetStopLoss() calls are made for subsequent OnBarUpdate() calls? Will each one replace the last?
            Correct. Because of this, it is important to add a check in OnBarUpdate() for a flat position, and then call the SetStopLoss() method again and pass in the starting offset of a stop loss price when a new position is entered, otherwise the last known offset value will be used.
            And can we selectively replace the stop losses by specifying a "fromEntrySignal" parameter on each SetStopLoss() call?
            Yes you can.
            RayNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by martyn73, Today, 05:27 PM
            0 responses
            5 views
            0 likes
            Last Post martyn73  
            Started by MichaelAlexander, 02-22-2017, 05:06 AM
            5 responses
            1,402 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by walter739, Today, 11:56 AM
            3 responses
            10 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by kevinfloresz, Today, 09:46 AM
            4 responses
            29 views
            0 likes
            Last Post kevinfloresz  
            Started by digibob, 12-13-2019, 10:01 PM
            7 responses
            20 views
            0 likes
            Last Post NinjaTrader_ChrisL  
            Working...
            X