Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem with Limit Orders

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

    Problem with Limit Orders

    Hi,

    I've just purchased my lifetime license, and will be going live on a new strategy rollout pretty soon. I was hoping to get some advice regarding a question I have with setting limit orders.

    In my old breakout strategy, I would immediately enter a market order the moment my breakout conditions were met. However, that always resulted in a bad price, since I'd be buying into the initial breakout spike and selling into the initial breakout plunge.

    As such, I'm seeking to enter a limit order 10 pips above/below the price observed when the conditions were first met (ie: 10 pips from where my old strategy would have entered the market immediately).

    However, after changing the code, my strategy goes crazy, entering limit orders and cancelling them immediately after entering them. I suspect the problem lies with GetCurrentBid since the current bid is always changing (Have attached a snippet of the code below). As such, what I really need is a method to "fix" or "record" the price initially observed when my entry conditions are all met (where my old strategy would have entered the market), then use that price as a reference for a limit order.

    Can someone advise me with a line of code on how I can achieve my desired outcome?



    Old Strategy Code

    if (Entry Conditions True)

    EnterLong(50000,"");

    New Strategy Code (Problematic)

    if (Entry Conditions True)

    {EnterLongLimit(50000, GetCurrentBid() - 100 * TickSize, "");


    Many Thanks!

    #2
    Hello,

    Thanks for the forum post.

    Yes this is the issue. As you are constantly changing to the limit price. Are you running this code Calculate On Bar Close = True or False as the method would change depending on this. Also, I left the other forum post open so that other members of the community can respond.

    Also, you need to understand the for EnterLongLimit you will need to resubmit this on every bar for the order to remain active. So the goal that we need to achieve here is find one price that you want to submit that at and then continue to submit EnterLOngLimit on every bar for this one price. This will involve using a counter or one time calculation to find this price. Instead of using a new price on every OnBarUpdate().

    Let me know if I can be of further assistance.


    Let me know if I can be of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by terofs, Yesterday, 04:18 PM
    1 response
    21 views
    0 likes
    Last Post terofs
    by terofs
     
    Started by CommonWhale, Today, 09:55 AM
    1 response
    3 views
    0 likes
    Last Post NinjaTrader_Erick  
    Started by Gerik, Today, 09:40 AM
    2 responses
    7 views
    0 likes
    Last Post Gerik
    by Gerik
     
    Started by RookieTrader, Today, 09:37 AM
    2 responses
    13 views
    0 likes
    Last Post RookieTrader  
    Started by alifarahani, Today, 09:40 AM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X