• 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

Boolean Switch

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

    Boolean Switch

    Hi Guys,

    this is prob a general programming question, could anybody tell me how i can switch a bool within a strategy?

    For example in the below script how do I switch the startstrategy bool automatically from true to false after first trade?
    Code:
    private bool startstrategy = true;
    
    protected override void OnBarUpdate()
    	{
    if (startstrategy == true)
    {
    DefaultQuantity = 100000;
    Switch startstrategy to false;
    }

    #2
    Hello sburtt,

    Thank you for your post.

    So would this be True to enter the trade and set False once the entry has been placed?

    I look forward to your response.
    Patrick H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_PatrickH View Post
      Hello sburtt,

      Thank you for your post.

      So would this be True to enter the trade and set False once the entry has been placed?

      I look forward to your response.
      exactly, but i think the answer is quite simple

      if (startstrategy == true)
      {
      DefaultQuantity = 100000;
      Switch startstrategy = false;
      }

      Comment


        #4
        Hello sburtt,

        Thank you for your response.

        I am not sure what you are attempting here. If I was going to set a bool for entry I would set some thing like the following:
        Code:
        if(startstrategy)
        {
        EnterLong();
        startstrategy = false;
        }
        Please let me know if I may be of further assistance.
        Patrick H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Steve L, Today, 05:01 PM
        0 responses
        6 views
        0 likes
        Last Post Steve L
        by Steve L
         
        Started by Trader-Joe, Today, 04:06 PM
        1 response
        13 views
        0 likes
        Last Post NinjaTrader_ShawnB  
        Started by vantojo, Today, 04:06 PM
        0 responses
        5 views
        0 likes
        Last Post vantojo
        by vantojo
         
        Started by tonynt, Today, 02:39 PM
        2 responses
        13 views
        0 likes
        Last Post tonynt
        by tonynt
         
        Started by StevenNelson, Today, 12:23 PM
        1 response
        12 views
        0 likes
        Last Post NinjaTrader_PatrickG  
        Working...
        X