Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Equity Trading Strategies

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

    Equity Trading Strategies

    Hi,

    I am looking to test strategies that are automated with equities too. Futures work good. With equities, I get the charts premarket and regular market working buy using Default 24/7 Trading Hours. When I manually enter or exit trades it is working too. When I enable some test strategies for automation, though, they come up on the chart but they never take the trades in the account it should be doing. I created a new SIM account in NT for this and it is still not taking the trades even though executions are taking place in the strategy for equities.

    What are some things I can look at to get this working for equities?



    Greg

    #2
    Hello Greg,

    NinjaScript Strategies will work with any tradable security type (instrument type) by default.

    Have you written explicit code to prevent the script from evaluating in OnBarUpdate() if the instrument type is equity?

    If you have not, if the expected trade(s) are not appearing, this would indicate that the condition to place the order is not evaluating as true and the order is not being submitted, or the order is being ignored for other reasons, or the order is being cancelled.

    To understand why the script is behaving as it is, such as placing orders or not placing orders or drawing objects when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

    In the strategy add prints (outside of any conditions) that print the date time of the bar and all values compared in every condition that places an order.
    The prints should include the time of the bar and should print all values from all variables and all hard coded values in all conditions that must evaluate as true for this action to be triggered. It is very important to include a text label for each value and for each comparison operator in the print to understand what is being compared in the condition sets.

    Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

    Further, enable TraceOrders which will let us know if any orders are being ignored and not being submitted when the condition to place the orders is evaluating as true.

    I am happy to assist you with analyzing the output from the output window.

    Run or backtest the script and when the output from the output window appears save this by right-clicking the output window and selecting Save As... -> give the output file a name and save -> then attach the output text file to your reply.

    Below is a link to a forum post that demonstrates using informative prints to understand behavior and includes a link to a video recorded using the Strategy Builder to add prints.
    https://ninjatrader.com/support/foru...121#post791121

    Please let me know if I may further assist with analyzing the output or if you need any assistance creating a print or enabling TraceOrders.​
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      NinjaTrader_ChelseaB Thanks. It is just a Strategy Builder strategy. What would I have to adjust there to be sure it will work with equities if it is to already set by default to do so? Nothing done in the Strategy Builder I see that would prevent it. Where would I look for this? I am looking now in all the options in the Strategy Builder now.

      Well, it it is showing trades firing historically on the strategy chart when enabled and also in real-time (I watch them and see them trying to go long, short, exit etc). But, it is not actually executing in the SIM account is what I am saying. Does that make better sense?

      So, it is evaluating as True 100% as I see the executions coming in on the chart and executions.

      The strategies show trades actually here https://www.screencast.com/t/wxnfnP2ib but not in the actual SIM account I have chosen in the chart trader to be used before enabling the strategy here https://www.screencast.com/t/NSq7G2MR4 The few trades for the $9.97 was me manually entering a few trades to be sure it was working earlier FYI but now strategy trades are in it yet for equities.

      Yea...backtests work too and show the executions as normal.

      Let me know additional thoughts given this?



      Greg

      NOTE: Update....I just noticed something... see here https://www.screencast.com/t/wxnfnP2ib​ (it shows the trades are going into SIM 101 actually. So, I guess that is the issue. How do I be sure it is using the right account I want?

      Update #2...I think I see the issue...in the strategies just prior to enabling, have to choose the right account...I thought I could change the chart trader to dictate that...guess not. Thanks so much for your input! It is good to go now...
      Last edited by birdog; 01-18-2023, 10:40 AM.

      Comment


        #4
        Hello birdog,

        The Strategy Builder does not have a control for limiting to a specific security type. The script would have to be unlocked and coded by hand to add something advanced like this.

        This indicates the strategy conditions did not evaluate as true with the data provided, or the orders were submitted, cancelled, or rejected.

        The output from the added prints will provide the answer as to why.


        Well, it it is showing trades firing historically on the strategy chart when enabled and also in real-time (I watch them and see them trying to go long, short, exit etc). But, it is not actually executing in the SIM account is what I am saying. Does that make better sense?
        This does not quite make sense.

        'firing historically on the strategy chart when enabled and also in real-time' on what account, the Sim101?
        Do mean when the Sim101 account is selected in the Account drop-down in the Strategies window, the orders are not going to your live funded brokerage account?
        Do you mean when the funded brokerage account is selected in the Account drop-down of the Strategies window, orders are placed, but when adding a new instance of the strategy and selecting the Sim101 in the Account drop-down of the strategy parameters in the Strategy window no historical orders are appearing on the chart?

        In historical, if the strategy is actually enabled, it won't matter what account is selected. If the conditions submit orders in historical they will be in the historical no matter the account.
        Are you sure the strategy is enabled?
        Is the strategy showing the Enabled checkbox checked on the Strategies tab of the Control Center?
        What Account is showing for that strategy on the Strategies tab of the Control Center?

        Note, after a NinjaScript Strategy has been enabled, do not change the Account selection, or this will prevent the strategy from enabling.
        Instead, add a new instance of the strategy to the Chart or to Strategies window in the Configured area, and select the live account or select a sim account for that new instance.​

        "in the strategies just prior to enabling, have to choose the right account...I thought I could change the chart trader to dictate that​"
        The Account selection in Chart Trader affects only the orders placed from Chart Trader. It does not affect the strategy parameters where the Account for the strategy is selected. This is the same for all trade windows such as Charts, SuperDoms, Basic Entry windows, Market Analyzer, etc. The selections in that window only affect that window and do not affect any scripts.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          NinjaTrader_ChelseaB Did you see my two updates in bold in my last reply?

          "
          NOTE: Update....I just noticed something... see here https://www.screencast.com/t/wxnfnP2ib​ (it shows the trades are going into SIM 101 actually. So, I guess that is the issue. How do I be sure it is using the right account I want?

          Update #2...I think I see the issue...in the strategies just prior to enabling, have to choose the right account...I thought I could change the chart trader to dictate that...guess not. Thanks so much for your input! It is good to go now...

          "

          Comment


            #6
            Hello birdog,

            Yes and addressed them.

            "The Account selection in Chart Trader affects only the orders placed from Chart Trader. It does not affect the strategy parameters where the Account for the strategy is selected. This is the same for all trade windows such as Charts, SuperDoms, Basic Entry windows, Market Analyzer, etc. The selections in that window only affect that window and do not affect any scripts."
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              NinjaTrader_ChelseaB all I was saying is that I found the issue and was good to go...smile.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NullPointStrategies, Yesterday, 05:17 AM
              0 responses
              65 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              139 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              75 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
              50 views
              0 likes
              Last Post TheRealMorford  
              Working...
              X