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

trigger as indicator goes from rise to fall

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

    trigger as indicator goes from rise to fall

    hi support,
    working on a strategy that will enter a trade when :

    1st condtion . two indicators are both oversold,
    2nd condition. a third indicator (lin reg) going from falling to rising.
    i would like the strategy to enter a long trade position ..

    thus far, my strategy will place a symbol on the chart when my two oversold conditions are met using the 'conditions and actions' of strategy wizard on set 1,,

    support, can you say how i go about setting my 2nd condition up on the strategy wizard ?
    in the condition builder, i put lin reg on the left, kept the == and chose rising on the right column, but get a 'boolean' error ?

    can i put the 2nd condition on set 1 as well or do i need to put it on the following set 2. ?

    #2
    Hi lightfoot500,

    Thanks for your post.

    If all the conditions must be met for the trade to take place, all the condition must be in the same conditional in the Strategy Wizard.

    So add this to condition 1.

    Attached is a screenshot of how to check for the LineReg to be rising.
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chelsea,
      is there a way to enter the trade [with in so many bars after] the 1st condition has been met. ?
      that is, so that all conditions dont have to be simultaneous to enter a trade,
      rather just after the first overcondition is met, and then the 2nd condition is met.?
      thanks

      Comment


        #4
        Hello lightfoot500,

        This would not be achievable with the Strategy Wizard and would need to be coded by hand.

        The wizard is not able to save the value of CurrentBar or increment a value. These are the two ways I can think of that would allow you to track the state of things in a number of bars.


        If you were to unlock the code for editing, you could save CurrentBar to a variable for each condition set when the condition is true, then as a bar closes check that all of the variables are greater than CurrentBar - n (however many bars the conditions need to be true in).

        For example:
        int barsAgoC1 = 0;
        int barsAgoC2 = 0;
        int barsAgoC3 = 0;
        int n = 10; // this is the amount of bars all conditions need to be true in.

        protected override void OnBarUpdate()
        {
        if (/* condition 1 is met */)
        {
        barsAgoC1 = CurrentBar;
        }
        if (/* condition 2 is met */)
        {
        barsAgoC2 = CurrentBar;
        }
        if (/* condition 3 is met */)
        {
        barsAgoC3 = CurrentBar;
        }

        if (barsAgoC1 > CurrentBar - n &&& barsAgoC2 > CurrentBar - n && barsAgoC3 > CurrentBar - n)
        {
        // execute trade
        }
        }
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thanks Chelsea,
          in lieu of that, i would like to replace the lin reg indicator with the signal period line of an MACD. but when i input the macd, i am not sure that i am getting the signal period line or the fast period or slow period. is there a way to select just the signal period line. ?

          Comment


            #6
            Hello lightfoot500,

            The MACD has 3 plots. The macd, the Avg, and the Diff. I think you are wanting the macd plot.

            The macd plot uses the following math:
            ((2.0 / (1 + Fast)) * Input[0] + (1 - (2.0 / (1 + Fast))) * fastEma[1]) - ((2.0 / (1 + Slow)) * Input[0] + (1 - (2.0 / (1 + Slow))) * slowEma[1])

            The Avg line uses the following math using the smoothing:
            (2.0 / (1 + Smooth)) * macd + (1 - (2.0 / (1 + Smooth))) * Avg[one bar ago]

            Neither of these lines is quite the slow or the fast.

            Again, I think you are wanting to choose the macd plot.

            Attached is a screenshot of how to choose the plot in the Rising input series parameters.
            Attached Files
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by RaddiFX, Today, 10:15 AM
            2 responses
            13 views
            0 likes
            Last Post RaddiFX
            by RaddiFX
             
            Started by patrickmlee007, Today, 09:33 AM
            2 responses
            17 views
            0 likes
            Last Post patrickmlee007  
            Started by magnatauren, 08-15-2020, 02:12 PM
            5 responses
            206 views
            0 likes
            Last Post RaddiFX
            by RaddiFX
             
            Started by rene69851, 05-02-2024, 03:25 PM
            1 response
            22 views
            0 likes
            Last Post rene69851  
            Started by ETFVoyageur, Yesterday, 07:05 PM
            5 responses
            45 views
            0 likes
            Last Post ETFVoyageur  
            Working...
            X