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

How to close the trade running in a strategy from the chart trader screen

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

    #16
    Thanks Chelsea, please correct me if I am wrong but for now my understanding is that I can use this "Button Strategy" template and incorporate my own strategy logics and thus will be able to manually enter and exit my strategy using those neat buttons, correct ? On a separate note, I tried to use this strategy as it is on 1 Min Bar Chart just for the pure heck of it on my SIM account and nothing happened. Any peculiar settings that needed to be correct ? I am enclosing the current logics build in in those example.

    {
    if (longButtonClicked
    && Close[1] >= MAX(High, 2)[2] + 0 * TickSize
    && High[1] < CurrentDayOHL().CurrentHigh[1]
    && High[0] > High[1])
    EnterLong();

    if (shortButtonClicked
    && Low[1] > CurrentDayOHL().CurrentLow[1]
    && Low[0] < Low[1]
    && Close[1] < MIN(Low, 2)[2] - 0 * TickSize)
    EnterShort();

    if (!longButtonClicked
    && Position.MarketPosition == MarketPosition.Long)
    ExitLong();

    if (!shortButtonClicked
    && Position.MarketPosition == MarketPosition.Short)
    ExitShort();
    }

    Comment


      #17
      Hello kazbek966,

      Yes, the example strategy demonstrates how to add buttons to the chart UI and place orders from a strategy with custom logic.

      Did your logic evaluate as true?

      Do you have prints have can provide output from to show that the after the button was clicked these conditions were true?

      If not, print the time, print all values used in the conditions outside of the condition.

      Below is a link to a forum post that demonstrates using Print() to understand behavior.


      Or test something simple. If you remove the conditions and just place an order on each button click with no conditional logic, (with EntriesPerDirection set to a high number like 999), do you see the orders?
      Chelsea B.NinjaTrader Customer Service

      Comment


        #18
        Corrections, Chelsea, looks like strategy fired up right now upon price exceeding high of the day on the long side.
        It appeared that was strategy logic. And I was able to terminate it but clicking on the ExitLong.
        If I would like to incorporate my own strategy logic into those template, can I just copy paste/replace, what is between
        parenthesis or a bit more fiddling requires ?

        Comment


          #19
          Hello kazbek966,

          I would use this more as an example to learn what it is doing.

          Your code would need to be adapted to fit the concept.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #20
            Originally posted by NinjaTrader_ChelseaB View Post
            Hello mtamaku,

            To close a position without disabling a NinjaScript Strategy running on the same instrument and account, place an order in the opposite direction of the position.

            For example, if you are long 2, place a sell market order with a quantity of 2.

            Hi, im trying or at least looking for a way to do by script ,that when clicking on the close button, close all the entries but the strategy continues running, is there a way or only those exposed in this thread


            if it is the only way, I think that the most appropriate thing may be to put a button above the close of chart trader, so that at least in the visual section and in the use of the client, what is intended is achieved

            TY


            Comment


              #21


              You might can modify this to Close instead of open and incorporate the way it works into your strategy code.

              Comment


                #22
                Hello RubenCazorla,

                Thanks for your note.

                "im trying or at least looking for a way to do by script ,that when clicking on the close button, close all the entries but the strategy continues running, is there a way or only those exposed in this thread"

                Clicking the 'Close' button in Chart Trader will close all positions on the instrument you are trading and will disable the NinjaScript strategy. There are no methods available for preventing the strategy from disabling when pressing the 'Close' button.

                You would need to follow the solutions recommended in this thread to create a custom button that closes out open positions.

                See this example script which demonstrates creating Chart WPF Modifications: https://ninjatrader.com/support/help...ui)-modifi.htm

                Let me know if I may assist further.
                Brandon H.NinjaTrader Customer Service

                Comment


                  #23
                  Hello,
                  How can I disable the strategy and close all trades on one chart without disabling and closing trades on a different chart, same instrument. thanks

                  Comment


                    #24
                    Hello ronaldgreene828,

                    Thanks for your notes.

                    The CloseStrategy() method could be used to cancels all working orders, close any existing positions, and finally disable the strategy.

                    Note that a NinjaScript Strategy is only able to see orders submitted by that instance of the strategy.

                    Also, please review this forum thread about running mutilple strategies on the same instrument and account: https://forum.ninjatrader.com/forum/...tures-contract

                    See this help guide page for more information and sample code: https://ninjatrader.com/support/help...egy.htm​
                    Brandon H.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Nicholewatkinsi, Yesterday, 10:53 PM
                    0 responses
                    6 views
                    0 likes
                    Last Post Nicholewatkinsi  
                    Started by dward123, 01-02-2024, 09:59 PM
                    4 responses
                    175 views
                    0 likes
                    Last Post Lancer
                    by Lancer
                     
                    Started by ETFVoyageur, Yesterday, 04:00 PM
                    2 responses
                    19 views
                    0 likes
                    Last Post ETFVoyageur  
                    Started by AaronKTradingForum, Yesterday, 03:44 PM
                    1 response
                    14 views
                    0 likes
                    Last Post AaronKTradingForum  
                    Started by Felix Reichert, 04-26-2024, 02:12 PM
                    11 responses
                    80 views
                    0 likes
                    Last Post Felix Reichert  
                    Working...
                    X