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

How can I place an order at bid when entering long, at ask when entering short?

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

  • NinjaTrader_Jesse
    replied
    Hello rocketman7,

    When backtesting only the OHLCVT values are known for each bar so the ask and bid are unknown and the close is substituted with those methods. It is noted in the help guide that the close is substituted during historical tests. You can use TickReplay to get historical ask and bid prices at the time of the last or if you wanted the full granularity and are using a data provider that has historical ask and bid data you can add a secondary ask and bid series to reference which will give you ask and bid values in a backtest.

    Leave a comment:


  • rocketman7
    replied
    On the backtesting, shouldn't they have the same result as GetCurrentBid/Ask will bring the Close price we had used in EnterLong/EnterShort?
    I have quite different results when applying each line on the backtesting.

    Code:
    EnterLong(Convert.ToInt32(DefaultQuantity), "");
    EnterLongLimit(Convert.ToInt32(DefaultQuantity), GetCurrentBid()  , "");
    Code:
    EnterShort(Convert.ToInt32(DefaultQuantity), "");
    EnterShortLimit(Convert.ToInt32(DefaultQuantity), GetCurrentAsk()  , "");

    Leave a comment:


  • NinjaTrader_Jesse
    replied
    Hello rocketman7,

    That is correct, in historical data those return the close price.

    Leave a comment:


  • rocketman7
    replied
    Are GetCurrentBid() and GetCurrentAsk() only working when State is realtime?

    Leave a comment:


  • NinjaTrader_Jesse
    replied
    Hello rocketman7,

    You would need to use a Limit type order to do that however keep in mind that a limit does not guarantee that the order will be executed only that it has a fixed price. As long as that price is traded then it could be executed.

    Leave a comment:


  • How can I place an order at bid when entering long, at ask when entering short?

    I searched various options of how I place orders on the Strategy, but I can't find how I can place an order at bid when entering long, and vice versa.

    EnterLong and EnterShort are market order so I'd like to place my order at where bid and ask prices are respectively.

    Thanks

Latest Posts

Collapse

Topics Statistics Last Post
Started by sofortune, Today, 02:31 AM
0 responses
7 views
0 likes
Last Post sofortune  
Started by sofortune, Today, 01:55 AM
1 response
5 views
0 likes
Last Post sofortune  
Started by cls71, Today, 01:37 AM
0 responses
8 views
0 likes
Last Post cls71
by cls71
 
Started by WHICKED, 06-27-2023, 12:07 PM
63 responses
764 views
1 like
Last Post Leeroy_Jenkins  
Started by rtwave, Today, 12:10 AM
0 responses
6 views
0 likes
Last Post rtwave
by rtwave
 
Working...
X