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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      94 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      51 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      81 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      75 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      62 views
      0 likes
      Last Post CarlTrading  
      Working...
      X