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

Strategy Test Across Network

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

    Strategy Test Across Network

    First pass at sending orders from TS to NT across the network. I have developed a simplified strategy to get the idea of how this works, but I have have a few questions. This code looks at the high an low of the first bar of the day and buys or sells the first breakout from that range.

    How do I test this before implementing, using historical data?
    I get no errors when I run this strategy as presented below when NT is on the same machine - I also get nor orders.
    When I try to connect to a networked computer, which is what I ultimately need to do, it does not find the DLL. Note the commented code. The computer name the NT will run on is "graphics", on an XP network.

    Code:
    [IntraBarOrderGeneration = TRUE] 
    {DefineDLLFunc: "NTDirect.dll", int, "Setup", lpstr, int;}
     
    inputs: numContracts(2);
    variables:  nHigh(0), nLow(0);
    variables: lFullDay(false), success(0);
       
     
    if Date <> Date[1] then 
    begin
     lFullDay = true;
     nHigh = High;
     nLow = Low;
    { SetUp("graphics", 36973);}
    end;
    
    if lFullDay and NTConnected(1) then 
    PRINT("c:\GG.TXT", "IN");
     
     begin
      {go long if price > high  of 1st bar }
      if High > nHigh and ntMarketPosition("") = 0 then
      begin
       success = NTBuyMarket("FirstBar",numContracts); 
       print("Position Size:  " + NumToStr(NTMarketPosition(""),0));
       print("Avg Fill Price: " + NumToStr(NTAvgFillPrice("FIrstBar"),2));
      
       end;
      
       
      if Low < nLow and ntMarketPosition("") = 0  then
       begin
         success = NTSellMarket("FirstBar",numContracts);     
       print("Position Size:  " + NumToStr(NTMarketPosition(""),0));
       print("Avg Fill Price: " + NumToStr(NTAvgFillPrice("FIrstBar"),2));
      end;
      
     end;

    #2
    Hi,

    - NT needs to be running on the same PC as TS
    - You can not test this on historical data, what you can do is run this in real-time and send orders to the Sim101 simulation account
    RayNinjaTrader Customer Service

    Comment


      #3
      According to the documentation I can use TS to send orders to NT even if it is on another PC. Tech support told me this as well. Here is the user manual excerpt, excpt I cannot get it to work.
      ------------------------
      You can run NinjaTrader on different PC than where TradeStation is running via the DLL interface only.


      1. Define the SetUp function by adding the following line to your EL script:


      DefineDLLFunc: "NtDirect.dll", int, "SetUp", lpstr, int


      2. You must call the SetUp function before calling any other DLL function. Following is sample code on how to accomplish this.


      if CurrentBar = 1 then begin
      SetUp("remote-machine-name-or-ip", 36973);
      end;


      Where remote-machine-name-or-ip is the name or IP address of your PC.

      Comment


        #4
        Since you can't get it working on 2 machines, I suggest trying to get it working on one machine first.

        Comment


          #5
          My apologies, I was thinking our TS Mail interface. As Dierk suggested, set up a test bench on one machine first, iron out the kinks and then move to the multi-pc environment.
          RayNinjaTrader Customer Service

          Comment


            #6
            OK - I have done as you ask and the connection problem remains. The TS error I get is "Cannot find function SetUp in DLL file NTDirect.dll"

            I have the latest version of NT on both the TS machine and the remote machine. When I run NT on the TS machine with the DLL and setup lines commented out, the order gets placed. But when I add the additional dll code, for some reason the setup function cannot be found by TS. The dll itself is in the windows/system directory and is dated 9/5/2007


            Code:
            DefineDLLFunc: "NTDirect.dll", int, "Setup", lpstr, int;
             
            inputs: numContracts(2);
            variables:  nHigh(0), nLow(0);
            variables: lFullDay(false), success(0);
               
             
            SetUp("graphics", 36973);
            if LastBarOnChart and  NTConnected(1) then 
               If NTMarketPosition("Sim101") = 0 then 
               
             begin
              success = NTBuyMarket("FirstBar",numContracts); 
              print("Position Size:  " + NumToStr(NTMarketPosition(""),0));
              print("Avg Fill Price: " + NumToStr(NTAvgFillPrice("FIrstBar"),2));
              
             end;

            Comment


              #7
              Cancel that question - "SetUp" is case sensetive. Working fine now.

              Comment


                #8
                Thanks for reporting back.
                RayNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by ghoul, Today, 06:02 PM
                3 responses
                14 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by jeronymite, 04-12-2024, 04:26 PM
                3 responses
                44 views
                0 likes
                Last Post jeronymite  
                Started by Barry Milan, Yesterday, 10:35 PM
                7 responses
                20 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by AttiM, 02-14-2024, 05:20 PM
                10 responses
                180 views
                0 likes
                Last Post jeronymite  
                Started by DanielSanMartin, Yesterday, 02:37 PM
                2 responses
                13 views
                0 likes
                Last Post DanielSanMartin  
                Working...
                X