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

Trading Stocks

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

    Trading Stocks

    Hello,

    I am currently working on converting my strategy that trades futures into a strategy to trade stocks. I am having difficulties with the Stop Loss and Take Profit portion of the strategy which works fine with futures instruments. Do you have any tutorials or information regarding any special considerations needed to trade stocks? Or do you have a sample of a stock trading strategy that I can leverage to complete my project? Thank you.

    JD

    #2
    Hello JD,

    Thanks for your post.

    The NinjaScript strategy framework should be agnostic to the asset type traded against as long as proper quantities are used.

    Could you elaborate on the specific issue you are having so we can assist further? What exact issue are you having with targets and stops?

    We look forward to assisting.
    JimNinjaTrader Customer Service

    Comment


      #3
      Jim, thank you much for getting back to me. Here are some screen shots from my current set up. I have the strategy working on futures perfectly fine, stop and take profit based on TICKS. The stop and profit that I would like to set up for stock is based on percentages from entry price. I do have multiple entries based on my indicator for entering trades, it can take several entries (entry_1,2 and 3) there is also an entry when EMA's cross, such cross is also used to close or enter portions.
      Last edited by Dhjesus; 08-19-2020, 08:20 AM.

      Comment


        #4
        Hello JD,

        Thanks for your reply.

        Is this Buy order a historical order or an order that was submitted with realtime data? You may reproduce the behavior with the Playback Connection if the order was made with realtime data.

        When you test with TraceOrders enabled, can you confirm that the Profit Target has reached a state of Working? TraceOrders is set in the Strategy Builder under Default Properties and under More Properties. Once set, you can remove/re-add the strategy and test again. TraceOrders feedback will be noted in a NinjaScript Output window (Control Center > New > NinjaScript Output.)

        Playback - https://ninjatrader.com/support/help...connection.htm

        I look forward to your reply.
        JimNinjaTrader Customer Service

        Comment


          #5
          Jim. I was able to make some changes at it seems like I am 90% there. The only issue left to be resolved is that I have a condition (a basic Ema cross over) working inside the strategy. I have assigned a different signal name (CROSS) and created a separate Stop and Profit parameter for it. It looks like is bypassing the Profit and Loss parameter and only closes position when Ema crosses again. I would like to have a TP and SL for the “cross” entry and not wait until emas cross over to close position. I am not sure why it does that in this strategy. The same exact strategy trades futures and I don’t have that issue.
          Attached Files
          Last edited by Dhjesus; 08-19-2020, 04:26 PM.

          Comment


            #6
            Ok, I have done more work and I believe the issue could be because TIF is day, that’s the only thing I can think of. I have reduced TP and SL to a smaller number and it works like is supposed to as long as it doesn’t go into the next day.

            Comment


              #7
              Hello JD,

              If the strategy calls EnterLong when the strategy is Short or EnterShort when the strategy is Long, the strategy will reverse positions.

              Please see the link below for how market position checks can be made. (Additional Conditions tips can be found here as well.)

              Making Market Position checks - https://ninjatrader.com/support/help...ionComparisons

              The Time In Force setting is set from the Strategies dialog when enabling a strategy (Chart > Right Click > Strategies,) and you can check the Orders tab of the Control Center to see if orders are submitted with a Time In Force of GTC or DAY.

              Also as a tip, high quality screenshots can be taken directly from your PC.

              To send a screenshot with Windows 7 or newer I would recommend using the Windows Snipping Tool.

              Click here for instructions

              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.

              Click here for detailed instruction

              We look forward to assisting.
              JimNinjaTrader Customer Service

              Comment


                #8
                Thanks Jim. I apologize for the low quality screen shots,I think there are issues with the way NinjaTrader handles equities transactions and TIF, it doesn't look like the information transfer over from session to session. I have been experimenting and I am getting different results when "exit on session close" is unchecked, please see attached screenshots.
                Attached Files

                Comment


                  #9
                  Here is a screen shot with TIF set up as GTC, strategy works as designed but I guess it won't work in a live environment since it requires to be set up for TIF to be DAY.
                  Attached Files

                  Comment


                    #10
                    Hello JD,

                    Thanks for the screenshots. The question is very clear.

                    Time In Force affects how often the orders are to stay alive. When set to DAY the orders will be cancelled at the end of the session.

                    More info on TimeInForce - https://ninjatrader.com/support/help...imeinforce.htm

                    Exit On Session Close uses the End Of Day as defined in the Trading Hours template to determine when the session close is to signal the strategy to close out an open position.

                    If we have TIF set to DAY and ExitOnSessionClose unchecked, I would expect to see circumstances where a position is entered, the protective orders get cancelled from TimeInForce, and the position is left open. The results you are seeing would be normal since we are changing ExitOnSessionClose and TimeInForce.

                    You could consider checking the strategy position on IsFirstBarOfSession and if there is an open position, to set a bool "NeedToProtect" to true. If "NeedToProtect" is true, you can call Exit methods in Conditions and Actions to protect the position that was left open over night.

                    Making Market Position comparisons - https://ninjatrader.com/support/help...ionComparisons

                    I have also attached an example that demonstrates using Exit methods for stop/target orders fin Conditions and Actions.

                    Let me know if there is anything else that needs clarity.
                    Attached Files
                    JimNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by DanielTynera, Today, 01:14 AM
                    0 responses
                    2 views
                    0 likes
                    Last Post DanielTynera  
                    Started by yertle, 04-18-2024, 08:38 AM
                    9 responses
                    40 views
                    0 likes
                    Last Post yertle
                    by yertle
                     
                    Started by techgetgame, Yesterday, 11:42 PM
                    0 responses
                    10 views
                    0 likes
                    Last Post techgetgame  
                    Started by sephichapdson, Yesterday, 11:36 PM
                    0 responses
                    2 views
                    0 likes
                    Last Post sephichapdson  
                    Started by bortz, 11-06-2023, 08:04 AM
                    47 responses
                    1,615 views
                    0 likes
                    Last Post aligator  
                    Working...
                    X