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

strategies with one market and one stop market entry orders.

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

  • bltdavid
    replied
    Originally posted by rtwave View Post
    nt does not include a native breakeven stop order, however it is possible to use a ordinary stop loss order and then move it to the entry price once a position has reached a defined profit amount. i have learned how to do this ...
    Awesome!

    Yep, that's exactly correct -- to effect the "move to breakeven" you had to
    move an existing Stop order by updating its Stop price.

    You're doing well, but I'd like to continue to correct your thinking.
    (Please don't think I'm picking on you -- these concepts are universal
    and I enjoy teaching -- so stay with me and scoop up this knowledge.)

    Knowing the different order types is important.
    There are only a few, mainly Market, Limit, and Stop orders.
    Almost every order type in existence uses one of these three as its basic operation.

    But, there is no such order type as a "Breakeven Stop" or "Ordinary Stop", much
    less "native" versions of these.

    "Breakeven" is a procedure applied to move an existing Stop order.
    It is not an order type.

    Similarly, "Auto Trail" is a procedure applied to move an existing Stop order.
    It is not an order type.

    The name "Stop Loss" is sometimes used as a synonym for a Stop order,
    but saying "Stop Loss" implies several additional things:
    If you're Long, a sell Stop order is entered below your entry price.
    If you're Short, a buy Stop order is entered above your entry price.
    We conveniently call both of these Stop orders a "Stop Loss" order.

    Why?
    In both cases the order type is simple -- it is a Stop order -- but the vocabulary
    is such that "Stop Loss" conveys the intention of the order, which is to exit the
    position and attempt to limit your losses to a certain amount. I say "attempt"
    because the underlying Stop order is subject to slippage.

    Thus, we have,
    "Stop Loss" is a procedure applied in how a Stop order is created.

    See the distinctions?

    -=o=-

    Another hard thing to grasp for a lot of folks is that a Stop order can also be
    used as an entry order -- for ex, a buy Stop order is a Stop order entered above
    market price -- it waits there, and when price rises to the Stop price, the buy
    Stop order becomes a buy Market order, and you are Long.

    There are other variations and combinations, but almost all of them utilize
    these basic order types (sometimes together, such as a Stop Limit order).

    My point is:
    The three basic order types are the primary foundation for all orders.

    In speech, a person's trading vocabulary is usually kinda loose, many things
    are inferred from context. But when it gets written, it helps to be more precise.

    Updating your vocabulary will be helpful to you, especially as you learn from
    other educational sources and tutorials, both here and elsewhere on the web.

    Happy Trading!


    Leave a comment:


  • NinjaTrader_BrandonH
    replied
    Hello rtwave,

    Thank you for your note.

    When it comes to running Optimizations, computer memory is important for long resource-intensive tests that generate a large number of trades without your machine stalling. Computer processor speed is important to get optimization iterations done quickly and the number of CPU cores allows for more iterations to run simultaneously.

    My colleague Jim has created a video demonstrating how the SampleMACrossover strategy, a simple strategy that utilizes IsInStantiatedOnEachOptimizationIteration=false for efficiency, can still quickly utilize memory resources.

    Demo — https://drive.google.com/file/d/15pz...w?usp=drivesdk

    As we can see there are a number of factors that are involved and memory utilization can climb very quickly depending on a few of these factors. Once memory gets maxed out, we can experience short freezes where memory is decommitted, stored to disk, and then new resources are committed before the backtest is resumed.

    We can easily control the number of iterations involved and we can also consider writing our strategies to use IsInstantiatedOnEachOptimizationIteration = false; (Which requires that we reset class level variables in State.DataLoaded.)

    See the help guide documentation below for more information about running optimizations.
    IsInstantiatedOnEachOptimizationIteration — https://ninjatrader.com/support/help...niteration.htm
    Optimization Tips — https://ninjatrader.com/support/help...ionPerformance
    Walk Forward Optimization — https://ninjatrader.com/support/help...ss_metrics.htm
    Genetic Optimization — https://ninjatrader.com/support/help..._algorithm.htm

    Let us know if we may assist further.

    Leave a comment:


  • rtwave
    replied





    thanks.


    nt does not include a native breakeven stop order, however it is possible to use a ordinary stop loss order and then move it to the entry price once a position has reached a defined profit amount. i have learned how to do this and i think that it should also be possible to achieve what i have in mind with profit - loss and boolean conditionals.


    i will take a look at the nt links that have been posted.



    anyway, i will point out that the nt platform is overwhelmed when one tries to optimize a strategy which includes the conditional breakeven stop code i mentioned above. the same strategy without this code will take something like 60 minutes to optimize but when one includes the breakeven this can take more than 5 times that amount of time. i think that in all likelihood, including even more complicated conditionals for position management should be much more problematic for the platform.


    i will have to see how this works out.

    Leave a comment:


  • NinjaTrader_BrandonH
    replied
    Hello rtwave,

    Thank you for your post.

    bltdavid is correct. This would be considered scaling into a position and it would require two separate entry orders to be placed.

    Scaling into a position is controlled with the signal names of your strategy, and properties EntryHandling and EntriesPerDirection. This reference sample can help with scaling in and out of a strategy.
    https://ninjatrader.com/support/helpGuides/nt8/en-us/scaling_out_of_a_position.htm

    This sample can assist further with managing multiple exit/entry signals:
    https://ninjatrader.com/support/helpGuides/nt8/en-us/using_multiple_entry_exit_sign.htm

    Please let us know if we may be of further assistance.

    Leave a comment:


  • bltdavid
    replied
    Originally posted by rtwave View Post
    enter short = open short position sell 1 contract short at close market ; ordinary position
    and place stop order sell short position for 1 contract at close + 16 points; pullback position

    this would be one single condition and one single entry with two separate orders, so i don't think it should be understood as pyramiding. i think i would only need a very simple working sample.
    It's called "scaling in", not "pyramiding".

    [EDIT: The opposite is called "scaling out" -- where multiple exit orders (aka, profit targets)
    are used to exit the position.]

    I understand it's one single condition, that's entirely dependent on your code, but by definition,
    scale in requires two separate entry orders, because it is, by definition, two separate entries.

    Managed or Unmanaged, doesn't matter, it's still two separate entry orders. The concepts
    of "scale-in" and "scale-out" are standard trading terms, not beholden to NinjaTrader.

    Seriously, the idea that you're doing "one single entry" with "two separate orders" is simply
    incorrect. Don't say it that way, you're just gonna confuse yourself later.

    You are opening one position with a sell order, and then adding to that same position
    with a second sell stop order. These are two separate entry orders, with the second
    entry order adding contracts to the same position created by the first entry order.

    Two separate entry orders mean two separate entries -- why you think otherwise
    is unknown -- but to continue that thinking will cause chaos as you gain experience.

    [EDIT: Also when looking at Trade Performance, each entry order is its own row,
    so two entry orders results in (at least) two rows of data.]

    Also, "ordinary" position vs "pullback" position is unholy.
    Don't think that way -- it is one single position and you are scaling in to create it.

    The single position will have an Average Entry Price, but this is obviously just the
    Fill prices from the two entry orders averaged together.

    And, yes, it can be done.
    Works great.

    Leave a comment:


  • strategies with one market and one stop market entry orders.




    people with nt,



    i have several trend following strategies that are very simple.



    in the case of a downtrend, the strategy will sell 1 contract short (of having it) and attach stop loss and breakeven stop orders to the position. this works well, the position will be held until it is stopped or until the downtrend condition is made to end.


    my strategies typically open positions at extremes and there is almost always a temporary pullback against the direction i have opened my position in. because of this i am interested in adding code to my strategies so that every position will sell one contract short at market and a second entry will be placed some points above the current price. i would use the inverse of this methodology for long positions.


    so, i want to understand whether the following position management would be possible in nt, specially if a strategy like i describe below could be backtested - optimized.


    if a downtrend starts:


    enter short = open short position sell 1 contract short at close market ; ordinary position
    and place stop order sell short position for 1 contract at close + 16 points; pullback position



    and the position management i have in mind would be as follows:

    ordinary position would have stop loss and breakeven stop orders attached to it. if price is mostly made to move in my favor, then i would have only 1 contract at risk. when this position is closed all stops should be cancelled and the second entry order that was never opened should also be cancelled.

    if price is made to move against my initial ordinary position, and the pullback position is indeed executed - filled, then i would want stop loss and breakeven stop orders to be attached to and calculated for the entire 2 contract position. this larger position will then either be held until the downtrend condition is made to end or will be stopped out.



    this would be one single condition and one single entry with two separate orders, so i don't think it should be understood as pyramiding. i think i would only need a very simple working sample.


    very well, thanks, regards.

Latest Posts

Collapse

Topics Statistics Last Post
Started by geddyisodin, Today, 05:20 AM
2 responses
16 views
0 likes
Last Post geddyisodin  
Started by hazylizard, Today, 08:38 AM
0 responses
6 views
0 likes
Last Post hazylizard  
Started by Max238, Today, 01:28 AM
5 responses
42 views
0 likes
Last Post Max238
by Max238
 
Started by giulyko00, Yesterday, 12:03 PM
3 responses
13 views
0 likes
Last Post NinjaTrader_BrandonH  
Started by habeebft, Today, 07:27 AM
1 response
16 views
0 likes
Last Post NinjaTrader_ChristopherS  
Working...
X