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

Trend Indicator Based on another time period

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

    Trend Indicator Based on another time period

    I am trying to use an trend filter to enter a trade.

    The primary data is a 1 minute chart and I want to use indicators and price date based on an hourly chart. I also want to ensure the following before entering a long trade (for example):

    1) Low of the current session is above 8 period SMA on the hour chart
    2) 8 period SMA on hourly chart is above 20 SMA on hourly chart

    I've tried a range of methods but keep getting the problem of not being allowed to use relationional operators with strings (error CS0019)

    Does anyone have any ideas how I might acheive my objective here?

    Many thanks

    Mark

    #2
    Mark, could you please post the code you're using? I'll take a look and see if anything looks out of place.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Austin View Post
      Mark, could you please post the code you're using? I'll take a look and see if anything looks out of place.
      Hi Austin,

      This is what i'm using first to activate the other time period;

      protected override void Initialize()
      {
      CalculateOnBarClose = true;
      Add(PeriodType.Day, 1);
      }
      Then this is one of several entry requirements

      && SMA(BarsArray[1], 8) > SMA(BarsArray[1], 20)
      It is giving me the CS0019 error when I try to compile it.

      I can't seem to find a function that would log the low of the session either, do you have any thoughts on this?

      Many thanks

      Mark

      Comment


        #4
        MJUK10, you would need to compare a double value from your series, i.e. SMA(BarsArray[1], 8)[0] > SMA(BarsArray[1], 20)[1]

        You can work with CurrentDayOHL for accessing the highs, lows of the day as defined by your session begin / end times (session template if you're working with NT7 beta).

        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by xiinteractive, 04-09-2024, 08:08 AM
        3 responses
        11 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by Johnny Santiago, 10-11-2019, 09:21 AM
        95 responses
        6,193 views
        0 likes
        Last Post xiinteractive  
        Started by Irukandji, Today, 09:34 AM
        1 response
        3 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by RubenCazorla, Today, 09:07 AM
        1 response
        5 views
        0 likes
        Last Post RubenCazorla  
        Started by TraderBCL, Today, 04:38 AM
        3 responses
        25 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X