Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NinjaScript - ATMstrategy

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

    NinjaScript - ATMstrategy

    Hello,

    with your information-link about ATMStrategyCreate I could add to a NinjaScriptStrategy an ATM strategy.

    But now it occurs that there are entries every time the conditions in the NinjaScript are filled - this doesn´t occur of course with the Scipt only.

    How do I have to change now the condition "Position.MarketPosition == MarketPosition.Flat" when joining with an ATMstrategy?

    Thanks
    Tony

    #2
    Hello,

    Thanks for for the note.

    You actually need to check the position of the ATM Strategy. Since the ATM Strategy is separate then strategy position when you use ATM Strategies for your orders.



    An example on how to do this is located inside your NinjaTrader under Control Center->Tools->Edit NinjaScript->SampleATMStrategy will show how to check this.

    You also need to make sure you check that the ATMStrategyID string exists if it does this also means your strategy is active.

    Let me know if I can be of further assistance.

    Comment


      #3
      Hello,

      I could solve this with your hint. But there appears a question in this concern: in my NinjaScriptStrategies I can define the entries, exits and stops for each contract eg "Long1", "Long2", "Ex1"...............

      How can I do this now when joining script and ATM? This is important to identify the entries and corresponding exits or stops.

      Thanks
      Tony

      Comment


        #4
        Hello,

        Glad to hear.

        Unfortunately you can no longer use this nice feature of the managed approach when you use ATM's.

        Let me know if I can be of further assistance.

        Comment


          #5
          Hello,

          OK, thanks. I thought everything clear now but there occurs a problem now as there are long trades and short trades at the same time. When I have a NinjaScriptStrategy for longs and another for Shorts - and both are joined with an ATM as we could solve now - how can I avoid that there are entries in both directions please.

          And moreover it occurs now that also there are entries in same direction even when "Cbi.MarketPosition.Flat" is not true and I have several entries now.

          And what means this "Cbi" here please. This is in the sampleATM but not in the link "AtmStrategyCreate()"

          That´s it then. Lets get this last brick.

          Thanks
          Tony
          Last edited by tonynt; 06-09-2011, 09:06 AM. Reason: typing error

          Comment


            #6
            Hello,

            Just so I understand do you only want one entry with one ATM Strategy at a time? Or multiple?

            I look forward to assisting you further.

            Comment


              #7
              Hello,

              thanks again for your reply!

              Yes, I want only one entry - per instrument. Eg I have enabled AUD, EUR, GBP long ninjascript strategy with ATM-strategy and I have enabled AUD, EUR, GBP short ninjascript strategy with ATM-strategy. There should not be an entry same direction (I think this could be no problem because of Cbi.MarketPosition.Flat".)

              AND there should not be an entry in the other direction. But I think the id()refers only to one strategy - how can this be solved so that when long trade there will not be a short entry, OR when short trade then there should not be a long entry.


              Thanks
              Tony
              Last edited by tonynt; 06-09-2011, 10:12 AM. Reason: clearify better maybe

              Comment


                #8
                Hello,

                Ok the best way to avoid this then is as shown in the SampleATMStrategy.

                Before you submit any order, check to see if ATMStrategyID is blank or not. If its blank then you have no active ATM Strategies (In this NinjaScript strategy) and you are free to then submit a new trade/entry.

                If it does exist then do not make the trade.

                Make sure that you have the code in your file as shown in the SampleATMStrategy that does the check for ATMStrategyPosition == MarketPosition.Flat that sets the ATMStrategyID back to blank when your ATM Strategy is closed out which allows you to then submit new trades again.

                Let me know if I can be of further assistance.

                Comment


                  #9
                  Hello,

                  thanks for your reply. How do I check to see if ATMid() is blank??

                  And coming back from lunch now I see a lot of trades - but I had NOT enabled the strategies in the strategies tab. Why does it take trades even when not enabled?

                  Best
                  Tony

                  Comment


                    #10
                    Hello,

                    It wouldn't.launch new trades by itself.

                    You might have had ATM Strategies left over in the market however. ATM Strategies are independent of ninjascript strategies.

                    Steps:

                    -Enable NS Strategy
                    -NS Strategy submit buy limit ATM Stategy that doesnt get filled yes and is sitting in market.
                    -Disable NS Strategy
                    -ATMStrategy stays in market since its an ATM Strategy not a NS strategy.
                    -ATMStrategy can then be filled and will be managed with the predefined SL and PT.

                    Let me know if I can be of further assistance.


                    Let me know if I can be of further assistance.

                    Comment


                      #11
                      Hello,
                      I didn´t say it launches new trades by itself! Did I?
                      I said " ,,,lot of trades - but I had NOT enabled..."

                      "you might have ... left over in the market" of course is a reason now. Question please (again):
                      * How to "check to see if ATMStrategyID is blank or not."?
                      * Does "ATMStrategyID is blank or not" mean the same as "is sitting in market or not"?

                      Thanks
                      Tony

                      Comment


                        #12
                        Its your responsibility in your code to track your ATM strategies and make sure there flat. The code can only control atm strategies it has generated, othe ATM strategies you generate by hand will need to be manually handled.

                        The sampleATMStrategy code if you have it in your strategy will work to do this. If a strategy is flat the PT and the SL was filled then the ATM ID will also be blank and your position flat.

                        You may have had a bunch of orders left over from your testing however. Best is to File->Flatten everything make sure everything is closed out then retest.

                        Comment


                          #13
                          Thanks for your reply.

                          Last question in this concern. Is it correct this way to define a target within a NinjaScriptstrategy-joined-with-ATMstrategy:

                          if (atmStrategyId.Length > 0)
                          {
                          // You can change the stop price
                          if (GetAtmStrategyMarketPosition(atmStrategyId) != MarketPosition.Flat
                          && GetCurrentAsk()<Position.AvgPrice - 50*TickSize)
                          {ExitShort(10000, "Ex_SH2", "Short2");}


                          //AtmStrategyChangeStopTarget(0, Low[0] - 3 * TickSize, "STOP1", atmStrategyId);

                          Thats it then.

                          Thanks
                          Tony

                          Comment


                            #14
                            Hello,

                            Why would you ExitShort when your ATMStrategy is not flat? You would want this is flat correct? I would also make sure to check if either the status of the stop loss or profit target is filled.

                            I look forward to assisting you further.

                            Comment


                              #15
                              Hello,

                              there is some misunderstanding - sorry if I couldn´t explain in english correctly.

                              "Why would you ExitShort when your ATMStrategy is NOT flat?"
                              --> if it´s !=flat (isnotflat) I want to exitshort once price is 50 tenthpips below entryprice.

                              You mean I should write "...= MarketPosition.Short"? But isn´t this the same?

                              Whats wrong with this or unlogical???

                              I want to close a position with ninjascriptstrategy (the stops are managed with the ATM). thats all

                              Thanks
                              Tony
                              Last edited by tonynt; 06-09-2011, 02:21 PM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by GussJ, 03-04-2020, 03:11 PM
                              16 responses
                              3,279 views
                              0 likes
                              Last Post Leafcutter  
                              Started by WHICKED, Today, 12:45 PM
                              2 responses
                              19 views
                              0 likes
                              Last Post WHICKED
                              by WHICKED
                               
                              Started by Tim-c, Today, 02:10 PM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by Taddypole, Today, 02:47 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post Taddypole  
                              Started by chbruno, 04-24-2024, 04:10 PM
                              4 responses
                              51 views
                              0 likes
                              Last Post chbruno
                              by chbruno
                               
                              Working...
                              X