Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

I need help

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

    I need help

    I have to issues,

    1 - I need to find the amount of decimal places. The problem is that if the variable (in this case if opening price is 1.3200 Open[0] will return 1.32 instead of 1.3200. I am using this:

    //Calculates the ammount of decimal places

    string str = Convert.ToString(Open[0]);
    string[] afterdot = str.Split('.');
    string strfinal = Convert.ToString(afterdot[1]);
    int Length = strfinal.Length;

    Print("The Length Variable is" + Length);

    In this case if the open price is 1.3200 Open[0] will return 1.32 and afterdot[1] will return 2 instead of 4. Is there a better way to accomplish this?


    2 - The second problem is related to the first one. I am trying to convert Open[0] - Close[0] to pips. So I am using the variable Length for the amount of zeroes to multiply to this difference (Open[0] - Close[0]). I cant concatenate the zeroes.

    //Round the body size. Convert to positive. Pass along the number of decimal places for the instrument.

    actualbodysize = Math.Abs(Math.Round(Close[0] - Open[0],Length));


    string cerodigits = "0";

    for (int t = 0; t == Length; t++)
    {
    cerodigits = String.Concat(cerodigits, "0");
    }
    Print("cerodigits variable is " + cerodigits);
    int actualbodysizepips = (int.Parse("1" + cerodigits) * Convert.ToInt32(actualbodysize));

    Print("Actualbodysizepips variable is " + actualbodysizepips);
    Print("Actual Body Size" + actualbodysize);
    Print("Actual Body Size in pips" + actualbodysizepips);

    cerodigits variable is returning 0 instead of 0000
    actualbodysizepips is giving me 0 .

    Is there a better way to to this. All this is to find the amount of pips Close - Open. Help

    #2
    Hello MillenniumTrader,
    1. Instead of using Open[0] if you try using TickSize then can you get the correct values.

    2. I would suggest using TickSize to calculate the number of pips in the Open - Close range

    Code:
    actualBodySize = Math.Abs((Close[0] - Open[0]) / TickSize);
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Joydeep View Post
      Hello MillenniumTrader,
      1. Instead of using Open[0] if you try using TickSize then can you get the correct values.

      2. I would suggest using TickSize to calculate the number of pips in the Open - Close range

      Code:
      actualBodySize = Math.Abs((Close[0] - Open[0]) / TickSize);
      http://www.ninjatrader.com/support/h...l?ticksize.htm

      I my god, that single line made the whole thing. Thank youuuuu.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      587 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      341 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      103 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      555 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      552 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X