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

Alerts using a Strategy in a Chart

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

    Alerts using a Strategy in a Chart

    I have a very simple strategy that tests 2 emas and a Stochastic, and having sat and watched the output scroll past for the last couple of hours, I can see several occasions that I think it should have alerted me, but it hasn't. My guess is that been new to Ninja Script I've made a simple error, but I'm damned if I can find it. I've enclosed the code below, can anybody tell me what I've done wrong.

    Code:
           protected override void Initialize()
            {
    
                CalculateOnBarClose = false;
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
                // Condition set 1
    			Print("EMA50-"+EMA(50)[0]+"   EMA100-"+EMA(100)[0]+"   STOC-"+Stochastics(5, 3, 3).K);
                if (EMA(50)[0] > EMA(100)[0]
                    && CrossAbove(GetCurrentAsk(), EMA(50), 5)
                    && CrossAbove(Stochastics(5, 3, 3).K, 20, 5))
                {
                    Alert("MyAlert0", Priority.High, "Buy Long Signal", @"C:\Program Files (x86)\NinjaTrader 7\sounds\Alert1.wav", 5, Color.White, Color.Black);
                }
                if (EMA(50)[0] < EMA(100)[0]
                    && CrossBelow(GetCurrentBid(), EMA(50), 5)
                    && CrossBelow(Stochastics(5, 3, 3).K, 80, 5))
                {
                    Alert("MyAlert0", Priority.High, "Buy Short Signal", @"C:\Program Files (x86)\NinjaTrader 7\sounds\Alert1.wav", 5, Color.White, Color.Black);
                }
            }

    #2
    Hello,

    Thank you for the question.

    I will try and run this, could you provide details on the instrument and chart settings that this works on?

    Also can you provide a sample of the output where you see it should have been triggered?

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      I'm not at my desk anymore to provide sample output, but I was testing with 1min GBPUSD and EURUSD

      Comment


        #4
        Hello drumuk,

        Thank you for your patience.

        Do you have a sample of the Output when the alert should occur?

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by XXtrader, Yesterday, 11:30 PM
        2 responses
        11 views
        0 likes
        Last Post XXtrader  
        Started by Waxavi, Today, 02:10 AM
        0 responses
        6 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Started by TradeForge, Today, 02:09 AM
        0 responses
        11 views
        0 likes
        Last Post TradeForge  
        Started by Waxavi, Today, 02:00 AM
        0 responses
        2 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Started by elirion, Today, 01:36 AM
        0 responses
        7 views
        0 likes
        Last Post elirion
        by elirion
         
        Working...
        X