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 TraderBCL, Today, 04:38 AM
        0 responses
        1 view
        0 likes
        Last Post TraderBCL  
        Started by Radano, 06-10-2021, 01:40 AM
        19 responses
        606 views
        0 likes
        Last Post Radano
        by Radano
         
        Started by KenneGaray, Today, 03:48 AM
        0 responses
        4 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
         
        Working...
        X