• 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

Adding string values to series<T>

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

    Adding string values to series<T>

    I am trying to create a custom series that holds strings indicating the direction of the Trend as calculated by a CheckMarketTrend().
    Without using the Trend series, the algorithm works well on historical data. With it, it does nothing. No compilation errors or log errors were given. I am assuming therefor that I am not adding the string values correctly to the Trend series.
    I would appreciate it if someone can point me in the right direction to fix this.

    Below is the skeleton code I am using to execute.

    else if (State == State.DataLoaded)
    Trend = new Series<string>(this);

    protected override void OnBarUpdate()
    {
    if (IsFirstTickOfBar)
    {
    CheckMarketTrend();
    }

    if (Trend[0] == "long")
    {
    ///Execute logic to enter long position
    }
    }

    private string CheckMarketTrend()
    {
    if (stochastic5min.D[0] <= 20)
    {
    return Trend[0] = "long";
    }
    ////logic continues setting Trend[0] = "long", "short" or "donothing" using logic structure of above example ending with an Exception to catch anything falling outside the scope given.
    }

    #2
    Hello JulieV,

    Trace it back one step at a time.

    Use prints to understand the behavior.
    http://ninjatrader.com/support/forum...979#post510979

    What have you understood so far?
    Is Trend[0] set to the expected value after that condition is set?
    Keep in mind a bar series value represents that entire bar. If its changed at some point its changed for the entire bar.
    This means if the condition was false on the first tick, then on each subsequent tick that condition will remain false (and vice versa) when the other condition is doing its evaluation on all the other bars..
    If its changed on other ticks, its changed for that bar..
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks, ChelseaB for the link. I found my error.
      I am hoping you can help me with adding commission to my backtesting.
      I have already added the commission under Tools - Commissions tab. I have ticked Include commission under Set up in the Strategy Analyzer. Not sure what else to do to get the commission added.
      I am currently on a demo account.

      Thanks

      Comment


        #4
        Hello JulieV,

        Have you applied a Commissions template to the Sim101 account?

        Below is a public link to the help guide.
        https://ninjatrader.com/support/help...atesToAccounts
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thanks, ChelseaB. I missed that documentation in my search. It's all fixed up.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by jerblaster23, Today, 03:42 PM
          1 response
          11 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by brian meade, Today, 01:39 PM
          2 responses
          10 views
          0 likes
          Last Post brian meade  
          Started by Johnny Santiago, Today, 12:20 PM
          1 response
          5 views
          0 likes
          Last Post NinjaTrader_ChrisL  
          Started by NinjaTrader_Brandon, Today, 10:24 AM
          0 responses
          64 views
          0 likes
          Last Post NinjaTrader_Brandon  
          Started by ptertich, Today, 07:56 AM
          2 responses
          19 views
          0 likes
          Last Post Johnny Santiago  
          Working...
          X