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 caacapital, Today, 10:10 AM
          1 response
          11 views
          0 likes
          Last Post NinjaTrader_ShawnB  
          Started by DiverG20, Today, 10:23 AM
          0 responses
          17 views
          0 likes
          Last Post DiverG20  
          Started by SuneSorgenfrei, Today, 09:29 AM
          0 responses
          15 views
          0 likes
          Last Post SuneSorgenfrei  
          Started by dodoei, Today, 07:24 AM
          0 responses
          14 views
          0 likes
          Last Post dodoei
          by dodoei
           
          Started by thecashguys, Today, 06:13 AM
          0 responses
          12 views
          0 likes
          Last Post thecashguys  
          Working...
          X