Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Quick Question about Stops & Targets

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

    Quick Question about Stops & Targets

    Okay, this question may sound obvious but I'm starting out with Ninja...

    I'm trying to put in profit target and stop loss. For some reason they won't work. To learn about how they work I took out all exit strategies and (on the last page of the wizard) all I did was add setprofit target to 5 ticks and setstoploss to 5 ticks (to see if I could get it to work) and it doesn't, all trades exit on the close.

    So, do I have to somehow tag each entry with a stop? I was under the assumption that the stop/target page would attach each target and stop with an entry?

    Thanks

    #2
    Hello Canuck,

    You can optionally tie profit target or stop losses to a specific entry signal. If no "From Entry Signal" is specified then they will apply to all entries.

    You say that orders are exiting on close and this is a property you can set when running the strategy. It's available under Order Handling settings when starting the strategy.

    Verify that this is set to false and let us know if it doesn't correct the issue.

    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hi Ryan,

      Thanks for the quick reply...sorry, i had to edit this post as I was looking at something else...

      i am using from entry point .... from what I can see this strategy doesn't execute my stops at all (i pulled up a chart and they don't add up) - unless 5 ticks means something different, because I'm looking at moves of 30 ticks - it seems to go from long to short without "stops" or "targets"

      protected override void Initialize()
      {
      Add(MACD(12, 26, 9));
      Add(MACD(12, 26, 9));
      SetProfitTarget("8", CalculationMode.Ticks, 0);
      SetStopLoss("5", CalculationMode.Ticks, 0, true);

      CalculateOnBarClose = true;
      }

      /// <summary>
      /// Called on each bar update event (incoming tick)
      /// </summary>
      protected override void OnBarUpdate()
      {
      // Condition set 1
      if (MACD(12, 26, 9)[0] > MACD(12, 26, 9).Avg[0]
      && Close[0] > SMA(20)[0])
      {
      EnterLong(DefaultQuantity, "");
      }

      // Condition set 2
      if (MACD(12, 26, 9)[0] < MACD(12, 26, 9).Avg[0]
      && Close[0] < SMA(20)[0])
      {
      EnterShort(DefaultQuantity, "");
      }




      }
      Last edited by canuck; 06-08-2010, 11:45 AM.

      Comment


        #4
        Thanks for sharing that code. It seems you are swapping the string name with the number of ticks. Your stop losses and profit targets are set to 0 in the code snippet you shared.

        If creating this with the wizard:
        Clear out From Entry Signal.
        Set Value to 8 for profit target and 5 for stop loss.

        Your code should then look like:
        SetProfitTarget("", CalculationMode.Ticks, 8);
        SetStopLoss(
        "", CalculationMode.Ticks, 5, false);

        http://www.ninjatrader-support.com/H...rdScreens.html
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          perfect, that's exactly the problem, I had the value in the wrong spot

          thanks a lot!!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by DawnTreader, 05-08-2024, 05:58 PM
          23 responses
          86 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by DustyContrer, Today, 04:02 AM
          0 responses
          3 views
          0 likes
          Last Post DustyContrer  
          Started by ETFVoyageur, Today, 02:15 AM
          0 responses
          11 views
          0 likes
          Last Post ETFVoyageur  
          Started by Board game geek, Today, 01:34 AM
          0 responses
          145 views
          0 likes
          Last Post Board game geek  
          Started by morrnel, 05-12-2024, 06:07 PM
          3 responses
          45 views
          0 likes
          Last Post wzgy0920  
          Working...
          X