Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

LinReg crossover strategy

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

    LinReg crossover strategy

    I am new to NT8 community transitioning from TradeStation. Trying to build a strategy using LinReg and LinRegSlop on Renko 5 period. With LinReg period at 400, trying to code this algo. Anyone can help with the order management piece of it. I am trying to enter trade with LinRegSlop > 0.15 for long entry when crosses over GetCurrentBid() or Close and LinRegSlop < -0.15 when crosses over for short entry.
    I tried Strategy Builder but clearly messed up.
    then I am copying codes from indicators to develop this.
    what code should I use to Place limit orders with Stop at 21 ticks and targets at 300 ticks?

    any suggestions - looking for some help.

    anshuman

    #2
    Hello anshuman,

    Thanks for your post.

    The LinRegSlope indicator could be compared to a numerical value to detect if it is Greater than or Less than 0.15 or -0.15.

    For example, you could create a condition that check if the LinRegSlope indicator (Indicators folder > LinRegSlope) is greater than a numerical value (Misc folder > Numerical value) of 0.15 and call an action of EnterLong() (Order management folder > Enter long position).

    You could consider using the Stops and Targets screen to create a stop loss and profit target a set number of ticks away from the Entry order.

    See the 'How to make indicator to value comparisons' section of this help guide page:



    See the 'How to create a crossover condition' section on the help guide page linked above for information about creating crossover conditions.

    Stops and Targets screen:
    https://ninjatrader.com/support/help...er_screens.htm

    Below is a link to a forum post with helpful information about getting started with NinjaScript.
    https://ninjatrader.com/support/foru...040#post786040
    Last edited by NinjaTrader_BrandonH; 06-18-2023, 03:20 PM.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Thanks Brandon for the detailed guidance. couple of fundamental questions on order management. When I use EnterLong or EnterShort - are they triggering market order or limit order? If Market order - how do I use limit order with Target and Stop defined ? any codeset you can point me to?

      Comment


        #4
        Hello tanagoswami,

        The EnterLong/EnterShort methods will submit market orders.

        To submit limit orders, you could use the 'Enter long position by a limit order' option or 'Enter short position by a limit order' option in the Order Management folder.

        Once those limit orders are filled, the stops and targets you create on the Stops and Targets screen of the Strategy Builder will submit protective orders.

        See this help guide page for more information:

        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment


          #5
          Thanks Brandon. I have another problem. I am using strategy builder to create it. While trying to compile it, its throwing some error. Now I am unable to launch Strategy Builder. This is the error message its throwing. I am unable to edit the code in Ninjascript Editor also. Can you suggest my next steps - I am kind of stuck

          Comment


            #6
            here is the error screen dump Brandon
            Attached Files

            Comment


              #7
              Hello tanagoswami,

              Thanks for your notes.

              Please follow the instructions below to see where the errors are coming from after compiling any indicator.

              For NinjaTrader 8:
              • Open NinjaTrader
              • From the Control Center select the New menu--> select NinjaScript Editor
              • Right-click in the window and select Compile to compile all NinjaScript objects
              • At the bottom of the NinjaScript Editor window, a new section will appear where you can find the error locations
              • You can exclude the file referenced in the editor by double-clicking on the appropriate object type on the right of the NinjaScript Editor window. This will expand the object type folder. You can then select the file with a left-click--> right click on the object--> then select Open to begin debugging the file, Exclude From Compilation, or Remove to delete the file.
              If you are unsure as to what the error is indicating, please send me a screenshot of the NinjaScript File column and Error column fully visible (not to be confused with the Code column)
              • To send a screenshot with Windows 7 or newer I would recommend using Windows Snipping Tool.
              • Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screenshot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save as a jpeg file and send the file as an attachment.
              We have also collected more comprehensive steps for resolving NinjaScript programming errors in this tip in our Help Guide:
              Please let us know if we may be of further assistance.​
              <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NullPointStrategies, Yesterday, 05:17 AM
              0 responses
              56 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              132 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              73 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              45 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              49 views
              0 likes
              Last Post TheRealMorford  
              Working...
              X