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

IF First Tick Of Bar Enter

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

    IF First Tick Of Bar Enter

    Hi,

    I am trying to code the line in my strategy saying that if previous conditions are met and If First tick of bar paints up(green)/down(red) enter long/short.

    Below is my attempt to code it but i can not figure out the missing part

    If (FirstTickOfBar > ??)
    {
    If (Conditions)
    Enterlong();
    }

    Any ideas?

    #2
    Hello Rawheritage,

    Thanks for writing in to our Support team.

    I suggest checking the close value of the previous bar against the value of the first incoming tick rather than checking what color the bar is painting - the bar will paint green if the first incoming tick is at a higher price than the close of the previous bar, and red if it is lower than the close of the previous bar. It is also important to note that you must set CalculateOnBarClose to false in order for FirstTickOfBar to pick up the first tick.

    For example:

    if(FirstTickOfBar && Close[0] > Close[1])
    EnterLong();

    Please let me know if I may be of any further assistance.
    Alan S.NinjaTrader Customer Service

    Comment


      #3
      Thanks.
      Would this solution also apply to a different dataseries like NTRenkoCandle?

      Comment


        #4
        Hello Rawheritage,

        Thanks for your reply.

        This solution will apply to other bar types - Close[] will always refer to the closing price of the bar and this will vary depending on the interval used, the bar type, and the instrument you are viewing.

        You can find more information on Close[] in our help guide here:
        http://ninjatrader.com/support/helpGuides/nt7/close.htm

        Please let me know if I may be of any further assistance.
        Alan S.NinjaTrader Customer Service

        Comment


          #5
          Thank you.

          Perhaps there is a way to check what color the first tick of bar paints then rather than comparing bar open close ?

          Comment


            #6
            Hello Rawheritage,

            The best way to do this is to check the close value of the previous bar against the value of the first incoming tick.

            You may access the UpColor or DownColor via ChartControl.BarsArray[0].BarsData.ChartStyle.UpColor but you cannot incorporate the color of a bar directly into a check unless you set it yourself via BarColor. The color set by BarColor will only be able to be accessed by the script that is setting BarColor and will be empty until it is set.

            You can find more information about BarColor here:
            http://ninjatrader.com/support/helpG...7/barcolor.htm

            Please let me know if I may be of any further assistance.
            Alan S.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by algospoke, Today, 06:40 PM
            0 responses
            9 views
            0 likes
            Last Post algospoke  
            Started by maybeimnotrader, Today, 05:46 PM
            0 responses
            7 views
            0 likes
            Last Post maybeimnotrader  
            Started by quantismo, Today, 05:13 PM
            0 responses
            7 views
            0 likes
            Last Post quantismo  
            Started by AttiM, 02-14-2024, 05:20 PM
            8 responses
            168 views
            0 likes
            Last Post jeronymite  
            Started by cre8able, Today, 04:22 PM
            0 responses
            10 views
            0 likes
            Last Post cre8able  
            Working...
            X