• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

UpTick or DownTick

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

    UpTick or DownTick

    On a tick chart , is there a direct way in indicator code to find out if the last tick was up or was down?
    Or any example of code doing that please?

    Or do I need to temporarily store the value of the prior tick then compare with the current tick?

    #2
    Hello,

    Thank you for the question.

    This would depend, if you are on a 1 tick chart, you could compare the Close[0] is greater or less than the Close[1]. This is just saying to compare the close of the current bar to the close of the last bar. This would work as an indicator on a 1 tick chart.

    For greater times such as a 100 tick chart, more logic would be required to either Add a 1 tick series and use logic to check this, or to use live market data ticks and logic.

    There are multiple ways to accomplish this depending on what the intended use would be. If you can provide more detail on the timeframe it would be used with or where it would be applied, I can provide a more specific example.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      It would normally be something like a 70 tick chart.

      So there isn't something like Close[0].Tick[1].CompareTo( Close[0].Tick[0] ) ? 'Down' : 'Up' ;

      Based on code from the Heiken-Ashi indicator, I can check on each tick if the bar is still a bull bar or a bear bar. It checks if the y-coordinate of the bar is smaller or larger than where it was at the open of the bar using ChartControl.GetYByValue

      But I'd like to compare tick by tick not just compared to the open of the current bar.

      Comment


        #4
        Hello,

        For tick by tick on any series, you could use OnMarketData or an added series.

        A couple of examples would be:

        Code:
        double lastTick;
        protected override void OnMarketData(MarketDataEventArgs e)
        {
        	if(e.MarketDataType == MarketDataType.Last)
        	{
        		if(e.Price > lastTick)
        		{
        			Print("Up");	
        		} 
        		else if(e.Price < lastTick)
        		{
        			Print("Down");
        		}
        		lastTick = e.Price;
        	}
        }
        This would take each incoming last tick and compare it to the previous tick.

        Another way woud be to add a 1 tick series, the statement below could be consolidated into a statement similar to the one you provided:
        Close[0].Tick[1].CompareTo( Close[0].Tick[0] ) ? 'Down' : 'Up' ;

        Code:
        protected override void Initialize()
        {
        	Add(PeriodType.Tick, 1);
        }
        
        protected override void OnBarUpdate()
        {
        	if(BarsInProgress == 1)
        	{
        		if(CurrentBars[1] >0)
        		{
        			if(Closes[1][0] > Closes[1][1])
        			{
        				Print("Up");	
        			}
        			else if(Close[0] < Close[1])
        			{
        				Print("down");	
        			}
        		}
        	}
        }
        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by ralett, Yesterday, 07:29 PM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Marco  
        Started by bboyle1234, Yesterday, 10:46 PM
        1 response
        3 views
        0 likes
        Last Post bltdavid  
        Started by swcooke, Yesterday, 04:29 PM
        0 responses
        5 views
        0 likes
        Last Post swcooke
        by swcooke
         
        Started by bboyle1234, Yesterday, 04:27 PM
        0 responses
        2 views
        0 likes
        Last Post bboyle1234  
        Started by swcooke, Yesterday, 03:31 PM
        2 responses
        12 views
        0 likes
        Last Post swcooke
        by swcooke
         
        Working...
        X