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

silly error. dunno where it is

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

    silly error. dunno where it is

    I get a compile error. for the life of me, i cannot find anything wrong with the code.
    can anyone take a second look. i have stared at this for atleast 1 hour.
    thanks for your help


    Code:
     protected override void OnBarUpdate()
            {
    			if(Historical)
    				return;
    			
    			If (Position.MarketPosition==MarketPosition.Flat)
    			{
    				if(Close[0]>MAX(High,20)[1]){
    					IOrder i =EnterLongLimit(MAX(High,20)[1],Instrument.FullName + "Long" + DateTime.Now.Ticks);
    					
    				}
    				
    			}
    			If (Position.MarketPosition==MarketPosition.Long)
    			{
    				null;
    			}
    			
            }

    #2
    Originally posted by junkone View Post
    I get a compile error. for the life of me, i cannot find anything wrong with the code.
    can anyone take a second look. i have stared at this for atleast 1 hour.
    thanks for your help


    Code:
     protected override void OnBarUpdate()
            {
                if(Historical)
                    return;
                
                If (Position.MarketPosition==MarketPosition.Flat)
                {
                    if(Close[0]>MAX(High,20)[1]){
                        IOrder i =EnterLongLimit(MAX(High,20)[1],Instrument.FullName + "Long" + DateTime.Now.Ticks);
                        
                    }
                    
                }
                If (Position.MarketPosition==MarketPosition.Long)
                {
                    null;
                }
                
            }
    1. What is the text of the error message?
    2. C# is case sensitive: If is not the same as if.

    Comment


      #3
      Yes, I think if you lowercase the if's and comment out the non meaningful second statement (what do you want to set to null?) you should be able to compile again.
      BertrandNinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by aligator, 01-06-2022, 12:14 PM
      4 responses
      236 views
      0 likes
      Last Post john_44573  
      Started by reynoldsn, Today, 05:56 PM
      0 responses
      8 views
      0 likes
      Last Post reynoldsn  
      Started by bortz, 11-06-2023, 08:04 AM
      51 responses
      1,990 views
      0 likes
      Last Post aligator  
      Started by dmking, 11-12-2019, 12:31 PM
      4 responses
      4,152 views
      0 likes
      Last Post jasonw
      by jasonw
       
      Started by roblogic, Today, 04:31 PM
      0 responses
      11 views
      0 likes
      Last Post roblogic  
      Working...
      X