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 to specify that I want long position to be taken in the current bar itself

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

    How to specify that I want long position to be taken in the current bar itself

    Hi,

    I am beginner in programming NinjaScript, and have a question on NinjaScript.
    Suppose I write the following code:

    if (MAX(High, 10)[1] > High[0])
    {
    EnterLongLimit(MAX(High, 10)[1] + 0.05);
    }

    I believe the following is what happens (assuming daily prices) if I run the above code: If today’s high is greater than the highest high of last 10 days excluding today, a long position will be taken tomorrow at the specified limit price. Is my understanding correct? If so, how can I specify that the long position should be taken today itself (i.e., in the current bar 0) at the specified limit price?

    Thanks

    Vineeth

    #2
    One more thing: This is purely for doing backtesting based on historical daily data

    Comment


      #3
      I am sorry for all the confusion. There was a mistake in the earlier code. The correct code should be:

      if (High[0] > MAX(High, 10)[1])
      {
      EnterLongLimit(MAX(High, 10)[1] + 0.05);
      }

      Comment


        #4
        Hello vineeth,

        Thanks for your posts.

        Using daily bars you would be unable to enter on the same bar that the condition is true because the condition is not known until the end of the daily bar.

        What you could do is add an intraday data series and check the high of each bar against the prior 10 day daily high and submit the order at that time, intraday. Here is a link to a reference strategy that demonstrates adding a faster data series for intrabar fills. https://ninjatrader.com/support/foru...ead.php?t=6652
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by algospoke, 04-17-2024, 06:40 PM
        3 responses
        26 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by bmartz, 03-12-2024, 06:12 AM
        3 responses
        27 views
        0 likes
        Last Post NinjaTrader_Zachary  
        Started by Aviram Y, Today, 05:29 AM
        2 responses
        8 views
        0 likes
        Last Post Aviram Y  
        Started by gentlebenthebear, Today, 01:30 AM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by cls71, Today, 04:45 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X