Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

indicator current bar

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

    indicator current bar

    Hello,

    I have added me an alert to my strategy. But when I do enable the datafeed or my strategy then I can hear the soundmessage even when the condition was true already few bars ago. I have (Historical) return;

    What can one do please so that the alert is done with the one bar (close of the bar with COBC=false) and only one time when the condition is true eg high[0]>SMA&&Low[0]<SMA and not later when datafeed or strategy is enabled.

    I have

    Alert("XY", NinjaTrader.Cbi.Priority.High, "XY", _alertSoundFile_XY, 300, Color.Black, Color. Yellow);

    I couldn´t find in the help guide what to add to the code.

    Thank you
    Tony
    Last edited by tonynt; 12-08-2014, 03:39 AM. Reason: translation error

    #2
    Can you post your actual code here, tonynt?

    Thanks.
    Pi
    ninZa
    NinjaTrader Ecosystem Vendor - ninZa.co

    Comment


      #3
      Hi Tony, I would not expect Alert to be called historically - do you work this condition by chance in FirstTickOfBar?
      BertrandNinjaTrader Customer Service

      Comment


        #4
        Hello,

        thank you for your replies.

        Sorry, I have COBC=true in my strategy.

        In my region Sounds I have

        if ((Rising(SMA(20)) && High[0]>=SMA(20)[0] && Low[0]<SMA(20)[0])
        Alert("R_HMA", NinjaTrader.Cbi.Priority.High, "R_HMA", _alertSoundFile_R_MA, 10, Color.Black, Color.Yellow);

        When enabling the strategies I hear all alerts even when condition is not true. And then I hear the alert approx. every minute. But the alert should be only one time after close of the bar the condition is true. (I hear the alert now from time to time even when condition was true 1 hour ago.)

        Than you!
        Tony
        Last edited by tonynt; 12-08-2014, 05:23 AM. Reason: clarifying

        Comment


          #5
          Originally posted by tonynt View Post
          Hello,

          thank you for your replies.

          Sorry, I have COBC=true in my strategy.

          In my region Sounds I have

          if ((Rising(SMA(20)) && High[0]>=SMA(20)[0] && Low[0]<SMA(20)[0])
          Alert("R_HMA", NinjaTrader.Cbi.Priority.High, "R_HMA", _alertSoundFile_R_MA, 10, Color.Black, Color.Yellow);

          When enabling the strategies I hear all alerts even when condition is not true. And then I hear the alert approx. every minute. But the alert should be only one time after close of the bar the condition is true. (I hear the alert now from time to time even when condition was true 1 hour ago.)

          Than you!
          Tony
          Thanks. So you have COBC = true, but alerts are triggered approximately every minute.
          What timeframe are you applying the strategy on?

          Try replacing Alert() function with Playsound() function. Just give it a try.

          Thanks.
          Pi
          ninZa
          NinjaTrader Ecosystem Vendor - ninZa.co

          Comment


            #6
            Thanks for the assist ninZa.

            Tony, please add a print as well in to see exactly when your condition would fire -

            if ((Rising(SMA(20)) && High[0]>=SMA(20)[0] && Low[0]<SMA(20)[0])

            This could be definitely true for a couple of bars and would not only trigger the alert on the first bar this setup occurred.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Thank you for your replies.

              I use 5RangeChart. Have replaced Alert with Playsound, but the same, and sound was already the 2 bars before with Low [0] is not < SAM20[0] (dashed line).
              Also cyan coloring should not be with:

              if((Rising(SMA(20)) == true)
              && High[0]>=SMA(20)[0] && Low[0]<SMA(20)[0])
              {PlaySound(_alertSoundFile_R_MA);
              BackColorAll=Color.Cyan;}



              Thanks
              Tony
              Attached Files
              Last edited by tonynt; 12-08-2014, 08:27 AM. Reason: clarifying

              Comment


                #8
                Originally posted by tonynt View Post
                Thank you for your replies.

                I use 5RangeChart. Have replaced Alert with Playsound, but the same, and sound was already the 2 bars before with Low [0] is not < SAM20[0] (dashed line).
                Also cyan coloring should not be with:

                if((Rising(SMA(20)) == true)
                && High[0]>=SMA(20)[0] && Low[0]<SMA(20)[0])
                {PlaySound(_alertSoundFile_R_MA);
                BackColorAll=Color.Cyan;}



                Thanks
                Tony
                It sounds very weird. Could you please post your strategy file (.cs)?

                Thanks,
                Pi
                ninZa
                NinjaTrader Ecosystem Vendor - ninZa.co

                Comment


                  #9
                  Tony, which market would that be exactly and which provider (for your sample chart)? I let the condition run on the 6E 12-14 here and see scenarios where it's true consecutive bars on the range chart, however always 'around' the SMA 20 value (as expected).
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    Hello,

                    thank you for your reply. Yes, it is weird. I have made script strategies - as non programmer - even with customized buttons and with this ridiculous issue hanging round for days.

                    I thank you for your offer, but the strategy has more than 1000 lines, can not post it here. In onbarupdate with if historical return I have a region with sounds and only the few lines as posted above and background is colored cyan even when low[0] is not below SMA20.

                    I have made same as an indicator and there it works.

                    If you want to know why I´d like it in a strategy - the reason is that it should only do the sound when I have activated the strategy (means when I expect instruments in a direction). With indicator it would be activated all the time and with 30 forexpairs there would be a concert of sounds all day long if I wouldnt filter out;-)

                    Thanks for your response.

                    Best regards
                    Tony




                    Originally posted by ninZa View Post
                    It sounds very weird. Could you please post your strategy file (.cs)?

                    Thanks,
                    Pi

                    Comment


                      #11
                      Originally posted by tonynt View Post
                      Hello,

                      thank you for your reply. Yes, it is weird. I have made script strategies - as non programmer - even with customized buttons and with this ridiculous issue hanging round for days.

                      I thank you for your offer, but the strategy has more than 1000 lines, can not post it here. In onbarupdate with if historical return I have a region with sounds and only the few lines as posted above and background is colored cyan even when low[0] is not below SMA20.

                      I have made same as an indicator and there it works.

                      If you want to know why I´d like it in a strategy - the reason is that it should only do the sound when I have activated the strategy (means when I expect instruments in a direction). With indicator it would be activated all the time and with 30 forexpairs there would be a concert of sounds all day long if I wouldnt filter out;-)

                      Thanks for your response.

                      Best regards
                      Tony
                      So it works properly as an indicator but does not as a strategy. Any suggestion, Bertrand?

                      I have sometimes encountered such a weird scenario. And my approach is to try building a similar indicator from scratch, adding each part of code step-by-step very slowly to see which codes cause the problem.

                      So you may have to try creating a new strategy file, adding only the condition and see if it works (I guess I will definitely work in a freshly new strategy). If it works, then other part of your current strategy code is causing a conflict or something like that.

                      double maValue = SMA(20)[0];
                      if(Rising(SMA(20)) && Low[0] < maValue && High[0] >= maValue) {
                      PlaySound(soundFile);
                      BackColorAll = Color.Cyan;
                      }
                      Thanks.
                      Pi
                      ninZa
                      NinjaTrader Ecosystem Vendor - ninZa.co

                      Comment


                        #12
                        There's no inherent reason it would be treated differently as far as the condition goes indicator vs strategy, the debug route to simplify and isolate out what's contributing would be needed.
                        BertrandNinjaTrader Customer Service

                        Comment


                          #13
                          I want to thank you for your replies. I will check out step-by-step.

                          Best regards
                          Tony

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by alifarahani, Today, 09:40 AM
                          6 responses
                          36 views
                          0 likes
                          Last Post alifarahani  
                          Started by Waxavi, Today, 02:10 AM
                          1 response
                          17 views
                          0 likes
                          Last Post NinjaTrader_LuisH  
                          Started by Kaledus, Today, 01:29 PM
                          5 responses
                          14 views
                          0 likes
                          Last Post NinjaTrader_Jesse  
                          Started by Waxavi, Today, 02:00 AM
                          1 response
                          12 views
                          0 likes
                          Last Post NinjaTrader_LuisH  
                          Started by gentlebenthebear, Today, 01:30 AM
                          3 responses
                          17 views
                          0 likes
                          Last Post NinjaTrader_Jesse  
                          Working...
                          X