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 NullPointStrategies, Today, 05:17 AM
        0 responses
        52 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        130 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        70 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        44 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        49 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X