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.

        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 argusthome, 03-08-2026, 10:06 AM
          0 responses
          77 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          45 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          27 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          32 views
          0 likes
          Last Post TheRealMorford  
          Started by Mindset, 02-28-2026, 06:16 AM
          0 responses
          63 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Working...
          X