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

Internal Order Handling Rules look like applied to market order

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

  • margandi
    replied
    thank you!

    Leave a comment:


  • NinjaTrader_PaulH
    replied
    Hello margandi,

    Thanks for your reply.

    You can debug your strategy using print statements. If you add a print statement to print the value of BarSinceEntry() inside the 2nd entry block you would see that it returns a value greater than 1 which is what your entry condition for the 2nd entry specifies.

    Here is what we see in the output window with added print statements to your code:
    11/28/2006 3:00:00 PM EnterLong - First
    11/28/2006 3:00:00 PM EnterLong - Second BarsSinceentry = 16
    11/28/2006 3:00:00 PM ExitLong LL
    Strategy 'ChanKenXshares/-1': An Set() method to submit an exit order at '11/28/2006 3:00:00 PM' has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.


    When you have the first entry on the same bar at the same time as the second entry, the object that updates BarsSinceEntry() has not instantaneously updated it as fast as your code requires, this means that BarsSinceEntry would be using a prior bars entry and not the current bars entry.

    What you can do is to add further logic to ensure that 2nd entry does not occur in the same bar by saving the current bar number in your first entry and then checking to see if the current bar is not equal to that saved bar number in your second entry.

    Leave a comment:


  • margandi
    replied
    Originally posted by NinjaTrader_PaulH View Post
    Hello margandi,

    Thanks for your reply.

    If you add print statements to each of your EnterLong and ExitLong sections what you will find, on the date(s) where you see the error, is that your coding is issuing Enterlong, Enterlong, and ExitLong at the same bar and this is causing the issue with the Set methods. The Set method is ignored because the positions are getting closed out by the Exit method which is exiting all positions. You would need to change your coding to prevent this (issuing Enterlong,Enterlong, and ExitLong at the same bar) from occurring.

    "if i delete the second enterlong(),there are no more errors. But i dont understand why ", By not using a second entry the set methods are not trying to deploy for that 2nd entry at the same time the code was issuing ExitLong, so deleting the second entry prevents the condition that causes the Set methods to be ignored.
    The second entry schould not be exucuted on the same bar because of BarsSinceEntryExecution>1, >2...>10when its >10, there s no error since thereis no second entry..
    Exit at the same bar should be if conditions for exit are met by my logic...

    Leave a comment:


  • NinjaTrader_PaulH
    replied
    Hello koganam,

    Thanks for your reply.

    Pedantic or not we always appreciate your feedback and insight.

    I will provide this thread to our help guide group for their review.

    Again, thank-you for taking the time and effort to clarify.




    Leave a comment:


  • koganam
    replied
    Originally posted by NinjaTrader_PaulH View Post
    Hello koganam,

    Thanks for your reply.

    From the example highlighted, a set method to exit a position (SetStopLoss, SetTrailStop, SetParabolicStop) would be ignored if a position exists and a non market order type is used, the ExitLongLimit() is shown as an example. Is the concern here that we need to explicitly say "does not apply to market order type such as ExitLong() and ExitShort()?

    Can you provide an example of the wording that makes sense to you?
    I do not mean to wax pedantic, but let us look at some things that make little sense, logically and sometimes grammatically.

    Click image for larger version

Name:	NT8ManagedApproahPoorlyWorded1.png
Views:	339
Size:	14.4 KB
ID:	1074723
    Exit orders are not used to enter a position in any direction. The statement already is confusing, both in its logic, and its grammar: to which of the preceding orders, does "the order" in "the order is used to open a position in the opposite direction" refer?

    If this section is meant to refer to entry orders that attempt to reverse the position, and hence automatically generate exit orders, then that is what is to be said. However, that has already been said in the paragraph that precedes the quoted paragraph, which would effectively make this statement redundant.

    Click image for larger version

Name:	NT8ManagedApproahPoorlyWorded2.png
Views:	334
Size:	141.0 KB
ID:	1074724
    Really? So I cannot override the exit with a market exit order? If I can, then maybe, you want to explicitly let me know. This says that even an ExitLong() will be ignored in the situation.

    Click image for larger version

Name:	NT8ManagedApproahPoorlyWorded3.png
Views:	366
Size:	230.6 KB
ID:	1074725
    Quite separate from the issue of "exit orders not being used to make entries", the highlighted bullets are exactly the same, so, using the text of the section itself, logically if "A position is open and an order submitted by an enter method (EnterLongLimit() for example) is active and the order is used to open a position in the opposite direction", then Exit orders will be ignored and Set() method orders will also be ignored. Is it really true that there would be no way to exit the position, as this argument then implies?

    Click image for larger version

