Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

I get alot of orders

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

    I get alot of orders

    I want to do something like "IF price hits this point, buy, or if it hits this point, sell". And do not buy or sell again if there is an open position.

    I have this code

    Code:
    if(importantPoints[0] != 0 && Position.MarketPosition == MarketPosition.Flat)
                                {
                                    if(closestPoint[1] == 6 || closestPoint[1] == 7)
                                        {
                                            if(priceType == importantPoints[3])
                                                {
                                                    EnterLong(1, "Long");
                                                    SetProfitTarget("Long", CalculationMode.Price, importantPoints[7]);
                                                    SetStopLoss(CalculationMode.Price, importantPoints[4]);
                                                }
                                                
                                            if(priceType == importantPoints[2])
                                                {
                                                    EnterShort(1, "Short");
                                                    SetProfitTarget("Short", CalculationMode.Price, importantPoints[7]);
                                                    SetStopLoss(CalculationMode.Price, importantPoints[5]);
                                                }
                                        }
                                }
    I get like hundreds of orders when the above is true. Not 1 order, but hundreds in the same location. Why is this happening?

    #2
    What is your strategies "EntriesPerDirection" set to? 1 should limit to 1.

    I haven't tried "0", but that might disable it, hence your misfortune.

    I'm not sure if EntriesPerDirection of 1 would limit a long and short at the same time.. haven't gone down that road.

    Anyways, is this upon strategy startup? Do you have a Historical check in there?

    If (Historical) return;

    ?

    There is some caveat about historical on indicators or strategies, and I'm not recalling which at the moment, so that too, might not be your problem.

    If you could post some code in full, that we could run, ***PLEASE CHANGE what you need to keep "secret" *** , but make sure it produces the same result of "hundreds of orders".. so we could test and debug.

    **Kogonam probably will know before I have a chance to debug.








    Originally posted by Maciek View Post
    I want to do something like "IF price hits this point, buy, or if it hits this point, sell". And do not buy or sell again if there is an open position.

    I have this code

    Code:
    if(importantPoints[0] != 0 && Position.MarketPosition == MarketPosition.Flat)
                                {
                                    if(closestPoint[1] == 6 || closestPoint[1] == 7)
                                        {
                                            if(priceType == importantPoints[3])
                                                {
                                                    EnterLong(1, "Long");
                                                    SetProfitTarget("Long", CalculationMode.Price, importantPoints[7]);
                                                    SetStopLoss(CalculationMode.Price, importantPoints[4]);
                                                }
                                                
                                            if(priceType == importantPoints[2])
                                                {
                                                    EnterShort(1, "Short");
                                                    SetProfitTarget("Short", CalculationMode.Price, importantPoints[7]);
                                                    SetStopLoss(CalculationMode.Price, importantPoints[5]);
                                                }
                                        }
                                }
    I get like hundreds of orders when the above is true. Not 1 order, but hundreds in the same location. Why is this happening?

    Comment


      #3
      I use Add(PeriodType.Tick, 1); as my prices to be as accurate as possible. I did what you suggested, and I still get thousands of orders when there should be 1.

      All I need is really simple. IF THERE IS AN EXISTING POSITION, DON'T TRADE ANYMORE.

      I want my code to do something like this:

      IF EXISTING POSITION, DON'T TRADE

      ELSE TRADE

      IF PRICE HITS POINT, BUY/SELL

      ENTER PROFIT TARGET, ENTER STOP

      Thats all. I thought I achieved that, but it buys and sells thousands for each individual tick.

      Comment


        #4
        Are you using managed or unmanaged approach?




        I use only managed....


        Originally posted by Maciek View Post
        I use Add(PeriodType.Tick, 1); as my prices to be as accurate as possible. I did what you suggested, and I still get thousands of orders when there should be 1.

        All I need is really simple. IF THERE IS AN EXISTING POSITION, DON'T TRADE ANYMORE.

        I want my code to do something like this:

        IF EXISTING POSITION, DON'T TRADE

        ELSE TRADE

        IF PRICE HITS POINT, BUY/SELL

        ENTER PROFIT TARGET, ENTER STOP

        Thats all. I thought I achieved that, but it buys and sells thousands for each individual tick.

        Comment


          #5
          So, I read all that, and I tried a lot of different things. Nothing seems to be working. There should be about 3 trades, but instead it does 50000 trades.

          I think it has to do with me using these:

          Code:
          Add(PeriodType.Minute, 1);
          Add(PeriodType.Tick, 1);
          I tried changing BarsInProgress and all the bar index factors in the EnterLong. Nothing seems to work.

          Code:
          if(Open == 1500)
          {
                 if(PRICE == Important Point 1)
                  {
                      EnterLong(2, 1, "Long");
                      SetProfitTarget("Long", CalculationMode.Price, Important Point 2);
                      SetStopLoss(CalculationMode.Price, Important Point 3);
                  }
          }
          I just need to have 1 position at a time. No more then 1. As soon price hits the Important Number, I need to buy or sell and set up profit target and stop.

          Comment


            #6
            Please help i need something like "if order or position exists, do not create new order or position on forthcoming bars"

            Comment


              #7
              Originally posted by Maciek View Post
              Please help i need something like "if order or position exists, do not create new order or position on forthcoming bars"
              Look at this thread, specifically Koganam's replies.



              Also look up MarketPosition in the help.

              if (Position.MarketPosition == MarketPosition.Flat)

              Comment


                #8
                Hello Maciek,

                Thank you for your post.

                Have you implemented EntryHandling along with EntriesPerDirection into your strategy?

                For example if I use EntryHandling.AllEntries with EntriesPerDirection 1 you should only see 1 position per side:
                Code:
                protected override void Initialize() 
                { 
                    EntriesPerDirection = 1;
                    EntryHandling = EntryHandling.AllEntries;
                For information on EntryHandling please visit the following link: http://www.ninjatrader.com/support/h...ryhandling.htm

                Please let me know if you have any questions.

                Comment


                  #9
                  Originally posted by Maciek View Post
                  So, I read all that, and I tried a lot of different things. Nothing seems to be working. There should be about 3 trades, but instead it does 50000 trades.

                  I think it has to do with me using these:

                  Code:
                  Add(PeriodType.Minute, 1);
                  Add(PeriodType.Tick, 1);
                  I tried changing BarsInProgress and all the bar index factors in the EnterLong. Nothing seems to work.

                  Code:
                   
                  if(Open == 1500)
                  {
                         if(PRICE == Important Point 1)
                          {
                              EnterLong(2, 1, "Long");
                              SetProfitTarget("Long", CalculationMode.Price, Important Point 2);
                              SetStopLoss(CalculationMode.Price, Important Point 3);
                          }
                  }
                  I just need to have 1 position at a time. No more then 1. As soon price hits the Important Number, I need to buy or sell and set up profit target and stop.
                  Not enough information.
                  1. What is the COBC setting?
                  2. When you say it enters multiple trades, are you saying that these are completed (entry, and exit), or are you saying that you end up with a large position? i.e., does your statement about 5000 trades mean that you got a position of 5000, or that you got 5000 entries followed by exits in rapid succession?

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  633 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  364 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  105 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  567 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  568 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X