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

Just 1 order per day?

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

    Just 1 order per day?

    Hey there,

    So i programmed a strategy that opens a order every Wednesday.
    I also added a stoploss to it.


    Code:
    if (Time[0].DayOfWeek == DayOfWeek.Wednesday)
    
    
    {
    				EnterLong(Convert.ToInt32(DefaultQuantity), "");
    			
    			
    		}


    The only problem I have is that im getting more then 1 order per day because the old order got stopped.

    So if a order gets in and this order gets stopped, a second order gets in.


    Is there a way to limit this?

    I only want 1 order per day.

    #2
    Originally posted by SpaceGrey View Post
    Hey there,

    So i programmed a strategy that opens a order every Wednesday.
    I also added a stoploss to it.


    Code:
    if (Time[0].DayOfWeek == DayOfWeek.Wednesday)
    
    
    {
                    EnterLong(Convert.ToInt32(DefaultQuantity), "");
                
                
            }
    The only problem I have is that im getting more then 1 order per day because the old order got stopped.

    So if a order gets in and this order gets stopped, a second order gets in.


    Is there a way to limit this?

    I only want 1 order per day.
    Use a boolean flag.
    Code:
    //In Variables section
    private bool TradingEnabled = false;
    
    //In OBU
    if (Time[0].DayOfWeek == DayOfWeek.Tuesday)
    {
                    TradingEnabled = true;
    } 
           
    if (Time[0].DayOfWeek == DayOfWeek.Wednesday && TradingEnabled)
    {
                    EnterLong(Convert.ToInt32(DefaultQuantity), "");
                    TradingEnabled = false;
    }

    Comment


      #3
      Hm that doesnt seem to work:

      This is how I did it:


      Code:
        
      
      // my variable section
      	private bool TradingEnabled = false;
      
      
      
      
      
      // my onBarUpdate() section
      
       // set 1
      			if (Time[0].DayOfWeek == DayOfWeek.Wednesday)
      			{
      				EnterLong(Convert.ToInt32(DefaultQuantity), "");
      			TradingEnabled = true;
      				
      			
      		}		
      
      
      
      I still have more then one order every wednesday

      Comment


        #4
        Hello SpaceGrey,

        I have attached a sample which will make only 1 trade per day.

        To do this I reset the bool in the if statement,
        Code:
        if (Bars.IsFirstBarOfSession == true)
        Please see attached and let us know if you need further assistance.
        Attached Files
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_AlanP View Post
          Hello SpaceGrey,

          I have attached a sample which will make only 1 trade per day.

          To do this I reset the bool in the if statement,
          Code:
          if (Bars.IsFirstBarOfSession == true)
          Please see attached and let us know if you need further assistance.
          Hey thank you very much Alan - I converted it into NinjaTrader 7 and now it works perfect
          Last edited by SpaceGrey; 09-05-2017, 03:10 AM.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by PhillT, 04-19-2024, 02:16 PM
          4 responses
          31 views
          0 likes
          Last Post PhillT
          by PhillT
           
          Started by ageeholdings, 05-01-2024, 05:22 AM
          5 responses
          36 views
          0 likes
          Last Post ageeholdings  
          Started by reynoldsn, Today, 02:34 PM
          0 responses
          10 views
          0 likes
          Last Post reynoldsn  
          Started by nightstalker, Today, 02:05 PM
          0 responses
          17 views
          0 likes
          Last Post nightstalker  
          Started by llanqui, Yesterday, 09:59 AM
          8 responses
          30 views
          0 likes
          Last Post llanqui
          by llanqui
           
          Working...
          X