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

StopBuy and StopSell

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

    StopBuy and StopSell

    Sometimes especially in very volatile markets my strategy produces an error because I'm using StopBuy and StopSell orders and the market is already passed these.

    So I use the GetCurrentAsk and GetCurrentBid functions in the way posted afterwards. Would this be the correct way to do it?

    Code:
    if (GetCurrentAsk() < entry) StopBuy();
    if (GetCurrentBid() > entry) StopSell();

    Thanks!

    #2
    Hi symphys,

    I'm not sure what the value for "entry" is, however you could also simply use GetCurrentAsk() in EnterLongStop(double stopPrice), for example.
    TimNinjaTrader Customer Service

    Comment


      #3
      Thanks for your answer.
      While entry is a value anywhere above/below the current market price I just want to make sure that the Stop orders can be send.

      So I guess I just want to know what the least minimum price is when the strategy enters a long/short stop position?

      Testing in DOM with Ask 1,4898, Bid 1,4896 I can enter both sides long/short at bid price. This would mean my code is wrong and I would only need to check my entry against GetCurrentBid.

      Comment


        #4
        Hi symphys,

        The minimum price would technically be the current bid or ask, of course whether you get filled at that price is out of your control, and the market could obviously move up or down, getting a better fill. However, if you use GetCurrentAsk() when entering long, you'd get a price very close to the current price traded.

        You can attempt to enter the market at any price you want, however, using a EnterLongStop() should only let you submit at a price above the market, otherwise you would get an error or be filled immediately at the market price.
        TimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by JonesJoker, 04-22-2024, 12:23 PM
        8 responses
        41 views
        0 likes
        Last Post JonesJoker  
        Started by timko, Today, 06:45 AM
        0 responses
        3 views
        0 likes
        Last Post timko
        by timko
         
        Started by Waxavi, 04-19-2024, 02:10 AM
        2 responses
        38 views
        0 likes
        Last Post poeds
        by poeds
         
        Started by chbruno, Yesterday, 04:10 PM
        1 response
        44 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by Max238, Today, 01:28 AM
        1 response
        25 views
        0 likes
        Last Post CactusMan  
        Working...
        X