• 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

prevent execution of script

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

  • koganam
    replied
    Originally posted by MM345 View Post
    Hi, I currently have a check in place that prints a message if a condition is met warning me NOT to use the strategy:

    In OnStateChange( ):
    Code:
    			
    else if (State == State.DataLoaded)
    {
    	if (ConditionA){
    	    Print("ERROR, don't run script");
    	    Log("ERROR, don't run script", NinjaTrader.Cbi.LogLevel.Error);
    	}
    }
    But instead of simply printing out error messages and then continuing with execution of the script, I want the script to terminate immediately without moving on. That way it doesn't do anything prior to my noticing the error messages What can I add to the above code to accomplish that?
    Code:
    //As a class variable
    private TradingAllowed = false;
    In OnStateChange( ):
    Code:
    			
    else if (State == State.DataLoaded)
    {
    	if (ConditionA){
    	    Print("ERROR, don't run script");
    	    Log("ERROR, don't run script", NinjaTrader.Cbi.LogLevel.Error);
                TradingAllowed = false;
    	}
            else {
                TradingAllowed = true;
            }
    }
    Code:
    //In OnBarUpdate
    if (!TradingAllowed) return;
    //rest of OBU goes here
    Last edited by koganam; 04-02-2017, 08:43 PM.

    Leave a comment:


  • MM345
    started a topic prevent execution of script

    prevent execution of script

    Hi, I currently have a check in place that prints a message if a condition is met warning me NOT to use the strategy:

    In OnStateChange( ):
    Code:
    			
    else if (State == State.DataLoaded)
    {
    	if (ConditionA){
    	    Print("ERROR, don't run script");
    	    Log("ERROR, don't run script", NinjaTrader.Cbi.LogLevel.Error);
    	}
    }
    But instead of simply printing out error messages and then continuing with execution of the script, I want the script to terminate immediately without moving on. That way it doesn't do anything prior to my noticing the error messages What can I add to the above code to accomplish that?

Latest Posts

Collapse

Topics Statistics Last Post
Started by HiddenPhilosopher, Today, 06:45 AM
1 response
9 views
0 likes
Last Post NinjaTrader_ChelseaB  
Started by PG7940, Today, 04:26 AM
1 response
13 views
0 likes
Last Post NinjaTrader_ChelseaB  
Started by Sh00tHerMcGavin, Yesterday, 07:39 PM
1 response
9 views
0 likes
Last Post NinjaTrader_ChelseaB  
Started by dltharpe, Today, 09:17 AM
0 responses
7 views
0 likes
Last Post dltharpe  
Started by marcus2300, Today, 02:25 AM
1 response
4 views
0 likes
Last Post NinjaTrader_ChrisL  
Working...
X