Announcement

Collapse
No announcement yet.

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.

    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.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        72 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        39 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        63 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        63 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        53 views
        0 likes
        Last Post CarlTrading  
        Working...
        X