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

Strategy Builder Closing Trade On Opposing Signal

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

    Strategy Builder Closing Trade On Opposing Signal

    Hi NinjaTeam,

    When I'm running an automated strategy through strategy builder, (please note I am not a coder), once the signal has triggered and the order an placed, if there is a signal in the opposite direction my strategy closes the current trade and goes in the other direction.

    How can I stop this from happening?

    Thank you.

    #2
    Hi Trader5012, thanks for posting.

    You can add a Current Market Position check to each entry condition to make sure you are flat before entering e.g.


    This will make sure you are flat so the short condition doesn't close out of the long position.

    Best regards,
    -ChrisL
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hi Chris,

      Thank you for your reply. It worked perfectly.

      I've recently has a coder create a new strategy for me as it seemed too difficult to build through strategy builder.

      I've tried to run the strategy through strategy analyzer and although it sees the strategy and its input, it comes back with no data when I try to run it.

      Do you know of a third part software that I can use to back test strategies not created through strategy builder or am I missing something with strategy analyzer?

      Thank you

      Comment


        #4
        Hi Trader5012, thanks for the follow up.

        You can call Indicators through strategies, not other strategies through strategies. If you are not getting data from the indicator it means the indicator is not implementing any Plots. Any indicator used in the strategy builder must add a plot with AddPlot() and fill in that plot with values to be available from the strategy builder.

        Best regards,
        -ChrisL
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Hi Chris,

          Can you tell me the solution to why Ninja trader wont let me compile and export my strategy and what simple steps I need to do to make this work? The error is below, please note Im not a coder.

          Error compiling export assembly: c:\Users\kevin\OneDrive\Documents\NinjaTrader 8\bin\Custom\Strategies\AveragingV1AutoV1withKey.c s(36,11) : error CS0433: The type 'NinjaTrader.NinjaScript.Indicators.EMA' exists in both 'c:\Users\kevin\OneDrive\Documents\NinjaTrader 8\bin\Custom\NinjaTrader.Vendor.dll' and 'c:\Users\kevin\OneDrive\Documents\NinjaTrader 8\bin\Custom\Supertrend.dll'

          Thank you,

          Comment


            #6
            Hi Trader5012, thanks for the follow up.

            The EMA indicator is being defined in two DLLs. the Vendor.dll is generated by NinjaTrader and Supertrend.dll is a custom DLL. Removing the SuperTrend DLL would be one solution. The SuperTrend DLL should not be copying this EMA code since EMA is already a default indicator in NinjaTrader 8. The creator of this DLL would need to fix this since a DLL is not source code.

            Best regards,
            -ChrisL
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Chris you are a superstar, thank you for the information above.

              Can you tell me if its possible to use strategy builder to add a daily cash profit target to an automated strategy. So lets say your auto trader has had two winning trades and the third trade goes into profit and hits your cash target for the day it will stop trading?

              So if target = $800 then close all trades and stop trading.

              Thank you Chris...

              Comment


                #8
                Hi Trader5012,

                We have an example of setting a loss limit here:
                Hello, I've updated the DailyLossLimit and DailyLosLimitMultiTrade examples that were posted on the forum for NinjaTrader 7 for NinjaTrader 8. These are often requested and I felt they are good examples to have for NT8. DailyLossLimitExample_NT7 - http://ninjatrader.com/support/forum...241#post451241 (http://ninjatrader


                Best regards,
                -ChrisL
                Chris L.NinjaTrader Customer Service

                Comment


                  #9
                  Hi Chris,

                  When using strategy builder and having it take entries on signals, how do I get the strategy to ignore previous signals before going flat?

                  So whats happening is, if I enable the strategy or disable it and then re-enable it, it waits for the previous signal to hit either its profit target or stop if there was a previous signal (before turning green from yellow in the control panel) and then looks for the next signal.

                  So if im waiting for a setup, I see one, enable the strategy, if the previous signal hasnt gone flat it doesnt take the new signal and entry that I was waiting for.

                  So in a nut shell, what can I use within strategy builder to ignore all previous signals when I enable the strategy?

                  Thank you
                  Kevin

                  Comment


                    #10
                    Hi, thanks for your reply.

                    You would need to unlock the script and add this to the top of OnBarUpdate:

                    if(State == State.Historical)
                    return;

                    Another way, but also requiring the script to be unlocked, would be to use AdoptAccountPosition as the startup behavior.

                    Best regards,
                    -ChrisL
                    Chris L.NinjaTrader Customer Service

                    Comment


                      #11
                      BINGO! Worked a treat - thanks again Chris.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by DJ888, Yesterday, 10:57 PM
                      0 responses
                      6 views
                      0 likes
                      Last Post DJ888
                      by DJ888
                       
                      Started by MacDad, 02-25-2024, 11:48 PM
                      7 responses
                      158 views
                      0 likes
                      Last Post loganjarosz123  
                      Started by Belfortbucks, Yesterday, 09:29 PM
                      0 responses
                      7 views
                      0 likes
                      Last Post Belfortbucks  
                      Started by zstheorist, Yesterday, 07:52 PM
                      0 responses
                      7 views
                      0 likes
                      Last Post zstheorist  
                      Started by pmachiraju, 11-01-2023, 04:46 AM
                      8 responses
                      151 views
                      0 likes
                      Last Post rehmans
                      by rehmans
                       
                      Working...
                      X