• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy to enter trade but want to manage it manually - how?

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

    Strategy to enter trade but want to manage it manually - how?

    Hi

    Very new to playing with the strategy builder and looking at code.
    I have a simple strategy that places a market order with stop and target. I had thought that I could manage the trade manually after it opened but I see and now understand this is not possible.
    However it is critical for my trading that I be able to manage itrades manually.
    If I I remove the stop and target inputs in the strategy builder will that allow me to manage the trade that is opened?
    What is the easiest way for me to achieve what I want to do.
    I have the logic sorted and I am happy for a market order to be placed at a bar close.
    At that point I would really like to use an ATM strategy to place stop and target that can be manually moved on the chart.
    Looking forward to a solution within my ability to implement.

    thanks
    Lindsay


    #2
    Hello Lindsay,

    Thanks for your post.

    You are correct, the strategy builder type strategies do not provide a means to manually adjust stop/profit orders.

    "If I I remove the stop and target inputs in the strategy builder will that allow me to manage the trade that is opened?", No, if the strategy was in a position and there is no stop or target if you manually close the position the strategy would continue along as if it were still in a position and likely would place an exit order at the end of the session (unless that option was disabled). So at best you would get either one entry per run or one entry per session (depending on session exit selection).

    You can work with ATM strategies through a Ninjascript created strategy. There is a working example of such a strategy in your NinjaTrader called "SampleAtmStrategy" that provides well-commented code to explain what the code is doing. In addition, you would need to review the special ATM method/properties in the ninjascript help guide: https://ninjatrader.com/support/help...gy_methods.htm

    You could create your entry rules and such in the strategy builder and then "unlock" the code to work directly in Ninjascript to use the ATMmethods. Alternatively, you could modify a copy of SampleAtmStrategy to add your entry conditions. In either case, you ultimately would need to work directly in Ninjascript to accomplish your goal.

    Here is a link to another Ninjascript based strategy that works with ATMs you can also review: https://ninjatraderecosystem.com/use...tegy-reversal/
    The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.

    Alternatively, you could have your strategy created by a 3rd party coder, if this is of interest, please let us know and we can post a link to such providers.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks for this useful response.

      Another question. Is it possible in strategy builder to apply a conditional trailing stop? For example, hold the trade while a fast ema is above a slow ema?

      Comment


        #4
        Hello Lindsay,

        Thanks for your reply.

        In the strategy builder, the SetTrailStop() method only works one way in that it begins trailing a set amount immediately upon entry (and a positive profit direction).

        Instead of the SetTrailStop, you can construct a set where you check the price level to some level you determine and if exceeded use an exit method to exit the position. Using your example you might have a set where you check to see that you are in a long position and when the fast ema crosses the slow ema to then exitlong(). The only concern would be if you are using a fixed stop / target that the exit would not occur at the same time as either of those potentially causing an over fill, also if you entering in the opposite direction with the crossover using an Entershort could cause an overfill.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Thanks Paul

          I am interested in your idea of putting my entry conditions into the SampleAtmStrategy. I ran this and it does seem to allow manual stop and PT adjustment.

          Does this read/interpret as "The ATM strategy will be applied to a buy limit order placed at the low of the current bar"

          "AtmStrategyCreate(OrderAction.Buy, OrderType.Limit, Low[0], 0, TimeInForce.Day, orderId, "AtmStrategyTemplate", atmStrategyId, (atmCallbackErrorCode, atmCallBackId)"

          I want to place a market order at close of bar(0) if my conditions are met. There are 4 conditions that involve defining a 2 bar reversal and a couple of other things like the close being across an ema that must all be met. Can you show me how you would add such a series of conditions in the format above? I assume all conditions must be within the one statement rather than one per statement as this would add a position for each condition?

          Or alternately do you think it would be more simple to unlock my code from strategy builder and then add the ATMmethod to that?

          thanks for your help.

          Comment


            #6
            Hello Lindsay,

            Thanks for your reply.

            "Does this read/interpret as "The ATM strategy will be applied to a buy limit order placed at the low of the current bar"" - Yes.

            To place a market order you could use AtmStrategyCreate(OrderAction.Buy, OrderType.Market, 0, 0, TimeInForce.Day, orderId, "AtmStrategyTemplate", atmStrategyId, (atmCallbackErrorCode, atmCallBackId)

            In the SampleAtmStrategy, the entry criteria is shown in line 59: if (orderId.Length == 0 && atmStrategyId.Length == 0 && Close[0] > Open[0]) The first two conditions are checking to make sure the ATM is not already in use (in other words any prior position is closed), the last entry condition is simply Close[0] > Open[0]. You can replace the Close[0] > Open[0] with your various entry conditions. In Ninjascript/C# the "&&" means "and" so if you and all the conditions they must all be true at the same time. With "several" entry conditions" you will also likely need to use "||" which means "or". If you do a view code of the strategy builder code you already have, you may be able to use that. I would suggest that you go slowly and add one set of conditions first and validate its functionality, then another set and so on as it will be a lot easier for you you to debug (and yes you will need to learn how to debug) the code.

            Here is a simple example:

            if (orderId.Length == 0 && atmStrategyId.Length == 0 && Close[0] > EMA(5)[0] && (Condition1 || condition 2 || condition3)) Note that the "or" ed condition are contain within their own () so the statement says that the orderID must be zero, the length must be 0, the close must be greater than the EMA(5)[0] and then any of the 3 other conditions must be true in order to proceed. Again I would suggest proceeding slowly especially as this seems new to you.

            Alternatively, you can always hire a 3rd party programmer who can code this for you and we can provide a link to such 3rd party coders if this option is of interest.


            Paul H.NinjaTrader Customer Service

            Comment


              #7
              I am having the same issue needing to Manually adjust the stop loss and profit target orders once in a trade. I read something about OnOrderUpdate() which seems to imply that an updated order (which manually moving would be OrderUpdate but I need some help figuring our how to include in strategy.

              Comment


                #8
                Hello DTSSTS,

                Thanks for your post.

                To manually move orders you need only work with ATM strategies through a Ninjascript created strategy. There is a working example of such a strategy in your NinjaTrader called "SampleAtmStrategy" that provides well-commented code to explain what the code is doing. In addition, you would need to review the special ATM method/properties in the ninjascript help guide: https://ninjatrader.com/support/help...gy_methods.htm
                Paul H.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NT-Roland, Today, 06:34 AM
                0 responses
                1 view
                0 likes
                Last Post NT-Roland  
                Started by gemini42, Yesterday, 09:44 PM
                0 responses
                11 views
                0 likes
                Last Post gemini42  
                Started by martyn73, Yesterday, 03:09 PM
                0 responses
                9 views
                0 likes
                Last Post martyn73  
                Started by martyn73, Yesterday, 03:05 PM
                0 responses
                9 views
                0 likes
                Last Post martyn73  
                Started by mic414, Yesterday, 02:17 PM
                0 responses
                6 views
                0 likes
                Last Post mic414
                by mic414
                 
                Working...
                X