• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Price EMA Crossover Occurs

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

    Price EMA Crossover Occurs

    Looking for strategy to store the price variable that the last MA crossover occurs at..

    What does the code look like for getting that price point..



    Regards,
    Chris

    #2
    Hello Chris,

    The Close[0] price will be the last price of the bar.
    http://ninjatrader.com/support/helpG...n-us/close.htm

    The object type is a double.

    Create a variable that is a double. Assign the Close[0] to the variable when the CrossAbove or CrossBelow condition is true.
    Code:
    private double storedPrice = 0;
    if (CrossAbove(EMA(7), EMA(14), 1))
    {
    storedPrice = Close[0];
    }
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      private double storedPrice = 0;
      if (CrossAbove(EMA.low(7), EMA.low(14), 1))
      {
      storedPrice = Close[0];
      }


      if I wanted the EMA to use 'low' value.. is the above correct?..

      Comment


        #4
        Hello Kubera2024,

        No, this would not be correct.

        Below is a link to the help guide on EMA().
        http://ninjatrader.com/support/helpG...onential_e.htm

        Correct usage would be:

        EMA(Low, 7)

        Where Low is the Low data series supplied to the EMA as the input series overload parameter.
        http://ninjatrader.com/support/helpG.../en-us/low.htm
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by HiddenPhilosopher, Today, 07:50 AM
        0 responses
        2 views
        0 likes
        Last Post HiddenPhilosopher  
        Started by NinjaCustomer, Today, 06:55 AM
        4 responses
        11 views
        0 likes
        Last Post NinjaCustomer  
        Started by Udimuz, Today, 05:46 AM
        0 responses
        10 views
        0 likes
        Last Post Udimuz
        by Udimuz
         
        Started by TAJTrades, Today, 05:11 AM
        0 responses
        13 views
        0 likes
        Last Post TAJTrades  
        Started by poeds, Today, 05:08 AM
        2 responses
        10 views
        0 likes
        Last Post poeds
        by poeds
         
        Working...
        X