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

Crossabove with Offset

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

    Crossabove with Offset

    Sorry if this has been addressed but I searched and could not find the answer. I'm sure I'm missing something simple. I'm trying to set an offset to a EMA crossover. So for example I would like to place a buy order when the 3EMA crosses above the 10EMA + 1.00. The wizzard does not seem to add the offset to the code, and NT8 buys at the crossover without the offset. Any help is greatly appreciated. Thanks!


    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 1)
    return;

    // Set 1
    if (CrossAbove(EMA1, EMA2, 1))
    {
    EnterLongLimit(Convert.ToInt32(DefaultQuantity), Open[0], @"Long1");
    }

    }
    }
    }

    #2
    Hello JDcrossesover,

    Thanks for your post and welcome to the Ninjatrader forums!

    In the screenshot, the condition appears to be adding a value of 1 to the 10 period EMA.

    How are you testing this to verify that the offset is or is not being considered?

    Are you testing on a live data chart, on a chart with Playback/market replay data, or in the strategy analyzer?

    What is the strategy's calculate set to (OnBarClose, OnPriceChange, or OnEachTick)?

    What instrument, bar type and size are you testing with?

    Can you post a screenshot to illustrate what you see and what you expect?

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_PaulH View Post
      Hello JDcrossesover,
      In the screenshot, the condition appears to be adding a value of 1 to the 10 period EMA.
      Yes, that's the plan

      How are you testing this to verify that the offset is or is not being considered?
      Using a backtest in strategy analyzer

      Are you testing on a live data chart, on a chart with Playback/market replay data, or in the strategy analyzer?
      strategy analyzer

      What is the strategy's calculate set to (OnBarClose, OnPriceChange, or OnEachTick)?
      OnBarClose

      What instrument, bar type and size are you testing with?
      ES, 1Min

      Can you post a screenshot to illustrate what you see and what you expect?
      attached screenshot, as you see NT8 bought on the next bar after the crossover BUT the EMA3 was not 1.00 above the EMA10. I would have expected it to buy 7 bars later where the EMA3 crossed above the EMA10+1.00.
      Last edited by JDcrossesover; 06-22-2020, 12:54 PM.

      Comment


        #4
        Hello JDcrossesover,

        Thanks for your reply.

        I've replicated what you are doing and I do see that the Strategy builder is ignoring the offset of 1.

        I will write this up and have our QA group review which may take some time to review..

        Another alternative would be to set a bool variable that you create to be true when the cross occurs and in another set, check that the bool is true and also check that the EMA1 is Greater than the EMA2 + 1.0. You may need additional logic to prevent this from happening too many bars away from the cross event.

        Thanks in advance for your patience while we review further.

        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Thanks Paul,

          Will this thread be updated when the issue is resolved?

          JD

          Comment


            #6
            Hello JDcrossesover,

            Thanks for your reply.

            Yes, I will update this thread when information becomes available.
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Hello JDcrossesover,

              With unlocked code, CrossAbove allows comparing a Series to a Series, and also comparing a Series to a double value to create a crossover.

              With the Strategy Builder, if we make a crossover condition with 2 indicators, and we apply an offset to the indicator, it is ambiguous if we want to apply an offset to the plot value referenced (offset to double,) or to the the entire indicator (offset to Series.)

              Because this leaves an area of ambiguity, we have disabled offsets for crossover conditions to avoid hitting this area of confusion where the offsets are not applied.

              To check a crossover with an offset, we will specifically want to assign the indicator plot to a double, and then offset the double in our crossover, or we would want to create a Series<double> for the indicator and offset the values assigned to the Series<double>.

              I have attached some examples to demonstrate applying crossovers with offsets.

              We look forward to assisting.
              Attached Files
              JimNinjaTrader Customer Service

              Comment


                #8
                OK, thanks for your help.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by GussJ, 03-04-2020, 03:11 PM
                11 responses
                3,227 views
                0 likes
                Last Post xiinteractive  
                Started by andrewtrades, Today, 04:57 PM
                1 response
                13 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by chbruno, Today, 04:10 PM
                0 responses
                7 views
                0 likes
                Last Post chbruno
                by chbruno
                 
                Started by josh18955, 03-25-2023, 11:16 AM
                6 responses
                440 views
                0 likes
                Last Post Delerium  
                Started by FAQtrader, Today, 03:35 PM
                0 responses
                12 views
                0 likes
                Last Post FAQtrader  
                Working...
                X