Name:	NT8ManagedApproahPoorlyWorded4.png
Views:	346
Size:	238.4 KB
ID:	1074726

    These 2 highlighted sections imply that if I have Set() orders and ExitLongLimit() both coded, there is no way to exit the position, as they will both effectively be ignored. Is it even possible to simultaneously have ExitLongLimit() and Set() orders placed? If not, then you might want to clearly state what would happen if there is an attempt to place both.

    That being said, is this whole section not redundant? It seems to have been misworded, but was intended to refer to order methods that automatically generate exit orders as part of their operation; such as orders that are intended to reverse the position. If so, that is already handled very clearly in the preceding paragraph. At best, all that might be required is to explain what situations will automatically generate exit orders. Even that should properly belong to a different section, I should think.

    Leave a comment:


  • NinjaTrader_PaulH
    replied
    Hello margandi,

    Thanks for your reply.

    If you add print statements to each of your EnterLong and ExitLong sections what you will find, on the date(s) where you see the error, is that your coding is issuing Enterlong, Enterlong, and ExitLong at the same bar and this is causing the issue with the Set methods. The Set method is ignored because the positions are getting closed out by the Exit method which is exiting all positions. You would need to change your coding to prevent this (issuing Enterlong,Enterlong, and ExitLong at the same bar) from occurring.

    "if i delete the second enterlong(),there are no more errors. But i dont understand why ", By not using a second entry the set methods are not trying to deploy for that 2nd entry at the same time the code was issuing ExitLong, so deleting the second entry prevents the condition that causes the Set methods to be ignored.

    Leave a comment:


  • margandi
    replied
    hello,
    lines 125 and 127 dont provide that error. If script is run from 2014,there is no error, but try run it from 2005, and 28/11/2006 you Will have it.

    In CL 12-19 there is no error in anytime. But In DOW30 depends on symbols there are a lot of "an set method an exit order at xx/xx/xxxx has been ignored"

    P.S. if i delete the second enterlong(),there are no more errors. But i dont understand why and how to solve it.

    Thanks.
    Last edited by margandi; 10-15-2019, 03:01 AM. Reason: addiding info

    Leave a comment:


  • NinjaTrader_PaulH
    replied
    Hello koganam,

    Thanks for your reply.

    From the example highlighted, a set method to exit a position (SetStopLoss, SetTrailStop, SetParabolicStop) would be ignored if a position exists and a non market order type is used, the ExitLongLimit() is shown as an example. Is the concern here that we need to explicitly say "does not apply to market order type such as ExitLong() and ExitShort()?

    Can you provide an example of the wording that makes sense to you?

    Leave a comment:


  • koganam
    replied
    Originally posted by margandi View Post
    unfortunately, this error from that strategy.There is the same error on any symbol, lets say for instance ES 12-19.
    1 day time-frame..
    Whereas this is very poorly worded and circularly contradictory, the idea is that one cannot use both Exit() methods and Set() methods in the same Strategy script.

    Support, please ask your Documentation team to word this better: this writeup implies that all exit orders will be ignored, as that is the only way that the statements can be simultaneously true.


    Click image for larger version

