Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Weird error with strategy

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

    Weird error with strategy

    Hey guys,

    I've been working on a strategy, that works fine when it starts on a chart with no bars, but won't work at all on a chart with bars. So if it starts blank it will run through, it's doing some weird things though its not drawing etc after it enters the trade.

    I get this error when I run it on a chart with bars.

    'Bars' property can't be accessed from within 'Initialize' method.

    Even if I comment out all items in the Initialize() area. The only things I have in Initialize are strategy settings, CalculateOnBarClose = False etc.

    protected override void Initialize()
    {
    SetProfitTarget("",Calculationmode.Ticks, pt);
    this.CalculateOnBarClose = false;
    this.EntriesPerDirection = 10;
    this.EntryHandling = EntryHandling.UniqueEntries;
    this.ExitOnClose = false;
    this.DefaultQuantity = 1;
    }

    If I comment out all the lines it still gets the same error. What in the OnBarUpdate would cause such an error?
    Last edited by happypappy; 10-08-2014, 07:20 PM.

    #2
    And if you comment out all of Initiatlize()?

    /*
    protected overided void Initialize()
    {
    ...
    }
    */

    does it still happen?

    Comment


      #3
      Hey sledge Ill give that a go, cheers.

      Comment


        #4
        happypappy, would not see a reason for the very Initialize() method you posted - however are you sure you picked the 'right' script here? Meaning I could see the scenario where you're trying to fix an Initialize() of a unrelated script here...important to consider Initialize() is called across scripts.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Originally posted by happypappy View Post
          Hey guys,

          I've been working on a strategy, that works fine when it starts on a chart with no bars, but won't work at all on a chart with bars. So if it starts blank it will run through, it's doing some weird things though its not drawing etc after it enters the trade.

          I get this error when I run it on a chart with bars.

          'Bars' property can't be accessed from within 'Initialize' method.

          Even if I comment out all items in the Initialize() area. The only things I have in Initialize are strategy settings, CalculateOnBarClose = False etc.

          protected override void Initialize()
          {
          SetProfitTarget("",Calculationmode.Ticks, pt);
          this.CalculateOnBarClose = false;
          this.EntriesPerDirection = 10;
          this.EntryHandling = EntryHandling.UniqueEntries;
          this.ExitOnClose = false;
          this.DefaultQuantity = 1;
          }

          If I comment out all the lines it still gets the same error. What in the OnBarUpdate would cause such an error?
          If that is all that is in your Initialize() method for the class in question, then your error notice is coming from a different class. Initialize() is global: it is called for every class whenever it has to be called.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by judysamnt7, 03-13-2023, 09:11 AM
          4 responses
          57 views
          0 likes
          Last Post DynamicTest  
          Started by ScottWalsh, Today, 06:52 PM
          4 responses
          36 views
          0 likes
          Last Post ScottWalsh  
          Started by olisav57, Today, 07:39 PM
          0 responses
          7 views
          0 likes
          Last Post olisav57  
          Started by trilliantrader, Today, 03:01 PM
          2 responses
          19 views
          0 likes
          Last Post helpwanted  
          Started by cre8able, Today, 07:24 PM
          0 responses
          9 views
          0 likes
          Last Post cre8able  
          Working...
          X