Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnMarketData and tick resolution

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

    OnMarketData and tick resolution

    Hello!
    I have the next problem.
    In my strategy I'm using multiple timeframes (1minute and 60minutes).
    The Entry Logics are on 1 minute timeframe.
    To Exit the positions I'm using OnMarketData with this code:


    Code:
    protected override void OnMarketData(MarketDataEventArgs marketDataUpdate)
    {
    if (marketDataUpdate.MarketDataType == MarketDataType.Last)
    {
    if(Position.MarketPosition == MarketPosition.Long)
    {
    if(mycondition)
    {
    ExitLong(0, orderSize, "Exit Long", "Enter Long");
    }
    }
    }
    The problem is, that when I'm testing this strategy in Analyzer it does'nt works fine. All timestamps are only from 1 minute timeframe (on Entries and on Exits). Tick Replay is on.
    One problem is that now it seems like Strategy Analyzer ignores the Highs and Lows of bars - it must be the stoploss and ExitLong triggered, but the Close of the bar was higher then SL price - and it ignored this ExitLong. After some time, when Close comes lower - it comes.

    What I need to do?
    Thanks.

    #2
    Hello YevhenShynkarenko,

    When you say "All timestamps are only from 1 minute timeframe", what timestamps are you referring to? The code you have provided does not have any prints in it.
    I would be expecting:
    Code:
    Print(string.Format("{0} | market data update | {1}", marketDataUpdate.Time, marketDataUpdate));
    Or something like it, to see the time stamps of each market update..

    Are you printing the Highs and Lows to see these are being ignored in OnBarUpdate()?

    When you mention:
    " when I'm testing this strategy in Analyzer it does'nt works fine"

    What is not working fine?

    TickReplay cannot be used for order fill accuracy. Are you expecting the order fill prices to change? (They won't)
    An added 1 tick series would need to be used for accurate fill prices.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    45 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    21 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    31 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    50 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    42 views
    0 likes
    Last Post CarlTrading  
    Working...
    X