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

How do I identify "First bar of day"

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

    #31
    double to int convertion

    Appreciate help in this:

    I´m trying to input an incrementing value into the SUM method that counts when [
    VolratioDS[0]>Threshold], and then resets. I need to use a dataseries value as input (I asume). But since these are doubles and the method expects an int input, I get stuck.

    When I try to pass the dataseries value (CountDS) to an int variable (count) I once again get stuck cos I "cannot convert double to int".

    Is there way to make the SUM method accept the double input, to make the dataseries an int, or to convert the dataseries double to a variable int? Any other solution?


    if (VolratioDS[0]>Threshold)
    {
    if (Crossover == false)
    {
    CountDS.Set(1);
    count = CountDS[0];
    CumvolDS.Set(SUM(VoldiffDS, count)[0]);
    Crossover = true;
    if (CumvolDS[0]>0)
    {
    Plotpos.Set(CumvolDS[0]);
    }
    else
    {
    Plotneg.Set(CumvolDS[0]);
    }
    }
    else
    {
    CountDS.Set(CountDS[0]+1);
    count = CountDS[0];
    CumvolDS.Set(SUM(VoldiffDS, count)[0]);

    if (CumvolDS[0]>0)
    {
    Plotpos.Set(CumvolDS[0]);
    }
    else
    {
    Plotneg.Set(CumvolDS[0]);
    }
    }
    }
    else
    {
    Crossover = false;
    count = 0;
    CountDS.Set(0);
    Plotpos.Set(0);
    Plotneg.Set(0);
    }



    //Fredrik

    Comment


      #32
      Lots of answeres on this if I wasn´t so lazy to ask first : ). However, I doubt I did this the most efficient way;

      CountDS.Set(CountDS[0]+1);
      countd = CountDS[0];
      counti = System.Convert.ToInt32(countd);
      CumvolDS.Set(SUM(VoldiffDS, counti)[0]);
      if (CumvolDS[0]>0)

      Comment


        #33
        FREEN, you should also be able to cast it to an int -

        Code:
         
        CumvolDS.Set(SUM(VoldiffDS, (int)countd)[0]);
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by ETFVoyageur, Today, 02:15 AM
        0 responses
        8 views
        0 likes
        Last Post ETFVoyageur  
        Started by Board game geek, Today, 01:34 AM
        0 responses
        6 views
        0 likes
        Last Post Board game geek  
        Started by morrnel, 05-12-2024, 06:07 PM
        3 responses
        42 views
        0 likes
        Last Post wzgy0920  
        Started by FishTrade, Yesterday, 11:11 PM
        0 responses
        7 views
        0 likes
        Last Post FishTrade  
        Started by Austiner87, Yesterday, 03:42 PM
        1 response
        22 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X