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

how to offset EMA's

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

    how to offset EMA's

    I have a qestion about how to offset an EMA 5 by 1
    meaning the line is atually infornt of the current bars. i know that i will have to build my own indicator but i am confused as to where the code for the offset would me placed. attached is a code for any EMA if someone could input the changes that would be great
    thank you
    john

    #region Variables
    privateint period = 5;
    #endregion
    ///<summary>
    /// This method is used to configure the indicator and is called once before any bar data is loaded.
    ///</summary>
    protectedoverridevoid Initialize()
    {
    Add(
    new Plot(Color.Orange, "EMA"));
    Overlay =
    true;
    PriceTypeSupported =
    true;
    }

    ///<summary>
    /// Called on each bar update event (incoming tick)
    ///</summary>
    protectedoverridevoid OnBarUpdate()
    {
    Value.Set(CurrentBar ==
    0 ? Input[0] : Input[0] * (2.0 / (1 + Period)) + (1 - (2.0 / (1 + Period))) * Value[1]);
    }

    #2
    Not sure I understand exactly what you want to achieve, but are you trying to code an indicator which actually peeks 5 bars ahead?

    -> this then would be looking into the future, which likely would not be advisable for coding trading systems

    Also:
    - accessing NinjaScript values by negative "barsAgo" values (which you then probably would need), is not supported
    - would the Displacement option help? http://www.ninjatrader-support.com/H...placement.html

    Comment


      #3
      No not looking for it to look in the future. what i want is to be able to move the EMA5 basised on the last 5 bars but print this value on bar -1. ie the EMA would be drawn one bar ahead of the current bar(or the acutal bar) if you dont understand what im looking for just open up a ninja trader chart and set the displacement to 1 and you wil see that the EMA actually leads the stock price.
      Last edited by vpr10c; 07-21-2008, 01:14 PM.

      Comment


        #4
        See this link in the Help Guide -

        RayNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by funk10101, Today, 09:43 PM
        0 responses
        2 views
        0 likes
        Last Post funk10101  
        Started by pkefal, 04-11-2024, 07:39 AM
        11 responses
        36 views
        0 likes
        Last Post jeronymite  
        Started by bill2023, Yesterday, 08:51 AM
        8 responses
        44 views
        0 likes
        Last Post bill2023  
        Started by yertle, Today, 08:38 AM
        6 responses
        25 views
        0 likes
        Last Post ryjoga
        by ryjoga
         
        Started by algospoke, Yesterday, 06:40 PM
        2 responses
        24 views
        0 likes
        Last Post algospoke  
        Working...
        X