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

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 Tim-c, Today, 03:54 AM
    0 responses
    3 views
    0 likes
    Last Post Tim-c
    by Tim-c
     
    Started by FrancisMorro, Today, 03:24 AM
    0 responses
    3 views
    0 likes
    Last Post FrancisMorro  
    Started by Segwin, 05-07-2018, 02:15 PM
    10 responses
    1,772 views
    0 likes
    Last Post Leafcutter  
    Started by Rapine Heihei, 04-23-2024, 07:51 PM
    2 responses
    31 views
    0 likes
    Last Post Max238
    by Max238
     
    Started by Shansen, 08-30-2019, 10:18 PM
    24 responses
    945 views
    0 likes
    Last Post spwizard  
    Working...
    X