Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

why didn't this code work

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

    why didn't this code work

    if NTMarketPosition("Uxxxxx") = 0 then
    buy this bar on close;

    #2
    Code:
    if NTMarketPosition("Uxxxxx") = 0 then begin
         //buy this bar on close;
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      thank you for your reply Josh, however I'm confused as to how I would enter an order then

      if this is correct:
      if NTMarketPosition("Uxxxxx") = 0 then begin
      //buy this bar on close;

      then would this work...
      if NTMarketPosition("Uxxxxx") = 0 then
      begin
      if condition1 then
      buy this bar on close;
      end

      2) Also, using the following functions that are in the NT DLL, will you get tradestation to successfully backtest it. Say that the following code

      if condition1 then
      buy this bar on close

      if barssinceentry = 5 then
      sell this bar on close
      * say that the above code produces 50 trades on a tradestation backtest

      now
      if NTMarketPosition("Uxxxxx") = 0 then
      begin
      if condition1 then
      buy this bar on close;
      end

      if NTMarketPosition("Uxxxxx") > 0 then
      begin
      if barssinceentry = 5 then
      sell this bar on close;
      end
      ?? would you get the 50 trades to show up on the tradestation backtest?

      Comment


        #4
        1)
        Code:
        buy this bar on close
        is not really code. To place orders you need to program the logic to send the order at the bar close and then you would use NTBuyMarket or any of the other functions listed here: http://www.ninjatrader-support.com/H...html?Functions.

        Code:
        if NTMarketPosition("Uxxxxx") = 0 then
        begin
             if condition1 then
                 buy this bar on close;
        end
        You would need two "end" to close both if statements.

        2) Unfortunately I cannot provide guidance on TradeStation's backtesting, but I would assume the codes will work theoretically. Perhaps this sample code (http://www.ninjatrader-support.com/H...SanpleStrategy) will help you in programming ELDs that use NinjaTrader in TradeStation.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          ah,

          that answers it perfectly. thank you very much

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by bortz, 11-06-2023, 08:04 AM
          47 responses
          1,605 views
          0 likes
          Last Post aligator  
          Started by jaybedreamin, Today, 05:56 PM
          0 responses
          8 views
          0 likes
          Last Post jaybedreamin  
          Started by DJ888, 04-16-2024, 06:09 PM
          6 responses
          18 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by Jon17, Today, 04:33 PM
          0 responses
          4 views
          0 likes
          Last Post Jon17
          by Jon17
           
          Started by Javierw.ok, Today, 04:12 PM
          0 responses
          13 views
          0 likes
          Last Post Javierw.ok  
          Working...
          X