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

KAMA cross strategy

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

    KAMA cross strategy

    I'm trying to create my first strategy. The ides is to use 2 different KAMA's crossing, but I'm having a problem. I put one KAMA w/ fast set to 2 (red) on my chart and one w/ fast set to 4 (black).
    KAMA Cross (3 Range) 1_11_2016.jpg
    I then tried to create a strategy that would put an up or down arrow when one KAMA crosses the other and play a different sound for each. I keep getting an error message that says: " The name 'Y' does not exist in the C" Code CS0103 Line 47 Column 67.

    What am I doing wrong? Thanks.
    Attached Files

    #2
    The Summary says:

    ///<summary>
    /// Called on each bar update event (incoming tick)
    ///</summary>
    protectedoverridevoid OnBarUpdate()
    {
    // Condition set 1
    if (CrossAbove(KAMA(2, 10, 30), KAMA(4, 10, 30), 1))
    {
    DrawArrowUp(
    "My up arrow" + CurrentBar, true, 0, 5, Color.DarkGreen);
    PlaySound(
    @"C:\Program Files (x86)\NinjaTrader 7\sounds\Alert1.wav");
    }
    // Condition set 2
    if (CrossBelow(KAMA(2, 10, 30), KAMA(4, 10, 30), 1))
    {
    DrawArrowDown(
    "My down arrow" + CurrentBar, false, 0, 4, Color.Crimson);
    PlaySound(
    @"C:\Program Files (x86)\NinjaTrader 7\sounds\Alert4.wav");

    Comment


      #3
      Trader Thor,
      Thanks for your post.

      Can you try to replace your above code with:

      Code:
      protected override void OnBarUpdate()
      {
      // Condition set 1
      if (CrossAbove(KAMA(2, 10, 30), KAMA(4, 10, 30), 1))
      {
      DrawArrowUp("My up arrow" + CurrentBar, false, 0, Low[0], Color.DarkGreen);
      PlaySound("Alert1.wav");
      }
      // Condition set 2
      if (CrossBelow(KAMA(2, 10, 30), KAMA(4, 10, 30), 1))
      {
      DrawArrowDown("My down arrow" + CurrentBar, false, 0, High[0], Color.Crimson);
      PlaySound("Alert4.wav");
      }
      }
      I've changed the path of the sound alert and the prices of your arrows to High[0].
      Bobby Y.NinjaTrader Customer Service

      Comment


        #4
        The problem was I needed to select an indicator to attach the arrow to in the "Y" field.

        Comment


          #5
          // Condition set 1
          if (CrossAbove(KAMA(2, 10, 30), KAMA(4, 10, 30), 1))
          {
          DrawArrowUp(
          "My up arrow" + CurrentBar, true, 0, KAMA(2, 10, 30)[0] + -10 * TickSize, Color.DarkGreen);
          PlaySound(
          @"C:\Program Files (x86)\NinjaTrader 7\sounds\Alert1.wav");
          }
          // Condition set 2
          if (CrossBelow(KAMA(2, 10, 30), KAMA(4, 10, 30), 1))
          {
          DrawArrowDown(
          "My down arrow" + CurrentBar, true, 0, KAMA(2, 10, 30)[0] + 10 * TickSize, Color.Crimson);
          PlaySound(
          @"C:\Program Files (x86)\NinjaTrader 7\sounds\Alert4.wav");

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by trilliantrader, Today, 03:01 PM
          2 responses
          17 views
          0 likes
          Last Post helpwanted  
          Started by ScottWalsh, Today, 06:52 PM
          2 responses
          16 views
          0 likes
          Last Post ScottWalsh  
          Started by cre8able, Today, 07:24 PM
          0 responses
          1 view
          0 likes
          Last Post cre8able  
          Started by Haiasi, Today, 06:53 PM
          1 response
          4 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by ScottW, Today, 06:09 PM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Working...
          X