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

I need help getitng around delayed Chart data

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

    I need help getitng around delayed Chart data

    I notice the Bid and Ask tend to be ahead of the candle sticks printing on my tick chart. In other words, the candles on the chart is always trying to catch up the trade execution at the exchanges. Have this in mind as you read the following.

    Let assume, I'm looking to execute a BUY-STOP-LIMIT trade at $10 when the following happens :

    Condition
    1. When Price crossesbleow $9.75
    2. Enter Long BUY-STOP-LIMIT trade at $10


    When I tried doing this manually, I get the error that price has already moved above $10. The delayed chart data (about one second or less) is significant enough to miss the timing of this trade manually.
    To get around this delay, I wanted to create an automated strategy that will execute the trade automatically. However, I think I will run into the same problem, if I try to use "Low[0] < $9.75" because it will be waiting for the bar to print on the chart before executing the trade. Thus, I was considering using "GetCurrentBid(0) < $9.75". Is there a way to access the "Last Price" a trade was executed (so that I can use the condition "Last Price < $9.75")?

    Your assistance will be appreciated. Thanks
    Last edited by cryfgg; 05-05-2022, 10:31 AM.

    #2
    Hi cryfgg, thanks for posting. The "last" traded price is represented in the Close array. The data coming from the data feed might be slightly faster than the visual representation on the chart (milliseconds apart). There should be no need to submit the order at 9.75 to get the order to rest at 10$. Submit the order at 10$ if the last price is below 10$. You can test this out in a script on the Sim101 account.

    Kind regards,
    -ChrisL
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChrisL View Post
      Hi cryfgg, thanks for posting. The "last" traded price is represented in the Close array. The data coming from the data feed might be slightly faster than the visual representation on the chart (milliseconds apart). There should be no need to submit the order at 9.75 to get the order to rest at 10$. Submit the order at 10$ if the last price is below 10$. You can test this out in a script on the Sim101 account.

      Kind regards,
      -ChrisL
      I understand what you're saying but that's not the strategy I'm tying to execute. That's why in my post I mentioned using a BUY-STOP-LIMIT order type. Thus, my trade will only execute if <Price crossesbleow $9.75> and then reverses (crossesabove) $9.75 to $10 .my trade will execute at $10.

      Comment


        #4
        Hi cryfgg, thanks for the follow up. The order methods will not execute any logic or conditions. The strategy needs to handle the order submission based on price movement. The EnterLongStopLimit order takes a limit price and a stop price. This defines a range of price values you are willing for the order to get filled on. The price movement order entry decisions need to be made by the strategy. To do this, check if the price crosses 9.75 and then place the order at 10$ if that becomes true.

        Best regards,
        -ChrisL
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChrisL View Post
          Hi cryfgg, thanks for the follow up. The order methods will not execute any logic or conditions. The strategy needs to handle the order submission based on price movement. The EnterLongStopLimit order takes a limit price and a stop price. This defines a range of price values you are willing for the order to get filled on. The price movement order entry decisions need to be made by the strategy. To do this, check if the price crosses 9.75 and then place the order at 10$ if that becomes true.

          Best regards,
          -ChrisL
          I will provide the limit price for the EnterLongStopLimit order in the full Ninjascript (I don't want to bore you with all the info). The question I'm really asking is what is the optimal way to check (per my example) if price has crossedbelow $9.75? Given that price will be moving extremely fast; it can crossbelow $9.75 and then crossabove $9.75 in less than 2 secs (before the Buy-Stop-Limit order is executed at $10). I want my script to be able to pickup the crossbelow $9.75 before it shows up on my chart, and automatically submit the Buy-Stop-Limit @ $10 in anticipation of the crossabove $9.75.

          Here are the options i think i have:
          1. Low[0] &lt; $9.75 ---&gt; will only work for very slow price movement or if the crossabove $9.75 happens 4 secs later.
          2. GetCurrentBid(0) &lt; $9.75 ---&gt; I think this will work bcos it doesn't rely/wait on the rendering on the chart, but I don't know if it is risky (ex. bad BID/ASk data). Can you think of any potential risk.
          3. What other options do you think I have?

          Thanks

          Comment


            #6
            Hi cryfgg, thanks for your reply. The best way to check the cross above is to use the CrossAbove() method that we have documented here:


            The OnBarUpdate method gets called in a matter of milliseconds you can assume it happens instantly. You can test out the output of CrossAbove by printing out the condition e.g.

            if(CrossAbove(Close, 9.75, 1))
            Print("CrossAbove " + Time[0]);

            To get the cross to trigger as soon as possible you would need to run the script OnEachTick. Please try this out and look at the output window for the prints.
            Chris L.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Segwin, 05-07-2018, 02:15 PM
            14 responses
            1,788 views
            0 likes
            Last Post aligator  
            Started by Jimmyk, 01-26-2018, 05:19 AM
            6 responses
            837 views
            0 likes
            Last Post emuns
            by emuns
             
            Started by jxs_xrj, 01-12-2020, 09:49 AM
            6 responses
            3,293 views
            1 like
            Last Post jgualdronc  
            Started by Touch-Ups, Today, 10:36 AM
            0 responses
            12 views
            0 likes
            Last Post Touch-Ups  
            Started by geddyisodin, 04-25-2024, 05:20 AM
            11 responses
            62 views
            0 likes
            Last Post halgo_boulder  
            Working...
            X