Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Newbie: error in the code

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

    Newbie: error in the code

    Hello,

    I just discover the power of Automated Trading with NT but I have a problem with the following code at Condition set 3 where the condition does not go through the compiler... To be clear I with to use a SMA of the absolute value of an oscillator... What is the correct syntax?
    Thanks in advance

    ...

    Condition set 3
    if (SMA(Math.Abs(PriceOscillator(2, 10, 1)),222)[0] >= 0)
    {
    PlaySound("");
    }


    #2
    Hello,

    Is it because Math.Abs() requires a value, not a series.
    For example this compiles:
    double test = Math.Abs(PriceOscillator(2, 10, 1)[0]);
    But this doesn't:
    double test = Math.Abs(PriceOscillator(2, 10, 1));

    For former refers to a value, and the latter refers to a series.
    DenNinjaTrader Customer Service

    Comment


      #3
      Easier Way?

      OK.
      But if Math.Abs() does not accept a series, how to compute a SMA of absolute values of values of an indicator?
      Do I need to use a loop to compute one by one the values such that

      sum=0;
      for (int k = 1; x <= 222; x++)
      {

      sum = sum + Math.Abs(PriceOscillator(2, 10, 1)[k]);
      }
      sum=sum/222;

      or is there any easier way?

      Comment


        #4
        Hello,

        I don't think so. I would create a dataseries to store the absolute values, then use that dataseries in your SMA. This link shows how to create a dataseries:
        DenNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by futureszone, Today, 01:57 AM
        0 responses
        11 views
        0 likes
        Last Post futureszone  
        Started by zhangjc, 11-29-2024, 11:22 AM
        2 responses
        20 views
        0 likes
        Last Post zhangjc
        by zhangjc
         
        Started by SATORI IKIGAI, Yesterday, 02:18 PM
        2 responses
        19 views
        0 likes
        Last Post SATORI IKIGAI  
        Started by firstlanetech, Yesterday, 11:31 PM
        0 responses
        5 views
        0 likes
        Last Post firstlanetech  
        Started by AH369, 07-03-2024, 10:17 AM
        8 responses
        835 views
        1 like
        Last Post Karado58  
        Working...
        X