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

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 trilliantrader, 04-18-2024, 08:16 AM
      4 responses
      18 views
      0 likes
      Last Post trilliantrader  
      Started by mgco4you, Today, 09:46 PM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by wzgy0920, Today, 09:53 PM
      0 responses
      9 views
      0 likes
      Last Post wzgy0920  
      Started by Rapine Heihei, Today, 08:19 PM
      1 response
      10 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by Rapine Heihei, Today, 08:25 PM
      0 responses
      10 views
      0 likes
      Last Post Rapine Heihei  
      Working...
      X