Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

strategy for alerts not execution

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

    strategy for alerts not execution

    I have created a strategy that sends me alerts when conditions occur, but does not execute trades. If three conditions occur within 6 bars ( originally 4, but increased to make testing easier) Ninja is supposed to email me, make noise, and change the color on the alerts window,

    It does not seem to be working. It is a little hard to test because "test on historical data" only seems to count trades.

    Here is a snip of the code.

    -------

    CalculateOnBarClose = false;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (CrossAbove(Ergodic(3, 5, 14).Main, MyInput0, 6)
    && CrossAbove(DM(14).DiPlus, DM(14).DiMinus, 6)
    && CrossAbove(WoodiesCCI(2, 5, 14, 34, 25, 6, 60, 100, 2), MyInput0, 6))
    {
    Alert("MyAlert0", Priority.High, "Triple cross Bull has occured", "", 0, Color.Lime, Color.Black);
    SendMail("[email protected]", "[email protected], [email protected]", "ES bull triple cross", "Bullish ES triple cross has occured");
    PlaySound(@"C:\Program Files (x86)\NinjaTrader 7\sounds\newuptrend.wav");
    }

    // Condition set 2
    if (CrossBelow(Ergodic(3, 5, 14).Main, MyInput0, 6)
    && CrossBelow(DM(14).DiMinus, DM(14).DiPlus, 6)
    && CrossBelow(WoodiesCCI(2, 5, 14, 34, 25, 6, 60, 100, 2), MyInput0, 6))
    {
    SendMail("[email protected]", "[email protected], [email protected]", "ES Bear triple cross", "Bearish ES triple cross has occured");
    Alert("MyAlert26", Priority.High, "Bearish ES triple cross", "", 0, Color.Firebrick, Color.Black);
    PlaySound(@"C:\Program Files (x86)\NinjaTrader 7\sounds\newdowntrend.wav");
    }




    }


    If anyone can see why it is not working please let me know. Yes it is enabled.
    Also, If knew how to distinguish between a 90 degree cross over and a 4 degree one I might use this strategy for execution. But I don't. So I am setting it to alert me so I can look at the chart.

    Anyway, any help is appreciated. Thank you

    #2
    I do not see any reason that would not work based off the simple syntax alone.

    I would suggest putting Print() statements in your conditions to debug that these are in fact true in any point on historical data.

    The Alert/SendMail functions are only going to work on real-time data. To test these, I'd suggest running on Market Replay or connecting to the Simulated Data Feed which would allow you to test these conditions.
    MatthewNinjaTrader Product Management

    Comment


      #3
      Is this telling us anything. I tried restarting ninja and my computer. Made a small change in the script. It is still not working. Is there a log for the script Thanks


      4/9/2013 2:58:20 PM|1|2|Time to flatten=12:00:00 AM, Flatten all=Disabled
      4/9/2013 2:58:33 PM|1|2|Global simulation mode disabled
      4/9/2013 2:58:33 PM|1|4|Order entry hot keys disabled
      4/9/2013 2:58:33 PM|1|2|Optimized CPU performance enabled
      4/9/2013 2:58:33 PM|1|4|Automated trading disabled
      4/9/2013 3:01:59 PM|1|128|Enabling NinjaScript strategy 'AlertSTrat/0bac795c09d241559c66d96d1cad30cf' : On starting a real-time strategy - StrategySync=WaitUntilFlat SyncAccountPosition=False EntryHandling=AllEntries EntriesPerDirection=1 StopTargetHandling=PerEntryExecution ErrorHandling=StopStrategyCancelOrdersClosePositio ns ExitOnClose=True/ triggering 30 before close Set order quantity by=Strategy ConnectionLossHandling=KeepRunning DisconnectDelaySeconds=10 CancelEntryOrdersOnDisable=False CancelExitOrdersOnDisable=True CalculateOnBarClose=False MaxRestarts=4 in 5 minutes

      Comment


        #4
        I do not see any errors there and trust that the strategy is starting correctly.

        Were you able to Print the conditions historically to see if the were ever satisfied?

        What I mean by that, is if you added the folllowing to condtion1

        Code:
        // Condition set 1
        if (CrossAbove(Ergodic(3, 5, 14).Main, MyInput0, 6)
        && CrossAbove(DM(14).DiPlus, DM(14).DiMinus, 6)
        && CrossAbove(WoodiesCCI(2, 5, 14, 34, 25, 6, 60, 100, 2), MyInput0, 6))
        {
          Print(Time[0] + " Condition 1 is true");
        }
        You should get output to the Tools--> Output window when that condition was true.

        If that does not produce anything, you'd need to simply the statement to determine what is preventing that from working
        MatthewNinjaTrader Product Management

        Comment


          #5
          Hi

          The print command did not really work correctly. Back printed results for the last 2 days and then stopped on yesterday market open.

          In any event. I just rewrote the script with a new name. It works fine

          I have no idea what happened. But this seems like a simpler solution

          Thanks for your help

          Comment


            #6
            I'm glad to hear that it is working for you now. Please let us know if you see further instances of this.
            MatthewNinjaTrader Product Management

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            661 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            375 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            110 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            574 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            580 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X