• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

probleme with SMA 5 bars ago

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

    probleme with SMA 5 bars ago

    Hi,

    in an Indicator in 70 Tick, I need SMA, 5 bars ago :

    if ((SMA(50)[5] > SMA(100)[5])
    && (SMA(100)[5] > SMA(200)[5]))
    {
    PlaySound(@"C:\Program Files\NinjaTrader 7\sounds\Alert4.wav");
    }
    dont made sound Alert4

    BUT this next works perfectly in 0 Bars ago and ma
    if ((SMA(50)[0] > SMA(100)[0])
    && (SMA(100)[0] > SMA(200)[0]))
    {
    PlaySound(@"C:\Program Files\NinjaTrader 7\sounds\Alert4.wav");
    }
    give the Alert4 sound

    Where is the difference ?
    What can I do to use SMA (X) in 5 bars ago

    Thanks in Help

    #2
    Hello,

    If you are not first checking how many bars are loaded before checking a barsago value you will get an error.

    Try adding this above the statement you provided:

    if(CurrentBar < 5) return;

    This prevents the script from running until you have 5 bars loaded, then it can look back 5 bars.

    Please let me know if I may be of additional assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      oups, it is obvious
      i am so sorry

      thanks

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by bosajin, Yesterday, 06:27 PM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_Jim  
      Started by stefanrvc, Today, 04:59 AM
      1 response
      14 views
      0 likes
      Last Post NinjaTrader_Marco  
      Started by 7robert, Yesterday, 08:30 PM
      2 responses
      16 views
      0 likes
      Last Post NinjaTrader_Marco  
      Started by pjsmith, Today, 01:13 AM
      1 response
      16 views
      0 likes
      Last Post NinjaTrader_ChrisSch  
      Started by yukashg, Yesterday, 09:56 PM
      1 response
      16 views
      0 likes
      Last Post NinjaTrader_ChrisSch  
      Working...
      X