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

why is this not printing to the output window

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

    why is this not printing to the output window

    Code:
    [FONT=Courier New][SIZE=2][COLOR=#0000ff]
    namespace[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] NinjaTrader.Strategy
    {
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080]<summary>
    [/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000] Enter the description of your strategy here
    [/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080]</summary>
    [/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][Description([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"Enter the description of your strategy here"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])]
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]class[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] MyCustomStrategy3 : Strategy
    {
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]#region[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] Variables
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// Wizard generated variables
    [/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] myInput0 = [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]; [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// Default setting for MyInput0
    [/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// User defined variables (add any user defined variables below)
    [/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]#endregion
    [/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] barAtPlaceStrategy ;
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080]<summary>
    [/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000] This method is used to configure the strategy and is called once before any strategy method is called.
    [/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080]</summary>
    [/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] Initialize()
    {
    CalculateOnBarClose = [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2];
    barAtPlaceStrategy=CurrentBar;
    Print([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]" Current Bar when strategy opened "[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] + barAtPlaceStrategy);
    }
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080]<summary>
    [/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000] Called on each bar update event (incoming tick)
    [/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080]</summary>
    [/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] OnBarUpdate()
    {
    Print([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"bar ticking"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);
    }
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]#region[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] Properties
    [Description([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])]
    [Category([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"Parameters"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])]
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] MyInput0
    {
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]get[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] { [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] myInput0; }
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]set[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] { myInput0 = Math.Max([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2], value); }
    }
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]#endregion
    [/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]}
    }
    [/SIZE][/FONT]
    all i have done is declared a private variable and am trying to print to the output window. not sure why it is not doing it when i apply the strategy.

    #2
    Can you check your log tab of the Control Center window to see if there are any errors logged when running your strategy?
    RayNinjaTrader Customer Service

    Comment


      #3
      24/11/2008 4:32:04 AM Strategy Failed to call method 'Initialize' for strategy 'forexTrailingStop': 'CurrentBar' property can not be accessed from within 'Initialize' method

      what properties can/cannot be called from Initialize

      Comment


        #4
        E.g. the CurrentBar property is not supported in Initialize. Unfortunately there is no list of properties/methods not supported in Initialize.

        Comment


          #5
          what factors determine if a property will be or will not be supported in the Initialize.

          Comment


            #6
            Unfortunately there are no such factors exposed/documented.

            Comment


              #7
              this is rather pityful. its like buying a car from GM, the check engine light comes on and GM states, well we dont documetn why the check engine lights up. you have to find out trial and error.

              Comment


                #8
                junkone,

                Generally no logic goes into the Initialize() method. If you are trying to access anything to run logic it should be done in OnBarUpdate().

                This is a partial list of what is settable from the Initialize() of a NinjaScript Strategy: http://www.ninjatrader-support.com/v...06&postcount=5
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by junkone View Post
                  this is rather pityful. its like buying a car from GM, the check engine light comes on and GM states, well we dont documetn why the check engine lights up. you have to find out trial and error.
                  Hi junkone,

                  consider the following, hope that makes sense to you:

                  Initialize() is performed before your strategy starts running. Therefore it couldn't know anything about a bar number or even a bar number when using a multi-timeframe strategy.

                  Initialize() does all the things before you start your GM-car, like unlock the car, sit down, close the door and fasten the seatbelt.

                  Regards
                  Ralph

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by geddyisodin, Today, 05:20 AM
                  3 responses
                  20 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by lorem, Today, 09:18 AM
                  1 response
                  5 views
                  0 likes
                  Last Post lorem
                  by lorem
                   
                  Started by bmartz, Today, 09:30 AM
                  0 responses
                  5 views
                  0 likes
                  Last Post bmartz
                  by bmartz
                   
                  Started by GussJ, 03-04-2020, 03:11 PM
                  14 responses
                  3,245 views
                  0 likes
                  Last Post GussJ
                  by GussJ
                   
                  Started by ArkansasClint, Today, 09:28 AM
                  0 responses
                  2 views
                  0 likes
                  Last Post ArkansasClint  
                  Working...
                  X