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

Future value indicator

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

    Future value indicator

    Hello,
    How could I know the value of any indicator if the price of the current bar closed, for example, with a value of 20 ticks higher? Example: what would be the value of ema(close, 14) if the price of the current candle was 20 ticks higher? Is there a way to program it in ninjascript?

    #2
    Hello gviand,

    Thanks for your post.

    You could consider creating a Series<double> variable named something like myDouble and assign the Close[0] price plus 20 Ticks to this variable.

    Then, you could pass this variable in for the Series<double> input argument when calling the EMA() method and assign this value to a plot.

    Code:
    //class level variable
    private Series<double> myDouble;
    
    //OnStateChange
    if (State == State.SetDefaults)
    {
        AddPlot(Brushes.DodgerBlue, "Plot1");
    }
    else if (State == State.DataLoaded)
    {
        myDouble = new Series<double>(this);
    }
    
    //OnBarUpdate
    protected override void OnBarUpdate()
    {
        myDouble[0] = Close[0] + 20 * TickSize;
    
        Values[0][0] = EMA(myDouble, 14)[0];
    }
    See the attached reference sample demonstrating this.

    And, see the help guide documentation below for more information.
    Series<T>: https://ninjatrader.com/support/help...t8/seriest.htm
    EMA: https://ninjatrader.com/support/help...onential_e.htm
    AddPlot(): https://ninjatrader.com/support/help...t8/addplot.htm

    Let me know if I may assist further.
    Attached Files
    Last edited by NinjaTrader_BrandonH; 08-09-2022, 01:31 PM.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3

      Thanks for your reply. What I need is something different. I need to calculate what would be the value of EMA(Close, 14) considering only that the current candle was 20 ticks higher, leaving the previous candles with their original close. That is, I need to simulate the value of candle number 0.

      Comment


        #4
        Hello gviand,

        Thanks for your note.

        This would go beyond what we would be able to provide support for. It would require you to program your own custom calculations within the script to determine what the EMA value might be if only the currently forming bar is 20 ticks higher. A Series<double> input must be used when calling EMA() as seen in post #2. It would not be possible to change a single candle's value for the EMA indicator to calculate.

        This forum thread will be open for other community members to share their insights on possible custom calculations to accomplish this.

        Let me know if I may assist further.
        Last edited by NinjaTrader_BrandonH; 08-09-2022, 03:02 PM.
        Brandon H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by haas88, 03-21-2024, 02:22 AM
        19 responses
        220 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by ZeroKuhl, Yesterday, 04:31 PM
        4 responses
        30 views
        0 likes
        Last Post ZeroKuhl  
        Started by cupir2, Yesterday, 07:44 PM
        3 responses
        21 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by reynoldsn, Yesterday, 07:26 PM
        2 responses
        16 views
        0 likes
        Last Post reynoldsn  
        Started by MartinT, 05-17-2023, 06:00 AM
        18 responses
        175 views
        0 likes
        Last Post flybuzz
        by flybuzz
         
        Working...
        X