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

OnStartUp and OnBarUpdate not called

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

    OnStartUp and OnBarUpdate not called

    Hello All,

    I am a newbee with NinjaTrader and am having a hard time getting started.

    I wrote the following basic code. It just prints when the various functions are called.
    1) I connect to my data provider,
    2) then create a chart.
    3) Add the data series "6S 06-13".
    4) Open the output window
    5) Then I add my strategy "PivotInputTester".

    - I get the Initialize print statement running twice and the OnBarUpdate or the OnStartUp are never called.

    Any Ideas?

    Cheers,
    Cleo

    publicclass PivotInputTester : Strategy
    {
    ///<summary>
    /// This method is used to configure the strategy and is called once before any strategy method is called.
    ///</summary>
    protectedoverridevoid Initialize()
    {
    CalculateOnBarClose =
    true;
    Print(
    "Initialize");
    }
    protectedoverridevoid OnStartUp()
    {
    // Set any variables or logic you wish to do only once at start of your indicator/strategy
    Print("OnStartUp");
    // double test = Pivots(PivotRange.Daily, HLCCalculationMode.CalcFromIntradayData, 0, 0, 0, 20).S1[0];
    // double value = Pivots(PivotRange.Daily, HLCCalculationMode.CalcFromIntradayData, 0, 0, 0, 20).PP[0];
    //Print("The Initialize Pivots' pivot value is " + value.ToString());
    }
    ///<summary>
    /// Called on each bar update event (incoming tick)
    ///</summary>
    protectedoverridevoid OnBarUpdate()
    {
    Print(
    "On Bar Update");
     
    }

    #2
    Welcome to our forums Cleo - what chart type and historical data look back are you running on please? Would it change the outcome if you loaded more data before enabling the strategy?
    BertrandNinjaTrader Customer Service

    Comment


      #3
      You need to enable the strategy before OnStartUp and OnBarUpdate are called.

      Comment


        #4
        Thank you, Enabling the strategy worked perfectly.

        Cheers,
        Cleo

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Spiderbird, Today, 12:15 PM
        2 responses
        8 views
        0 likes
        Last Post Spiderbird  
        Started by WHICKED, Today, 12:45 PM
        0 responses
        3 views
        0 likes
        Last Post WHICKED
        by WHICKED
         
        Started by FrazMann, Today, 11:21 AM
        2 responses
        6 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Started by rjbtrade1, 11-30-2023, 04:38 PM
        2 responses
        80 views
        0 likes
        Last Post DavidHP
        by DavidHP
         
        Started by lorem, Yesterday, 09:18 AM
        5 responses
        18 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X