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

How to add RSI indicator in Strategy in NinjaTrader8

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

    How to add RSI indicator in Strategy in NinjaTrader8

    Dear Team!

    I want add a condition :RSI >70 to my strategy.My logic is that,if the RSI is greater than 70,short will be triggered.

    I tried this way:

    if (State == State.DataLoaded)
    {
    AddChartIndicator(RSI(14, 1));
    }


    private void SetEntrySignal()
    {
    if (CrossAbove(RSI(14, 1), 30, 1))

    {
    _enterShort = Close[0] < Open[0];
    _enterShort &= Open[0] < Low[1];
    }
    }
    I also tried this:

    private void SetEntrySignal()
    {
    if (RSI(14, 1) > 70)
    { _enterShort = Close[0] < Open[0];
    _enterShort &= Open[0] < Low[1];
    }
    }
    But this still now work.Can you show me the correct way directly,I have read the document already ,but have no idea how to solve.Thank you so much!
    Last edited by williamzz; 06-20-2019, 07:17 PM.

    #2
    Hello williamzz,

    Thank you for your post.

    It looks like you are trying to get the current value of Close[0], Open[0], and Low[1] inside your custom event method. If you need to obtain a value like Close[0] value outside of one of the core data event methods, you can use TriggerCustomEvent() to reliably synchronize the barAgo indexer to the current bar being updated. Please see the example from our help guide below:



    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Sorry,could you read my question again.now I've made it more clearly to read.What I need is adding RSI indicator to Strategy,not get the current value of Close[0], Open[0].I think TriggerCustomEvent is more complicated.I just need a logic that,if the value of the RSI is higher than 70 I will short it.So can you give me more advice .Really appreciate it!

      Comment


        #4
        Issue solved.Thanks!

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by GussJ, 03-04-2020, 03:11 PM
        16 responses
        3,279 views
        0 likes
        Last Post Leafcutter  
        Started by WHICKED, Today, 12:45 PM
        2 responses
        19 views
        0 likes
        Last Post WHICKED
        by WHICKED
         
        Started by Tim-c, Today, 02:10 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by Taddypole, Today, 02:47 PM
        0 responses
        5 views
        0 likes
        Last Post Taddypole  
        Started by chbruno, 04-24-2024, 04:10 PM
        4 responses
        51 views
        0 likes
        Last Post chbruno
        by chbruno
         
        Working...
        X