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 argusthome, 03-08-2026, 10:06 AM
          0 responses
          61 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          39 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          21 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          23 views
          0 likes
          Last Post TheRealMorford  
          Started by Mindset, 02-28-2026, 06:16 AM
          0 responses
          51 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Working...
          X