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

reverse at stop limited

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

    reverse at stop limited

    Hello, I need to develop a script to limit the number of reverse at stop. Indeed when the market is in range we are quickly in loss because of the number of reverse. Is there a function to limit this number.
    Thanks.
    Laurent

    #2
    Hello lpceruninj,

    Can you clarify, are you using an ATM with the reverse at stop feature or are you saying that your scripts logic is entering into a new oposite position once the stop fills?

    If you mean an ATM there is not a way to limit that.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Yes I use an ATM strategy with the REVERSE AT STOP function.

      My question is: is it possible to develop a script in C# to add a function that would limit the number of reversals.

      When the market is in a range and you are caught in this range with the reverse at stop function, you inevitably lose money.

      This is the reason why I would like to develop a C# script to add a layer to the ATM REVERSE AT STOP strategy.

      Comment


        #4
        Hello lpceruninj,

        You could make a strategy which limits its own trading, you won't specifically be able to limit an ATM's reverse at stop from C#.

        For what you are asking you could develop a standard strategy which has conditions to enter and reverse. Depending on any factor you wanted you could stop it from re entering by defining that as part of its entry conditions.

        JesseNinjaTrader Customer Service

        Comment


          #5
          ok I understand.

          You are saying that I can create an ATM strategy in C# in which I set entry conditions, exit conditions, but also reverse at stop conditions, limiting the number of reverse at stop.

          Is that right?

          Comment


            #6
            Hello lpceruninj,

            No. The ATM cannot be limited if you are checking the box in the template "reverse at stop", that's a feature of the ATM and is not something that can be controlled in C#.

            You can design a non-ATM based strategy which reverses based on a stop filling and then make it quit reversing whenever you wanted based on its conditions. This would require manual coding to limit it because you would need to be able to watch for a stop filling to know when to reverse at stop/target like an ATM.

            JesseNinjaTrader Customer Service

            Comment


              #7
              Hello Ninjatrader support team,

              Is there a way to close at least some "Stop orders" to avoid another ATM reverse using the reverse at stop feature working with an autostrategy when some conditions are meet... Using the next code or similar as example:

              [CODE][// bool done = false;
              private void FlattenPosition()
              {
              if (InPosition) // Long or Short
              {
              foreach (Order order in Account.Orders) //First foreach loop, to get working orders
              {
              if(order.OrderState == OrderState.Working || order.OrderState == OrderState.Accepted) //This will print all working orders on the account
              {

              if (order.Name == "Entry") //Checks if the order name is Stop1, and if so, assigns it to an order object.
              {

              //Account.Cancel(new[] { order });
              }
              }
              }

              //Print("Closeing ATM for" + atmStrategyId.ToString());

              //AtmStrategyClose(atmStrategyId);

              //done = true;

              }

              }​/CODE]

              Using a FlattenPosition(); into OnBarUpdate if condition meet it should work to close the stop orders for the current account but I try it and seems it not working

              it could be a way to limit the autoreverse if some condition is meet into the autostrategy

              Thanks for your help

              Comment


                #8
                Hello bcomas,

                Thank you for your note.

                What is the condition that calls FlattenPosition() in your strategy? If you add Prints both inside and outside of the condition, which ones are output? Do you see the print inside of the condition when you are expecting it to be triggered? For more details on using prints to debug:


                The regular NinjaScript strategy methods are not able to monitor any aspects of the ATM strategy when using ATMs in a NinjaScript strategy. This information is broken down and explained further here:


                With that in mind, I see what you are trying to achieve using the Account class rather than the NinjaScript strategy methods; using prints should help to understand which parts of your logic are being hit and which ones are not. Please also check the Log tab of the Control Center for any error messages. I see your comment mentions it is checking if the order name is Stop1, though the logic is actually checking for an order name of "Entry"
                Code:
                if (order.Name == "Entry") //Checks if the order name is Stop1, and if so, assigns it to an order object.
                I suggest printing out the order names to see if Stop1 is being detected in the loop, then try modifying this to cancel the order if the order.Name is "Stop1" rather than "Entry"

                Please let us know if we may be of further assistance.
                Emily C.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by llanqui, Today, 10:32 AM
                0 responses
                2 views
                0 likes
                Last Post llanqui
                by llanqui
                 
                Started by StockTrader88, 03-06-2021, 08:58 AM
                45 responses
                3,992 views
                3 likes
                Last Post johntraderuser2  
                Started by TAJTrades, Today, 09:46 AM
                0 responses
                8 views
                0 likes
                Last Post TAJTrades  
                Started by rhyminkevin, Yesterday, 04:58 PM
                5 responses
                62 views
                0 likes
                Last Post dp8282
                by dp8282
                 
                Started by realblubb, Today, 09:28 AM
                0 responses
                8 views
                0 likes
                Last Post realblubb  
                Working...
                X