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

call an indicator (COBC) in Strategy (COET)

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

    call an indicator (COBC) in Strategy (COET)

    Hi, unfortunately i have not found a solution here. I have an indicator that is calculated on bar close (COBC):

    Code:
    public class SidiSuperTrend : Indicator
    {
    protected override void OnStateChange()
    {
     if (State == State.SetDefaults)
       {   
        Calculate = Calculate.OnBarClose;
        ....
       }
    ...
    }
    I use this indicator in my strategy which is calculated on each tick (COET)
    Code:
    public class SidiUnmanaged : Strategy
    {
     private SidiSuperTrend sidiSuperTrend;
    
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Calculate = Calculate.OnEachTick;
    ....
    }
     else if (State == State.DataLoaded)
     {
      sidiSuperTrend = SidiSuperTrend(STMode, STPeriode, STMultiplier, STMaType, STSmooth, STShowArrows, STShowHollowUpBars, STColorBars, STBarColorUp, STBarColorDown, STPlayAlert, STLongAlert, STShortAlert);
    
      if (ShowSupertrend)
      {
       AddChartIndicator(sidiSuperTrend);
      }
    }
    ...
    how can i load the indicator in the chart on calculation (COBC) and not on every tick?
    Attached Files
    sidlercom80
    NinjaTrader Ecosystem Vendor - Sidi Trading

    #2
    Hello sidlercom80,

    Thank you for your post.

    It would not be supported to have a hosted indicator calculate on a different calculate setting, as the hosted indicator will inherit the calculate setting of the hosting script.

    Please see tips #3 and 4 on our help guide pages for Calculate:



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

    Comment


      #3
      Hi _Kate, thanks for your quick answer. All calculations must be in the same .cs (class), where they are displayed in the chart, I have understood that ;-)
      Is there a way to start the indicator from the strategy? By this I mean that when the strategy is switched on, the indicator is also loaded, otherwise the indicator must be loaded into the chart by hand.
      sidlercom80
      NinjaTrader Ecosystem Vendor - Sidi Trading

      Comment


        #4
        Hello sidlercom80,

        Thank you for your reply.

        Loading an indicator on a chart through a strategy is done by using AddChartIndicator within the strategy. However, as mentioned previously the hosted indicator will inherit the Calculate setting of the strategy when loaded in this way. If you just want the indicator on the chart and want it to calculate differently, you would need to manually place the indicator on the chart. The strategy would not be able to access the calculations of the manually added indicator.



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

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by bortz, 11-06-2023, 08:04 AM
        47 responses
        1,603 views
        0 likes
        Last Post aligator  
        Started by jaybedreamin, Today, 05:56 PM
        0 responses
        8 views
        0 likes
        Last Post jaybedreamin  
        Started by DJ888, 04-16-2024, 06:09 PM
        6 responses
        18 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by Jon17, Today, 04:33 PM
        0 responses
        4 views
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        12 views
        0 likes
        Last Post Javierw.ok  
        Working...
        X