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

Simple ... Question offset and... > above...

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

    Simple ... Question offset and... > above...

    I try search... but not find ...i want test (to learn) a simple strategy and have some questions with patient for me...

    like:
    Close today > sma4
    sma3> sma 6
    Enter long
    ....

    Only in info about day close at some instrument.

    1º What is difference if I choose ">" or "Cross above" ?
    And in "Cross above" what is "look back period"?

    2º When define sma and close ... i have parameters:
    in Sma I choose "Bars ago" 1 ? or 0?
    and same but in "close today" choose 0?

    3º In "Offset type", choose "Price" or....?

    4º and in only "Offset"? What choose? 0 ? This is what for?



    It is:
    Code:
    CalculateOnBarClose = true
    if (CrossAbove(SMA(3), SMA(6), 1)
                    && CrossAbove(Close, SMA(4), 1))
                {
                    EnterLong(DefaultQuantity, "");
    ...
    Edit:
    How code this:
    "2 period RSI 2 falls 3 day in a row"?

    Thanks
    Last edited by jmagaia; 08-19-2013, 05:30 PM.

    #2
    In no particular order as I find it in the help files:

    SMA(int period)[int bars ago]

    so SMA(20)[1] is the sma of 20 periods, 1 bar ago.

    Using "CrossAbove" Or Below is just a heck of a lot easier than doing it long-form. They did the work for you. Look-back is what you're comparing the current bar off of, which is typically the previous bar, thus the "1" bar look-back.

    Example here:
    // Go long we have an up bar and the 10 EMA crosses above 20 EMA within the last 5 bars
    if (Close[0] > Open[0] && CrossAbove(EMA(10), EMA(20), 5))
    EnterLong();


    Similar syntax to SMA is Close.

    Close[0] is the closing price of the most current bar, so something like,

    if (Close[0] > Close[1]) // true if current close is greater than the previous close.
    hope it helps.

    Comment


      #3
      jmagaia, in addition to Steve's reply you would find this likely helpful to further clarify -



      For the RSI example, you would check the RSI value then against the previous RSI value to compare and formulate your condition, the CrossOver was implemented as convenience method really, you can also express the same item with the <> comparions, i.e. if the RSI this bar is higher than 30, but previous bar it was lower > then it must have crossed over.

      Offset would allow you to add lets say 'wiggle' room to the value compared to, i.e. RSI + 5 points or Close + 2 ticks.
      BertrandNinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by ZeroKuhl, Today, 04:31 PM
      0 responses
      14 views
      0 likes
      Last Post ZeroKuhl  
      Started by Vulgoth_t_Destroyer, 05-09-2022, 04:45 PM
      54 responses
      5,337 views
      0 likes
      Last Post Gaterz
      by Gaterz
       
      Started by ETFVoyageur, 05-07-2024, 07:05 PM
      11 responses
      76 views
      0 likes
      Last Post -=Edge=-  
      Started by _Zero_, 04-10-2020, 03:21 PM
      145 responses
      7,900 views
      6 likes
      Last Post johng2
      by johng2
       
      Started by TheTradingMantis, 01-19-2023, 02:05 AM
      43 responses
      923 views
      0 likes
      Last Post jmagaia
      by jmagaia
       
      Working...
      X