Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Translating a v6.0 strategy to 7

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

    #46
    Betrand, it uses a second counter to readjust orders,so the time frame isnt important. Its best viewed from the superdom. Its a simple market maker strategy.

    Do new entries appear once the profit target or stoploss or hit?
    The initial entries, the first fill and first exit work fine. It just stops after that,

    I am currently running version 18. I will update and try that.

    Comment


      #47
      I saw it happen here, too and believe it's related to your ChangeOrder call for the entries that is still run if you're in a position and waiting for the exits to trigger.

      Comment


        #48
        Ok, thanks. I will have a look. any easy fix for that one?

        Comment


          #49
          Actually Bertrand. Thats got me a bit confused. I thought I added a check that would only submit change order when the initial entry Buy and Sell were submitted.

          Code:
           if (entryBuyOrder != null && entrySellOrder != null);
               {
                     ChangeOrder(entryBuyOrder,1,this.bid - this.offsetTicks * TickSize,0);
                     ChangeOrder(entrySellOrder,1,this.ask + this.offsetTicks * TickSize,0);
               }
                     }

          Comment


            #50
            You would need to differentiate for the Buy and Sell ChangeOrder statements, currently you do them both in one for both potential MarketPositions (!= Flat).

            Comment


              #51
              Ok, will have a look at that. So change orders need to be done separately, but entry orders can be done at the same time?

              I just assumed I could write it that way as I only have both buy and sell entry working at the same time.


              Thanks for the help!!

              Comment


                #52
                The case is different here, in your entry section, you submit for both sides from a flat state...in the ChangeOrder you can also hit the scenario you're long and still attempt to changeOrder the nonexisting short entry.

                Comment


                  #53
                  How can I write a print command to show if the status of the entry order is null?
                  After Im getting filled on my exit Im not recieving any error messages, but Im not getting any new entry orders either.

                  Comment


                    #54
                    Actually I think I am getting really close to this working.

                    Im not getting any errors at the moment. After I exit a long position, I get new entry Orders. However, when I exit a sell entry order, I dont get any new orders.

                    Comment


                      #55
                      This would likely suggest you're not resetting the IOrders for the short side properly to catch new entries there as well, please add prints to see if your strategy enters the sell side logic based on your current code.

                      Comment


                        #56
                        Went back through it today and I think I figured it out. The entry order that was filled was being reset correctly, it was the entry order that wasnt filled that was the problem. It wasnt being reset after being cancelled.

                        After adding the reset for the cancelled orders it seems to be working ok ( for now anyway)

                        Comment


                          #57
                          Great job maninjapan, good to hear you got it working.

                          Comment


                            #58
                            back again with some questions about the strategy discussed here. Orders remain active after the strategy is stopped. What do I add to have the orders cancelled when the strategy is canceled?

                            Comment


                              #59
                              You can go to Tools > Options > Strategies > NinjaScript and set your order handling options.

                              Comment


                                #60
                                Thanks, easy fix!!

                                Unfortunately Im now having a much larger issue with it. the initial entry orders are written under onBarUpdate(), which means they are being updated every single tick. As it is it freezes all the time. How could I rewrite this so that its not updating the entry orders every tick?

                                Thanks
                                Code:
                                 /// </summary>
                                        protected override void OnBarUpdate()
                                        {
                                   // Submit an entry limit order if we currently don't have an entry order open
                                   if (entryBuyOrder == null && entryBuyOrder1 == null && entryBuyOrder2 == null && entrySellOrder == null && entrySellOrder1 == null && entrySellOrder2 == null && Position.MarketPosition == MarketPosition.Flat) 
                                   {
                                    int now = ToTime(DateTime.Now);
                                    int diff = now - this.lastTime;
                                    
                                         if (diff >= this.SECONDS || diff < 0)
                                        {
                                     this.bid = GetCurrentBid();
                                            this.ask = GetCurrentAsk();
                                     
                                     if (this.bid == this.ask) return;
                                    
                                               this.lastTime = now;
                                             this.Print("bid = " + this.bid + ", ask = " + this.ask);
                                        }
                                    
                                       // Buy 1   
                                       entryBuyOrder = SubmitOrder(0,OrderAction.Buy,OrderType.Limit,1,this.bid - this.oFFSET1 * TickSize,0,"","Long Limit1");
                                    
                                    // Buy 2   
                                       entryBuyOrder1 = SubmitOrder(0,OrderAction.Buy,OrderType.Limit,1,this.bid - this.oFFSET2 * TickSize,0,"","Long Limit2");
                                    
                                    // Buy 3   
                                       entryBuyOrder2 = SubmitOrder(0,OrderAction.Buy,OrderType.Limit,1,this.bid - this.oFFSET3 * TickSize,0,"","Long Limit3");
                                    
                                        // Sell 1
                                       entrySellOrder = SubmitOrder(0,OrderAction.SellShort,OrderType.Limit,1,this.ask + this.oFFSET1 * TickSize,0,"","Short Limit1"); 
                                    
                                    // Sell 2
                                       entrySellOrder1 = SubmitOrder(0,OrderAction.SellShort,OrderType.Limit,1,this.ask + this.oFFSET2 * TickSize,0,"","Short Limit2"); 
                                    
                                    // Sell 3
                                       entrySellOrder2 = SubmitOrder(0,OrderAction.SellShort,OrderType.Limit,1,this.ask + this.oFFSET3 * TickSize,0,"","Short Limit3"); 
                                   }
                                      else

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                649 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                370 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                109 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                574 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                576 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X