• 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 iishkuatcyta, Today, 02:43 AM
        0 responses
        1 view
        0 likes
        Last Post iishkuatcyta  
        Started by curious, Today, 02:17 AM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_EricB  
        Started by pmmkm, Yesterday, 11:13 PM
        0 responses
        3 views
        0 likes
        Last Post pmmkm
        by pmmkm
         
        Started by pulpiwapi, 03-04-2019, 11:18 PM
        11 responses
        149 views
        0 likes
        Last Post music_p13  
        Started by indy73, 06-25-2019, 10:52 PM
        3 responses
        20 views
        0 likes
        Last Post sledge
        by sledge
         
        Working...
        X