Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

From TS To Ninja

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

    From TS To Ninja

    I am transferring my TradeStation code into Ninja script. I will have a lot of questions in the next few days and would appreciate your patience. Maybe one day we could have a translation dictionnairy !


    Do you know how I could translate these lines ? :

    LastBarOnChart;

    FracPortion(ComputerDateTime);

    IntPortion(value1);


    Thank you so much

    #2
    blarouche,

    Unfortunately we are not EasyLanguage experts here.

    LastBarOnChart is always the index of [0]. You are always on the "last bar" of a chart at any given point in time. There is no peaking into the future in NinjaTrader.

    If FracPortion gets the decimal places, then just subtract the whole number portion from the double and then you are left with the decimal.

    If IntPortion means the whole number part, cast the variable to an int.
    someInt = (int) value1;
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      TS to Ninja

      Josh

      Here is the full line for the fracPortion function I am trying to translate:

      StartTime = FracPortion(ComputerDateTime)*86400;

      That converts the fraction portion of time to seconds...


      Thanks

      Comment


        #4
        Unfortunately we are not EasyLanguage experts. You would have to figure out what exactly that method does and how it does it to translate it properly.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          EL Translation

          Hi,
          To translate the EL code you will have to go into the EL script and right click on the FracPortion function then paste that code here. Once we see what the function does it should be easier to convert it to the Ninja Script language. I have written a lot of EL stuff over the years, but I am new to this Ninja C# script stuff. I will help if I can.
          Widgetman

          Comment


            #6
            Hi WidgetMan

            Thank you for your help but I found a way to get what I wanted in the different way.


            If you are interested I can show you what I did

            Bernard

            Comment


              #7
              I don't know if this can help anyone, and I would also appreciate anyone's critic.


              It's very basic. Any improvements are welcomed!

              FracPortion() will get the decimal value to the right of the price. It works on the TF and ES. I have not tested elsewhere.

              Usage example:
              int fracPortion = FracPortion(Close[0]);


              Here is my version of FracPortion()
              Code:
               
              public int FracPortion(double d_price)
              {
              // strip off decimal via a cast of double to int
              int i_price = (int) d_price;
               
               
              // get decimal value from Close[0]
              double tickValue = s.Instrument.MasterInstrument.Round2TickSize((d_price - i_price)) * 100;
               
              return (int) tickValue;
              }
              Last edited by r2kTrader; 09-24-2009, 02:26 PM.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              578 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              334 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              101 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              554 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              551 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X