Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy builder keeps trading at one bar

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

    Strategy builder keeps trading at one bar

    I'm having an issue with the strategy builder where my algo runs fine for a while and then at certain bars, I think they are usually very large bars, it trades repeatedly with the same timestamp and entry/exit price. Not sure why this is happening, can anybody help me out with fixing it?

    EDIT - I think I've determined the cause of the problem, which is that my profit and stop conditions are for [0] bars ago, so when there is a large enough bar it hits my profit and/or stop condition while also meeting my criteria for an entry signal, the algo gets stuck in a loop and keeps entering and exiting the same trade repeatedly. If this is true, them I'm not sure why it ever stops rather than just being stuck in an infinite loop, maybe some kind of stop measure in the software prevents it from continuing on forever?

    Is there some way I can limit the algo to have a maximum of one entry/exit per bar or something similar? I'll do some checking in the mean time.
    Attached Files
    Last edited by kj5159; 08-04-2018, 08:29 PM.

    #2
    This is what I use to limit multiple trades per bar

    PHP Code:
    if(longsignal && CanEnterBar())
    {
    //blah


    public bool CanEnterBar()
    {
    return (BarsSinceEntryExecution() >= 1 || BarsSinceEntryExecution() == -1) ? true : false;
    }

    public bool CanExitBar()
    {
    return (BarsSinceExitExecution() >= 1 || BarsSinceExitExecution() == -1) ? true : false;
    }

    Comment


      #3
      Hello kj5159,

      Likely this is being caused by the logic you have written in to the script.

      Your condition is evaluating as true and the order is being placed.

      If you don't want to place an order when the condition is true, add to the condition that another condition is not true by changing a bool from true to false (or vice versa). Then change the value of the bool from true to false from other condition sets.

      Bool variables can be added on the Inputs and Variables section of the Strategy Builder in the Variables section and can be compared to true or false in the Condition Builder section.

      You could, for example, set the bool back to true when IsFIrstTickOfBar is true.

      Below is a public link to a 3rd party educational site on bool.
      Test the bool type, which holds true or false. A bool occupies 1 byte of memory.
      Chelsea B.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by usazencort, Today, 01:16 AM
      0 responses
      1 view
      0 likes
      Last Post usazencort  
      Started by kaywai, 09-01-2023, 08:44 PM
      5 responses
      603 views
      0 likes
      Last Post NinjaTrader_Jason  
      Started by xiinteractive, 04-09-2024, 08:08 AM
      6 responses
      22 views
      0 likes
      Last Post xiinteractive  
      Started by Pattontje, Yesterday, 02:10 PM
      2 responses
      21 views
      0 likes
      Last Post Pattontje  
      Started by flybuzz, 04-21-2024, 04:07 PM
      17 responses
      230 views
      0 likes
      Last Post TradingLoss  
      Working...
      X