Name:	NT8ManagedApproahPoorlyWorded.jpg
Views:	434
Size:	68.9 KB
ID:	1074337

    Leave a comment:


  • NinjaTrader_PaulH
    replied
    Hello margandi,

    Thanks for your reply.

    In looking through your code I do not see anything specific. I tried to run the strategy in the strategy analyzer however I do not have the Bear method or the ATR_Percentage. I commented out lines 125 and line 127 where these methods are referenced and recompiled without errors. I ran the strategy on ES 12-19 in the strategy analyzer from November 2014 until today, using daily bars as you directed. No errors were produced. I do see first and second trades on the chart.

    Can you try and reproduce on your end by commenting out lines 125 and 127? I don't see any linkage between the Bear() and ATR_Percentage as it relates to the stop level so I do not believe that is the issue but I am curious if you can reproduce the error without those lines.

    Without those lines, can you provide a specific set of circumstances that consistently generate the error?

    Leave a comment:


  • margandi
    replied
    unfortunately, this error from that strategy.There is the same error on any symbol, lets say for instance ES 12-19.
    1 day time-frame..
    Attached Files

    Leave a comment:


  • NinjaTrader_PaulH
    replied
    Hello margandi ,

    Thanks for your reply.

    Based on the code you have displayed it is not obvious as to the issue.

    Is it possible that the error message you saw was actually from a different strategy? If there is doubt, please close all other strategies and test this strategy to see if the error message persists with this strategy.

    If the error message persists, please either attach your strategy file source code here or send it in to PlatformSupport[at]NinjaTrader[dot]com.

    The strategy file can be found in Documents>NinjaTrader8>bin>Custom>Strategies> and will have the name of the strategy with a .cs type.

    In addition, please identify the instrument, time frame and bar type such that we can replicate the issue on our end.

    if you send in the strategy, please include a link to this thread within the e-mail and mark the subject "Atten: Paul" ticket #2301874

    Leave a comment:


  • margandi
    replied
    if (Close[1] > SMA1[1]
    && Wr[1] <-80
    &&( ATR_percentage(100,14)[1] >= Bollinger( ATR_percentage(100,14),1,100).Upper[1] || ATR_percentage(100,14)[1] <= Bollinger( ATR_percentage(100,14),1,100).Lower[1] )
    )

    {
    double splitRisk = xAccountSize *percentToRisk;
    double xTickValue=Instrument.MasterInstrument.PointValue;
    int sharesToBuy= (int)(splitRisk/(GetCurrentBid()*0.03* xTickValue ));
    Print("sharesToBuy"+sharesToBuy.ToString()); //Prints Shares to buy
    EnterLong(sharesToBuy,"First");

    }

    if (Position.MarketPosition == MarketPosition.Long
    && BarsSinceEntryExecution()>1
    && Close[1] > SMA1[1]
    && Wr[1] <-80
    )
    {
    double splitRisk2 = xAccountSize *percentToRisk;
    double xTickValue=Instrument.MasterInstrument.PointValue;
    int sharesToBuy2= (int)(splitRisk2/(GetCurrentBid()*0.03* xTickValue));

    Print("sharesToBuy"+sharesToBuy2.ToString()); //Prints Shares to buy
    EnterLong(sharesToBuy2,"Second");
    }

    if (Wr[0]>-30 || Close[0]<SMA1[0])
    {ExitLong("wr"," ");}


    if( Position.MarketPosition == MarketPosition.Long && Position.GetUnrealizedProfitLoss(PerformanceUnit.C urrency, Close[0])>1.5*ATR(14)[0])
    {
    if (High[0]+14* TickSize<High[1]
    && Low[0]+14* TickSize<Low[1]
    && Low[1] <Low[2]
    && High[1]<High[2]

    )
    {ExitLong("LL","");}
    }


    I call take profit and stop loss from state.configure
    else if (State == State.Configure)
    {
    SetStopLoss(CalculationMode.Percent, 0.03);
    SetProfitTarget( CalculationMode.Percent, 0.06);
    }

    its NOT multi time frame.

    and it has :

    EntriesPerDirection = 1;
    EntryHandling = EntryHandling.UniqueEntries;
    Last edited by margandi; 10-11-2019, 06:06 AM.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello margandi,

    SetStopLoss() is a method that attaches an exit order to an existing position.

    A stop loss itself is not the actual position and is instead used to close the position. The position is the amount of contracts you have bought or sold. For example Long 2 would mean two contracts have been bought.

    If a Set() is called while there are other working orders (with the same signal name or no signal name) that order will be ignored.

    I was not able to confirm, are you calling a set method in your script?

    Leave a comment:


  • margandi
    replied
    "A position is open and an order submitted by an enter method (EnterLongLimit() for example) is active and the order is used to open a position in the opposite direction."

    Could SetStopLoss() be treated as position in the opposite direction ?

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by futureszone, Yesterday, 06:48 AM
4 responses
22 views
0 likes
Last Post NinjaTrader_ChristopherS  
Started by UliSchmuli, Today, 10:40 AM
0 responses
2 views
0 likes
Last Post UliSchmuli  
Started by Touch-Ups, Today, 06:51 AM
1 response
13 views
0 likes
Last Post NinjaTrader_Emily  
Started by Dice2022, Today, 10:04 AM
0 responses
3 views
0 likes
Last Post Dice2022  
Started by Philippe56140, Today, 09:13 AM
2 responses
7 views
0 likes
Last Post Philippe56140  
Working...
X