Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

look back period in strategy

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

    look back period in strategy

    I may be misunderstanding "look back period" .
    Lets say I have 3 conditions. Which are the "cross above" type.

    IF
    foo crosses above 0 (Substitute indicator of choice Ex 'MACD'
    boo crosses above 0
    soo crosses above 0
    THEN
    Enter long position or send alert

    So now when these three things occur during the same bar; the order is triggered.

    What if I don't want to restrict myself to ALL three conditions occurring exactly together?
    I thought that by changing the "look back period" on all the conditions to "4" that was creating a more flexible execution scheme. That example would mean;
    IF
    the three conditions have all occurred within the last 4 bars
    THEN Execute instruction.


    But perhaps I am misunderstanding "look back". I want to specify that a condition can have occurred within X bars. If look back in not the correct tool or if I am misunderstanding it, Please tell me what is. Thank you

    #2
    Originally posted by mcteague View Post
    I may be misunderstanding "look back period" .
    Lets say I have 3 conditions. Which are the "cross above" type.

    IF
    foo crosses above 0 (Substitute indicator of choice Ex 'MACD'
    boo crosses above 0
    soo crosses above 0
    THEN
    Enter long position or send alert

    So now when these three things occur during the same bar; the order is triggered.

    What if I don't want to restrict myself to ALL three conditions occurring exactly together?
    I thought that by changing the "look back period" on all the conditions to "4" that was creating a more flexible execution scheme. That example would mean;
    IF
    the three conditions have all occurred within the last 4 bars
    THEN Execute instruction.


    But perhaps I am misunderstanding "look back". I want to specify that a condition can have occurred within X bars. If look back in not the correct tool or if I am misunderstanding it, Please tell me what is. Thank you
    So post an example of the code that you have written, and what the error log logs.

    Comment


      #3
      Hello mcteague,

      Thank you for your post.

      That would be the correct understanding of the look back period. Look back period will look through X bars for the condition (in this case Cross Above).

      Please let me know if I may be of further assistance.

      Comment


        #4
        Lookback period in crossover

        I have trouble in interpreting the lookback period for crossabove/crossbelow.

        My code goes as follows:

        IF
        (
        XXX(14) [0] >= 20
        && (CrossAbove(SMA(50), SMA(200), 25)
        )
        {
        EnterLongLimit(TradeQty, GetCurrentBid(), " ");
        }


        If I understand correctly it checks previous bars one by one starting from 0 bar period to 25 bar period back?

        What i'm concerned about is what if within the 25 period the condition was TRUE and FALSE. Where for example:
        1. It was TRUE 5 periods back and FALSE 10 periods back. Would it trade then or not? In this case I would like it to trade.
        2. It was FALSE 6 periods back and TRUE 10 periods back. Would it trade? In this case I do NOT want it to trade.


        Please help me out with this one! THANKS!

        Comment


          #5
          Hello Rawheritage,

          Thanks for writing in to our Support team.

          The CrossAbove() method will look at the entire look back period - if a cross above condition occurred anywhere within that look back period, this method will return true.

          In your first listed case, since a cross above condition occurred within the look back period, the method would return true. In your second listed case, a cross above condition occurred within the look back period, so the method would return true.

          If you want to check different look back periods, you will need to include additional CrossAbove() checks with those look back periods defined.

          Please let me know if I may be of any further assistance.
          Alan S.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          558 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          324 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          545 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          547 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X