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

Indicator Not Plotting when changing instrument

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

    Indicator Not Plotting when changing instrument

    Hi,

    I have created a simple indicator that it is plotting correctly when I choose certain forex pairs, but when I chance the instrument from EURJPY to GBPAUD per say, it doesn't plot anymore. Also it seems to only work with time frames smaller than 10 min, so when the 15 min or 30 chart are selected the indicator doesn't work anymore. The estrange thing also is that with GBPUSD pair the indicator does work when time frames greater than 10 are selected, but will not work with a 17 min chart or greater. Very, very weird. If any body can help me with this I would greatly appreciated.

    I have attached the indicator in case you guys want to test it on your side.

    Thanks for all the help provided
    Attached Files

    #2
    Hello BuhoTrader1,
    Please make sure you have enough bars before accessing historical values. Please refer to this post which further describes the scenario.


    Code:
    if (CurrentBar > cantidad && cantidad >= 3)
    {
      //do something
    }
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      thanks for the info, I looked at the other post and adding the line
      if (CurrentBar < 1)
      return;

      provided in the post made it work for the other forex pairs that were not working. The problem of only being able to plot this indicator in charts smaller than 10 persists tough. and I have plenty of bars to test the indicator on.Llike I described in the first post, I may have the GBPUSD with a time frame of 15 min, and the indicator would plot fine, but if I change it to EURJPY, the same chart, same amount of bars, it wouldn't plot. I tried the code line you provided and it didnt seem to fix the issue. ANy other ideas?
      Thanks,

      Comment


        #4
        Hello BuhoTrader1,
        You have to make sure you have checked for the bars at the appropriate place.

        Code:
        protected override void OnBarUpdate()
        { 
        	int cantidad = 0;
        	
        
        				
        	if( Close[0] < Open[0] ) //Si es barra roja
        	{
        		do
        		{
        			cantidad = cantidad + 1;
        			[B]if (CurrentBar < cantidad) return;[/B]
        			
        		}while(Close[cantidad] < Open[cantidad]);
        		
        		if (cantidad >= 3)
        			Bearac.Set((Open[cantidad] + Close[0] )/2);
        	}
        	else if( Close[0] > Open[0] ) //Si es barra verde
        	{
        		do
        		{
        			cantidad = cantidad + 1;
        			[B]if (CurrentBar < cantidad) return;[/B]
        			
        		}while(Close[cantidad] > Open[cantidad]);
        //				
        		//Bullac.Set(cantidad);
        		if (cantidad >= 3)
        			Bullac.Set((Open[cantidad - 1] + Close[0] )/2);
        	}
        }
        Now the indicator dont throws any errors.
        JoydeepNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by rtwave, 04-12-2024, 09:30 AM
        5 responses
        37 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by funk10101, Today, 12:02 AM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by GLFX005, Today, 03:23 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by nandhumca, Yesterday, 03:41 PM
        1 response
        13 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by The_Sec, Yesterday, 03:37 PM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X