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

Converting from eSignal to Ninja code

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

    Converting from eSignal to Ninja code

    Hello,

    I am trying to convert from eSignal & Ninja to Ninja alone. The set of functions available from Ninja when using eSignal is nicely packaged and easy to understand.

    I am a little confused when it comes to converting my eSignal efs code to C# in Ninja. I am not sure if I should go the ATM route of placing and handling orders, or simply placing orders via EnterLong.... I believe I understand how everything would be handled using the ATM route, but I am trying to understand all my other options.

    My reason for leaning towards not using the ATM route, is that my signals change often, so orders are placed, cancelled and changed with frequency. Once in a trade, I also change my stops often as the trade advances with ticks and time. I also trade thinner markets some times and monitor the charts closes as the system auto trades. There are rare times where I will manually move the stops if there are time lapses between trades and it is nearing my stops.

    I have 2 questions. If I use EnterLongStopLimit() a way of entering a trade for example, how do I?

    1. Monitor the current state of that order? I use this to monitor fills so that I can place stops and targets.

    2. Find out if I am long, short or flat in a certain symbol in a certain account? I realize that now that I running this strategy on a chart in Ninja and an account is specified, I really only need to know the current position of strategy. I will have this same strategy running on other symbols in the same account.

    It is not clear to me if the GetAtmStrategyMarketPosition() and GetAtmStrategyEntryOrderStatus() will work, as the trades would not be entered using the Atm.... commands.

    I've explained the background more than the questions warrant looking for any comments on which way to go, or possibly another route entirely.

    Thanks,
    Tiara

    #2
    Hello,


    Generally entering a trade using an ATM strategy in NinjaScript is only advisable if the ATM's will provide the functionality you want. Also, it sound like you manually modify your trades, in this case you can only do this with an ATM and not with EnterLong() for example.

    You can best monitor an order via IOrder:


    You can best monitor a position via IPosition:


    This reference sample also has useful information regarding money management and trades that you will probably find useful:


    Note:
    There is a clear distinction between the ATM methods and the regular NinjaScript order methods. You cannot mix and match the two methods.
    Last edited by NinjaTrader_Ben; 12-22-2008, 09:28 AM.
    DenNinjaTrader Customer Service

    Comment


      #3
      OnBarUpdate (), check order status

      Ben,

      Thanks that helps steer me in the right direction.

      I can see how to check the state of the order within OnOrderUpdate, but is there a way to check on the order's state within OnBarUpdate?

      Thanks,
      Tiara

      Comment


        #4
        You can access the IOrder object's state anywhere in your code. It is not recommended you run this logic from OnBarUpdate() though because the underlying order state can change while you are processing OnBarUpdate() and you will not receive this state.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Correct Syntax

          Josh,

          Thanks.

          Would this be the correct syntax?

          Thanks,

          Tiara



          protectedoverridevoid OnBarUpdate()
          {
          if (EntryOrder.OrderState != OrderState.Working)
          {
          ......
          }
          }

          protectedoverridevoid OnOrderUpdate(IOrder order)
          {
          if (EntryOrder != null && EntryOrder.Token == order.Token)
          {
          if (order.OrderState == OrderState.Cancelled && order.Filled == 0)
          {
          EntryOrder =
          null;
          }
          }
          }
          Last edited by tiara50; 12-24-2008, 12:57 PM.

          Comment


            #6
            You have to check for null references first. Please see: http://www.ninjatrader-support2.com/...ead.php?t=4226
            Josh P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by andrewtrades, Today, 04:57 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by chbruno, Today, 04:10 PM
            0 responses
            5 views
            0 likes
            Last Post chbruno
            by chbruno
             
            Started by josh18955, 03-25-2023, 11:16 AM
            6 responses
            436 views
            0 likes
            Last Post Delerium  
            Started by FAQtrader, Today, 03:35 PM
            0 responses
            7 views
            0 likes
            Last Post FAQtrader  
            Started by rocketman7, Today, 09:41 AM
            5 responses
            19 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X