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 love2code2trade, 04-17-2024, 01:45 PM
        4 responses
        37 views
        0 likes
        Last Post love2code2trade  
        Started by alifarahani, Today, 09:40 AM
        2 responses
        13 views
        0 likes
        Last Post alifarahani  
        Started by junkone, Today, 11:37 AM
        3 responses
        16 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by pickmyonlineclass, Today, 12:23 PM
        0 responses
        3 views
        0 likes
        Last Post pickmyonlineclass  
        Started by frankthearm, Yesterday, 09:08 AM
        12 responses
        44 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Working...
        X