Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 Radano, 06-10-2021, 01:40 AM
          19 responses
          604 views
          0 likes
          Last Post Radano
          by Radano
           
          Started by KenneGaray, Today, 03:48 AM
          0 responses
          3 views
          0 likes
          Last Post KenneGaray  
          Started by thanajo, 05-04-2021, 02:11 AM
          4 responses
          470 views
          0 likes
          Last Post tradingnasdaqprueba  
          Started by aa731, Today, 02:54 AM
          0 responses
          5 views
          0 likes
          Last Post aa731
          by aa731
           
          Started by Christopher_R, Today, 12:29 AM
          0 responses
          11 views
          0 likes
          Last Post Christopher_R  
          Working...
          X