• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Template no parameters?

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

    Strategy Template no parameters?

    I attached a strategy template for your Sample MA Crossover strategy, which does save the parameter values into the XML template file. Notice in this file I changed Fast to 1 and Slow to 989. These values are stored in the <Strategy> group of the file.

    I have a strategy I created from the Strategy Wizard and added several parameters like they are in Sample MA Crossover. However, when I save the template for mine, there is no Strategy group... it simply looks like this:

    <Strategy />

    Which of course does not save any of the parameter values. What line(s) of code in the Sample MA Crossover causes it to store the <Strategy> group correctly so I can add that to mine?

    Thanks!
    Bryan
    Attached Files
    cassb
    NinjaTrader Ecosystem Vendor - Logical Forex

    #2
    Hello cassb, and thank you for your question. To answer it literally, these property tags

    Code:
            [Range(1, int.MaxValue), NinjaScriptProperty]
            [Display(ResourceType = typeof(Custom.Resource), Name = "Fast", GroupName = "NinjaScriptStrategyParameters", Order = 0)]
    Are responsible for letting the serializer know to look at these values. This said, since none of your properties are exporting, I would take a closer look at your Xml serialization after reviewing this page of the help guide on the topic, as some values need a little more work to serialize than what's in the SampleMACrossover strategy.

    http://ninjatrader.com/support/helpG...th_brushes.htm (the "Using brushes defined on the user interface" section)

    More general information on working with XML output is here,

    http://ninjatrader.com/support/helpG...attributes.htm

    I recommend starting to debug this by commenting out all references to any property not a basic type like an integer, double, boolean, this sort of thing. Once you can get this minimal set exporting properly, you can work on serializing your more advanced types such as brushes.

    We are happy to help with any questions that come up.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Thanks, Jessica. So here is an example that's not being saved to the XML file:

      Code:
      [Range(1, int.MaxValue)]
              [NinjaScriptProperty]
              [Display(Name="Tick Target", Description="Ticks-of-Profit value to exit a trade", Order=10, GroupName="Parameters")]
              public int TickTarget
              { get; set; }
      Can you tell me what is wrong with this property and why it's not saved in the <STRATEGY></STRATEGY> group?

      Thanks!
      Bryan
      cassb
      NinjaTrader Ecosystem Vendor - Logical Forex

      Comment


        #4
        Have you made sure that this is the only property in your script? If any of your properties are not serializing, it may be that none of your properties are serializing.

        In the attached script your code serializes on my end. We can see TickTarget in the attached template, retrieved from (My) Documents\NinjaTrader 8\templates\Strategy .

        I recommend, if you observe the same thing on your end, using the attached script as a debugging tool. You can add your properties one at a time until you can determine which is not serializing.
        Attached Files
        Jessica P.NinjaTrader Customer Service

        Comment


          #5
          None of them are serializing. I have over 20 parameters and the <STRATEGY> group is empty. What code causes the STRATEGY group to populate?
          cassb
          NinjaTrader Ecosystem Vendor - Logical Forex

          Comment


            #6
            Since your platform and ours are behaving differently, since the code you sent us serialized as evidenced by the template we returned to you along with the code we returned to you, and we are assuming you tested the code sample I returned to you, we will need to determine what is occurring with your platform before we can proceed further. Can you send an e-mail to platformsupport[at]ninjatrader[dot]com so that we can investigate further?

            Alternatively, we recognize your time is valuable. Please follow these instructions to create a clean environment to test your code compiles in. Please let us know if your code is unable to serialize even in a clean environment :



            • Download a fresh copy of NinjaTrader 8 from ninjatrader.com
            • Close NinjaTrader 8
              • To ensure NinjaTrader is closed completely, please press the windows key (to the left of the space bar) and the letter r at the same time, and type in
                taskkill /f /im NinjaTrader.exe
                and press enter
            • Rename your (My) Documents\NinjaTrader 8\db\NinjaTrader.sdf file to something unique. I prefer names that include today's date
            • Rename your (My) Documents\NinjaTrader 8 folder to something else that is unique. I prefer names that include today's date.
            • Use the installer you downloaded to uninstall, and then reinstall, NinjaTrader 8
            • Copy these files and folders from your old, renamed (My) Documents\NinjaTrader 8 folder to your new folder. If asked to replace files, always select "yes"
              • Config.xml
              • UI.xml
              • db\NinjaTrader.sdf
            • Start NinjaTrader 8. You will receive some dialogs about Ninja being unable to start because it needed to recompile some dlls. OK out of these dialogs
            • Start NinjaTrader 8 once more
            Jessica P.NinjaTrader Customer Service

            Comment


              #7
              Yes, the STRATEGY tag in your example code, which I saved a Default.xml template looks like this:

              Code:
              <Strategy>
                  <Example1682071 xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                    <IsVisible>true</IsVisible>
                    <AreLinesConfigurable>true</AreLinesConfigurable>
                    <ArePlotsConfigurable>true</ArePlotsConfigurable>
                    <BarsPeriodSerializable>
                      <BarsPeriodTypeSerialize>0</BarsPeriodTypeSerialize>
                      <BaseBarsPeriodType>Minute</BaseBarsPeriodType>
                      <BaseBarsPeriodValue>1</BaseBarsPeriodValue>
                      <MarketDataType>Last</MarketDataType>
                      <PointAndFigurePriceType>Close</PointAndFigurePriceType>
                      <ReversalType>Tick</ReversalType>
                      <Value>1</Value>
                      <Value2>1</Value2>
                    </BarsPeriodSerializable>
                    <BarsToLoad>0</BarsToLoad>
                    <Calculate>OnBarClose</Calculate>
                    <Displacement>0</Displacement>
                    <DisplayInDataBox>true</DisplayInDataBox>
                    <From>2099-12-01T00:00:00</From>
                    <IsAutoScale>true</IsAutoScale>
                    <IsDataSeriesRequired>true</IsDataSeriesRequired>
                    <IsOverlay>true</IsOverlay>
                    <Lines />
                    <MaximumBarsLookBack>TwoHundredFiftySix</MaximumBarsLookBack>
                    <Name>Example1682071</Name>
                    <Panel>-1</Panel>
                    <Plots />
                    <ScaleJustification>Right</ScaleJustification>
                    <SelectedValueSeries>0</SelectedValueSeries>
                    <ShowTransparentPlotsInDataBox>false</ShowTransparentPlotsInDataBox>
                    <To>1800-01-01T00:00:00</To>
                    <BarsPeriodParameter>
                      <Increment>1</Increment>
                      <Max xsi:type="xsd:int">0</Max>
                      <Min xsi:type="xsd:int">0</Min>
                      <Name />
                      <ParameterTypeSerializable>System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ParameterTypeSerializable>
                      <ValueSerializable>0</ValueSerializable>
                    </BarsPeriodParameter>
                    <BarsRequiredToTrade>20</BarsRequiredToTrade>
                    <Category>NinjaScript</Category>
                    <ConnectionLossHandling>Recalculate</ConnectionLossHandling>
                    <DaysToLoad>5</DaysToLoad>
                    <DefaultQuantity>1</DefaultQuantity>
                    <DisconnectDelaySeconds>10</DisconnectDelaySeconds>
                    <EntriesPerDirection>1</EntriesPerDirection>
                    <EntryHandling>AllEntries</EntryHandling>
                    <ExitOnSessionCloseSeconds>30</ExitOnSessionCloseSeconds>
                    <Gtd>1800-01-01T00:00:00</Gtd>
                    <IncludeCommission>false</IncludeCommission>
                    <IsAggregated>false</IsAggregated>
                    <IsExitOnSessionCloseStrategy>true</IsExitOnSessionCloseStrategy>
                    <IsFillLimitOnTouch>false</IsFillLimitOnTouch>
                    <IsOptimizeDataSeries>false</IsOptimizeDataSeries>
                    <IsStableSession>true</IsStableSession>
                    <IsTickReplay>false</IsTickReplay>
                    <IsTradingHoursBreakLineVisible>true</IsTradingHoursBreakLineVisible>
                    <IsWaitUntilFlat>false</IsWaitUntilFlat>
                    <NumberRestartAttempts>4</NumberRestartAttempts>
                    <OptimizationPeriod>10</OptimizationPeriod>
                    <OrderFillResolution>Standard</OrderFillResolution>
                    <OrderFillResolutionType>Tick</OrderFillResolutionType>
                    <OrderFillResolutionValue>1</OrderFillResolutionValue>
                    <RestartsWithinMinutes>5</RestartsWithinMinutes>
                    <SetOrderQuantity>Strategy</SetOrderQuantity>
                    <Slippage>0</Slippage>
                    <StartBehavior>WaitUntilFlat</StartBehavior>
                    <StopTargetHandling>PerEntryExecution</StopTargetHandling>
                    <SupportsOptimizationGraph>true</SupportsOptimizationGraph>
                    <Template />
                    <TimeInForce>Gtc</TimeInForce>
                    <TestPeriod>28</TestPeriod>
                    <TradingHoursSerializable />
                    <DrawOnPricePanel>false</DrawOnPricePanel>
                    <ZOrder>0</ZOrder>
                    <TickTarget>989</TickTarget>
                  </Example1682071>
                </Strategy>
              The STRATEGY tag in my strategy, with the same Property and several others, looks like this:

              Code:
              <Strategy />
              So, what is in your example that causes it to save the run-time parameters that is apparently not in my code? Can you look at your Kernel or core NT8 code and find out what it's looking for when generating a strategy template file that causes it to populate the STRATEGY tag with run-time variables? I can't debug your internal code, so you'll need to let me know if you could, please.

              Bryan
              cassb
              NinjaTrader Ecosystem Vendor - Logical Forex

              Comment


                #8
                I am glad the example code I sent you compiled successfully, and serialized properly. If you examine the code, you will see that exactly the code you sent us was added to this indicator.

                This means that

                • NinjaTrader is capable of serializing properly
                • The code samples we traded work properly

                Since your code in your strategy is not serializing, we must conclude that the reason is in the code you have.


                I need to emphasize this. The reason is not that the code sample you sent us, or the majority of your code, was written incorrectly. The code you sent us was written correctly. We determined this already. Examining differences between our code and yours will not resolve this query.

                As I mentioned previously, serializing is "all or nothing" . Since your strategy template is completely empty, this means that a piece of your strategy is preventing the other parts of your strategy, which are correctly written and would otherwise work successfully (as we demonstrated to ourselves), from serializing.


                We would be happy to demonstrate the debugging process. I believe to most successfully do this, based on our conversation, it would be best if we had a copy of your code to demonstrate with. Code copies are not retained and this would only be used to produce a video sent to you privately. To send it privately, please contact platformsupport[at]ninjatrader[dot]com referencing attn:NinjaTrader_JessicaP and 1682701 in the subject line of your e-mail. This code would not need any trade logic; it would just need strategy parameters that are not serializing properly.
                Last edited by NinjaTrader_JessicaP; 03-24-2017, 09:36 AM.
                Jessica P.NinjaTrader Customer Service

                Comment


                  #9
                  OK, no problem. I'll play around and see if I can figure it out then. I was just hoping that you could search for <STRATEGY> in your core code set and see where/when/why/how it creates that tag in the XML.

                  Thanks!
                  cassb
                  NinjaTrader Ecosystem Vendor - Logical Forex

                  Comment


                    #10
                    While I have this capability, the missing piece that we are unable to see, the way you are serializing all your variables, is critical to understanding why your code is not serializing. It is very easy to create a complicated object, like a Brush (which is why I linked the documentation for brush serialization), in a way which does not properly marshal this object. Since there are innumerably many ways to create objects that do not marshal correctly, we can not determine looking at our own code why your strategy will not serialize. And, since any incorrectly marshalled object will prevent serializing, looking at correctly serializing objects will not be useful to us.

                    Please let us know if there are any other ways we can help.
                    Jessica P.NinjaTrader Customer Service

                    Comment


                      #11
                      OK thank you! I just sent you an email with my complete list of Properties in the code. Maybe you can see which one of them might be preventing serialization.

                      Bryan
                      cassb
                      NinjaTrader Ecosystem Vendor - Logical Forex

                      Comment


                        #12
                        Thank you Bryan. I have followed up via e-mail.
                        Jessica P.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by ajay8000, Yesterday, 11:31 PM
                        5 responses
                        18 views
                        0 likes
                        Last Post NinjaTrader_Marco  
                        Started by simjs, Yesterday, 11:23 PM
                        0 responses
                        5 views
                        0 likes
                        Last Post simjs
                        by simjs
                         
                        Started by akuntysh, Yesterday, 10:41 PM
                        0 responses
                        4 views
                        0 likes
                        Last Post akuntysh  
                        Started by Wolf1, Yesterday, 08:26 PM
                        0 responses
                        7 views
                        0 likes
                        Last Post Wolf1
                        by Wolf1
                         
                        Started by pparmley, Yesterday, 04:30 PM
                        0 responses
                        9 views
                        0 likes
                        Last Post pparmley  
                        Working...
                        X