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

Difference between 2 EMA > 50...

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

    Difference between 2 EMA > 50...

    Hello, I'm trying to add a simple condition to my strategy. I want to have a difference between the EMA 100 and the EMA 300 at least 50 points. That should be simple..but I don't manage to do it :-(
    Thanks for your help, best regards.

    #2
    Hello TraderFred,

    Thank you for the post.

    Are you trying to use the strategy builder or manually code the strategy?

    To find the difference you would subtract one from the other. If you then wanted that reported in points you would need to use math to convert the price difference to points.

    A very simple example would be using Ticks instead and that would look like the following:

    Code:
    double tickDifference = (EMA(100)[0] - EMA(300)[0]) / TickSize;
    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks a lot. Is there a solution with strategy builder?

      Comment


        #4
        Hello TraderFred,

        With the builder you could do the subtraction however you would not be able to convert the resulting value to ticks or anything else. The best way to achieve this in the builder would be to make a complimentary indicator that goes with the strategy. The indicator could use the code shown in post 2 and Plot that result. The strategy could then read the indicators value to see what the value in ticks was.

        Please see the following for a sample of adding a Plot, you can alternatively just use the indicator wizard in the NinjaScript editor to generate a new indicator and add a Plot during that process.


        Once you have a indicator generated and have a plot you could use the following from OnBarUpdate:

        Code:
        double tickDifference = (EMA(100)[0] - EMA(300)[0]) / TickSize;
        Value[0] = tickDifference;
        The strategy could then use the indicator and its plot to retrieve the value.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by mgco4you, Today, 09:46 PM
        1 response
        3 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by wzgy0920, Today, 09:53 PM
        0 responses
        3 views
        0 likes
        Last Post wzgy0920  
        Started by Rapine Heihei, Today, 08:19 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by Rapine Heihei, Today, 08:25 PM
        0 responses
        6 views
        0 likes
        Last Post Rapine Heihei  
        Started by f.saeidi, Today, 08:01 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X