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

running strategy on Kinteick and IB

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

    running strategy on Kinteick and IB

    Hi there


    im testing out a strategy - and im trying to get it to run all calculations based on Kinetick data - but then entering the orders on the Live IB account.

    My strategy is only activated relatively rare - so it is hard to test and also see - when and where it is actually placing orders.

    I have previously got it working placing one order in the live account. But now it seems to be placing the orders into the sim101 account as you can see here on the attached image - where it placed two orders.

    Im running the samne strategy on both sim101 and on my IB account - to test if it is actually producing same result - but is that possible?/allowed? or i will have to create two different named strategies to run it like that? (I applied it onto a chart - but when i right click on that chart - and choose strategy performance - i only see one strategy to choose. )

    Yesterday i also changed all "Preffered Connnections -.historical" and all "Preffered Connnections -.real-time" to be kinetick. I do this to make sure that the data it calculates from is correct - from tick data from kinetick - but of cause i need the orders to allways be placed on IB. So should i change any settings there?

    I can also send some log info - but it seems like you dont want us to post the log files here - but let me know if i should send that.

    I also send image of the conenection and accounts - and the "order" they apppear in - but im not sure which account/connection is logged into first.

    Also - a last question - is there a way to lock which connection is used for data - and which connection is used for placing all orders - via the script?

    THanks a lot.
    Karsten








    #2
    I just realized that it actuallly did run on the correct account.
    So one question that is still remaining is - why does it only show the correct result on the sim101? - is it because that the IB account is somehow reset - on the daily shutdown?...
    I assume it is - but it would be nice to actually see the orders in the orders list - even though the orders where done the day before.

    Or - is it showing the orders for the sim101 account only - because it is running exact same script on both accounts?

    Thanks again.

    Comment


      #3
      Hello KarstenKafl,


      Im running the samne strategy on both sim101 and on my IB account - to test if it is actually producing same result - but is that possible?/allowed? or i will have to create two different named strategies to run it like that? (I applied it onto a chart - but when i right click on that chart - and choose strategy performance - i only see one strategy to choose. )
      You can apply the same strategy twice to separate accounts. I can't really comment about why only 1 strategy is selectable on the chart as I cannot see what was applied in your image. You can apply two strategies to a single chart but only one strategies executions will be displayed or the one with the selected account in chart trader. If you cannot see the strategy in the chart it may have got applied directly to the control center, that is where all strategies end up. You can also right click on the strategy from there to view its performance.

      Yesterday i also changed all "Preffered Connnections -.historical" and all "Preffered Connnections -.real-time" to be kinetick. I do this to make sure that the data it calculates from is correct - from tick data from kinetick - but of cause i need the orders to allways be placed on IB. So should i change any settings there?
      You shouldn't need to change anything else, the order will not be able to be placed to kinetick as that is not a broker so it would be sent to the selected IB account.



      I also send image of the conenection and accounts - and the "order" they apppear in - but im not sure which account/connection is logged into first.
      The order in the menu won't matter but the order you manually connect can. If you set a preferred data provider as you did then the order won't matter here.



      Also - a last question - is there a way to lock which connection is used for data - and which connection is used for placing all orders - via the script?
      Not through the script and in this use case there would be no need. As I mentioned kinetick has no account associated to it so that won't matter there, if you mean for the Sim or live account you would just need to ensure you apply the strategy to the correct account when you apply it.

      So one question that is still remaining is - why does it only show the correct result on the sim101? - is it because that the IB account is somehow reset - on the daily shutdown?...
      I assume it is - but it would be nice to actually see the orders in the orders list - even though the orders where done the day before.

      Or - is it showing the orders for the sim101 account only - because it is running exact same script on both accounts?
      I think you are saying "why is the chart only showing the Sim101 orders", have I understood that correctly? If so that would be what I had mentioned earlier or that the selected ChartTrader account will be what is displayed. You can open a second chart and select the second account using the ChartTrader to see the executions. Alternatively you can use the control center to right click on each strategy and then view each strategies performance.

      I look forward to being of further assistance.



      THanks a lot.
      Karsten
      JesseNinjaTrader Customer Service

      Comment


        #4
        Thank you Jesse for all explanation.

        Now i have run the strategy again a few times and have a few new questions.

        1.
        I have two charts open – with exactly same data.
        In the first I have entered the strategy – and enabled that and it is running ok – but it does not show the buy/sell indicators in that specific chart.
        Instead it shows it on the second chart -where there are no strategies running.
        I have enabled text and marker – on “plot execution” on both charts.
        I have chosen same Account on both charts.

        2.
        Then on this Friday 24. July the strategy went “long” – following the rules of the strategy – but if then tried the same strategy on optimization – with same input values – on the 24 july – it did not buy anything. How can that be? Is it something about it running on pr. Tick – instead of on bar close or something like that – and how can I check that?

        3.
        And my last questions. How do I make sure that the orders are filled? – I mean – do I need to code some kind of backup – that checks if the order is actually filled – especially when exiting – when I sell something?

        Thanks a lot for explaining.

        Comment


          #5
          Hello KarstenKafl,

          This is Jim, responding on behalf of Jesse who is out of the office at this time.

          Regarding #1,

          Is the strategy possibly initiating an ATM strategy and not actually submitting orders itself?

          Can you confirm that the account the strategy is applied to is the account selected in Chart Trader?

          Regarding #2,

          If the strategy is starting an ATM strategy, it will not produce results when backtesting because ATM strategies only operate on realtime data. We should also note that historical processing and realtime processing are fundamentally different. There is no intrabar movement when backtesting so logic is processed OnBarClose and orders are filled based on the OHLC values of the data series.

          If you are looking into an action that occurred with realtime data, I suggest recreating the scenario in the Playback connection and then take debugging steps to add prints to see why those conditions have become true and allowed that action to take place.

          Discrepancies between backtesting and realtime - https://ninjatrader.com/support/help...ime_vs_bac.htm

          Comparing Historical Realtime and Playback - https://ninjatrader.com/support/foru...mance?t=102504

          Playback - https://ninjatrader.com/support/help...connection.htm

          Debugging Tips - https://ninjatrader.com/support/help...script_cod.htm

          Regarding #3,

          You can use BarsSinceExitExecution or BarsSinceEntryExecution, or for a more robust approach, you can track your orders as Order objects.

          BarsSinceExitExecution - https://ninjatrader.com/support/help...texecution.htm

          BarsSinceEntryExecution - https://ninjatrader.com/support/help...yexecution.htm

          SampleOnOrderUpdate (Example for using OnOrderUpdate and tracking Order objects) - https://ninjatrader.com/support/help...and_onexec.htm

          We look forward to assisting.
          JimNinjaTrader Customer Service

          Comment


            #6
            Thank you Jim

            I recently had a strategy that started - while it should not.
            Im not sure how and what happens but it is runing on 1000 tick chart, and one condition was that (ADX1[0] > 21) - but the adx was about 15 or so when it startet.

            I noticed that the chart was looking like it was missing some hours/time - and looked bit weird - and when i choose to reload the data it maybe looked different.

            So - how can i avoid this "mistake" trade in best way? Is there no "double" checking that the data is correct? - can i set the strategy to somehow reload historical data?

            Thanks.
            Karstne

            Comment


              #7
              Hello Karstne,

              NinjaTrader will load data from the last period of time it saw data.

              A gap may come about if NinjaTrader was not connected to receive data, or if subsequent requests for data are made for a starting time after a last known segment of data. (The new data will gets loaded in, but NinjaTrader would not know there is a gap without fully requesting the data set.)

              You could ensure to run the Reload All Historical Data operation before enabling the strategy to ensure that the full set of data is available.

              I would also recommend using debugging prints when analyzing why a strategy has taken an operation as opposed to what is seen visually since what is processing in the strategy would be what triggers the logic and allows the orders to fire.

              Debugging Tips - https://ninjatrader.com/support/help...script_cod.htm

              We look forward to assisting.
              JimNinjaTrader Customer Service

              Comment


                #8
                Thanks Jim

                Now i have 2 questions.

                1. Can i do the load historical data - by script inside the strategy - like doing that each hour or so?

                2. I saw that when i used 2 charts with same 1000 ticks - it showed difference in the bars - as you can see in last bar.
                Then i reloaded all hitorical - but short after it showed same "issue".

                Can it be somethign about the start date?

                Comment


                  #9
                  Hello KarstenKafl,

                  There is a ReloadAllHistoricalData() method, but this is only intended to be called from OnConnectionStatusUpdate().


                  While this may not be helpful, a BarsRequest can be used to call out of sync data.




                  To confirm the historical tick data is from Kinetick and is not recorded from real-time data, is this correct?
                  The Trading hours template is the same in the Data Series window for both charts?
                  Chelsea B.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by RookieTrader, Today, 07:41 AM
                  2 responses
                  7 views
                  0 likes
                  Last Post RookieTrader  
                  Started by kujista, Today, 05:44 AM
                  2 responses
                  12 views
                  0 likes
                  Last Post kujista
                  by kujista
                   
                  Started by trilliantrader, Today, 08:16 AM
                  0 responses
                  3 views
                  0 likes
                  Last Post trilliantrader  
                  Started by AttiM, 02-14-2024, 05:20 PM
                  9 responses
                  175 views
                  0 likes
                  Last Post NinjaTrader_BrandonH  
                  Started by funk10101, Today, 08:14 AM
                  0 responses
                  2 views
                  0 likes
                  Last Post funk10101  
                  Working...
                  X