Announcement

Collapse
No announcement yet.

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, 02:10 AM.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by M_ichel, Today, 08:38 AM
          0 responses
          1 view
          0 likes
          Last Post M_ichel
          by M_ichel
           
          Started by soon123, Today, 12:18 AM
          1 response
          20 views
          0 likes
          Last Post NinjaTrader_PaulH  
          Started by space_trader, Today, 12:52 AM
          1 response
          20 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by ybhx0315, Yesterday, 09:06 PM
          0 responses
          21 views
          0 likes
          Last Post ybhx0315  
          Started by parkinsonbr, Yesterday, 08:23 PM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X