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

Looking for some MetaTrader MQL 4 equivalents in NinjaScript

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

    Looking for some MetaTrader MQL 4 equivalents in NinjaScript

    Hi,

    I’m currently migrating a large MetaTrader MQL4 program to NinjaScript and am looking for some equivalents:
    How can I retrieve in NinjaScript:
    - the number of digits after decimal point for the current symbol prices (in MQL4: Digits)


    - the current symbol point value in the quote currency, e.g. 0.0001 (in MQL4: Point). I’m not talking about the TickSize here.


    - The minimum order quantity for an instrument (in MQL4: MarketInfo (Instr, MODE_MINLOT)


    - The maximum order quantity for an instrument (in MQL4: MarketInfo (Instr, MODE_MAXLOT)


    - The step for changing the order quantity (in MQL4: MarketInfo (Instr, MODE_LOTSTEP)


    - The directory, from which NinjaTrader was launched (in MQL4: TerminalPath())


    - The currency of the account (in MQL4: AccountCurrency())

    - The minimum distance from the current price for a stop (in MQL4: MarketInfo (Instr, MODE_ STOPLEVEL))

    Is there a way to draw text using x- and y-coordinate, instead of x-bars ago and y-coordinate?
    Thanx in advance for any help.

    - forexfan

    #2
    Hello forexfan,
    Welcome to the forum and I am happy to assist you.

    - the number of digits after decimal point for the current symbol prices (in MQL4: Digits)
    You have to custom code it to do it. Please refer to this post which further demonstrates it


    - the current symbol point value in the quote currency, e.g. 0.0001 (in MQL4: Point). I’m not talking about the TickSize here.
    0.0001 is the TickSize only in NinjaScript. Please refer to our help guide to know more.


    - The minimum order quantity for an instrument (in MQL4: MarketInfo (Instr, MODE_MINLOT)
    - The maximum order quantity for an instrument (in MQL4: MarketInfo (Instr, MODE_MAXLOT)
    There is no minimum or maximum order quantity property in NinjaScipt.

    - The step for changing the order quantity (in MQL4: MarketInfo (Instr, MODE_LOTSTEP)
    To change the order quantity simply reassign the order again. For example if you have an limit order like:
    Code:
    EnterLongLimit(2, Close[0] - 10 * TickSize, "");
    and you want to change the order quantity to say 1, then just reassign the order as:
    Code:
    EnterLongLimit(1, Close[0] - 10 * TickSize, "");
    - The directory, from which NinjaTrader was launched (in MQL4: TerminalPath())
    You can use the below unsupported codes to do it.
    Code:
    Cbi.Core.SourceDir;         //installation folder
    Cbi.Core.UserDataDir;      //My Documnets/NinjaTrader 7 folder

    - The currency of the account (in MQL4: AccountCurrency())
    You can use the below unsupported code to do it
    Code:
    Instrument.MasterInstrument.Currency


    - The minimum distance from the current price for a stop (in MQL4: MarketInfo (Instr, MODE_ STOPLEVEL))
    Unfortunately there are no codes for it.

    Is there a way to draw text using x- and y-coordinate, instead of x-bars ago and y-coordinate?
    Yes, you can look into the unsupported properties in the ChartControl class to do it, however nothing we would officially support.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Hello Joydeep,
      thank you for your quick reply. That helps a lot!
      I have another question:
      Is there a way to directly access the properties of a DrawObject by tag without having to loop through DrawObject, e.g.
      DrawHorizontalLine (“TheLine”, …)
      Something like
      ThePrice = DrawObjects[“TheLine”].y


      Forexfan

      Comment


        #4
        Hello ForexFan,
        Yes, you can do it. Please refer to the below code which further demonstrates it

        Code:
        this.DrawRay("ray", 10, Close[0], 0, Close[0], Color.Blue); 
        IRay ray = (IRay)DrawObjects["ray"];
        Print(ray.Anchor2Y);
        Please note a NinjaScript code can access the draw objects created by it or manually drawn by the user. A NinjaScript code cannot access a draw object drawn by another NinjaScript code.
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Hello Joydeep,
          great, thank you!

          When using SetStopLoss():
          How can I handle possible errors?
          And which errors does SetStopLoss() return, if at all?

          Thanx again.
          Forexfan

          Comment


            #6
            Hello forexfan,
            To assist you further may i know what errors are you receiving using the SetStopLoss() method.
            JoydeepNinjaTrader Customer Service

            Comment


              #7
              Hello Joydeep,

              I'm still in the compilation phase, so my considerations are theoretical. But I can think of many possible errors:

              - What if my StopLoss price is too close to the current price? There might be a minimum distance for the SL, given by the broker.

              - What if my SL is beyond the price? Will the position be closed then or will I get an error to tell me?

              - What if NinjaTrader lost the connection to the broker and therefore the order could not be executed?

              ...

              My question about error handling applies to all order functions: Enter*(), Exit*(), CancelOrder() ... :

              How will I know about errors?

              Thanx.

              Forexfan

              -

              Comment


                #8
                Hello Forexfan,
                I would suggest contacting your broker on how it handles the stop orders or if they have any specific set of rules.

                In NinjaTrader you can handle order rejections. Please refer to our help guide to know more about it
                JoydeepNinjaTrader Customer Service

                Comment


                  #9
                  Hello jimmyjjohn,

                  Welcome to the NinjaTrader support Forums!

                  1. Data - NinjaTrader is able to pull Historical Data from your IB account, but it is going to be limited to their API limitations.

                  2. Range Bars - They are built into NinjaTrader, but the only trouble that I foresee is that IB does not have any Historical Tick data, which is going to be required to generate Historical Bars for your Range chart. While, NinjaTrader is able to save the real-time data as Historical, if you get disconnected or if NinjaTrader is not running you will be missing data. For this reason, you may want to have a another data provider that supports Historical Tick data like Kinetick that you can add.



                  3. Easy Language - While, NinjaScript is based on the C# Language that is very powerful, we do have a Strategy Wizard that you may use to get started with NinjaScript that you may code a simple strategy without even writing a single line of code. If you are interested in looking into this you may view our Help Guide at the link below.



                  I'm also proving a link to a recently recorded 'Automated Strategy Development Webinar' video for you to view at your own convenience.
                  Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.


                  4. Trade Desk - Although, NinjaTrader is not a broker or a Data Provider we have a large number to choose from which you may view at the following link:



                  5. Strategy on Platform's Server - We have a partner called http://www.speedytradingservers.com/ that you may try out that has dedicated servers where you may install NinjaTrader on so that way NinjaTrader is not running on your Local Computer and are dedicated near most exchanges.

                  Let me know if you have any further questions.
                  JCNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by PaulMohn, Today, 03:49 AM
                  0 responses
                  6 views
                  0 likes
                  Last Post PaulMohn  
                  Started by inanazsocial, Today, 01:15 AM
                  1 response
                  9 views
                  0 likes
                  Last Post NinjaTrader_Jason  
                  Started by rocketman7, Today, 02:12 AM
                  0 responses
                  10 views
                  0 likes
                  Last Post rocketman7  
                  Started by dustydbayer, Today, 01:59 AM
                  0 responses
                  4 views
                  0 likes
                  Last Post dustydbayer  
                  Started by trilliantrader, 04-18-2024, 08:16 AM
                  5 responses
                  23 views
                  0 likes
                  Last Post trilliantrader  
                  Working...
                  X