Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Why isn't my second trade firing?

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

    Why isn't my second trade firing?

    This should also be a relatively easy one. I think this has to do with the Position Signals and perhaps my Strategy UI settings...



    I want to determine when I should fire off a second trade using my P and L.

    Example:

    I have a $400 Stop Loss...when I am down $200, I want to double my share size and then exit in full (all shares, closeout order) when the number hits 400.


    For now I am using:

    -- Entries Per Direction is set to 1
    -- Entry Handling is set to Unique
    -- Stop and Target submission is set to Per Entry Execution.


    EDIT: Now that I see the code below outside of NT I think I see my problem, so I wold just ask for confirmation as to the following: in my second trade, I can not use Closes[2][0] as my limit price; i must define the price as something that does not update with every tick bar, is this correct?


    Toy Code is as follows:



    Code:
    double upperLimitPrice;
    doubleSupportPrice;
    int shareQuantity;
    
    
    
    if ((Position.MarketPosition == MarketPosition.Flat)      
    && (Closes[2][0] <= upperLimitPrice)
    && (Closes[2][0] >= supportPrice))
    
    							
    {EnterLongLimit(2, true, shareQuantity, upperLimitPrice, "BuyLong");}
    								
    
    if ((Position.MarketPosition == MarketPosition.Long)      
    && (Position.GetProfitLoss(Closes[2][0],PerformanceUnit.Currency) <= -200.00))
    
    
    {EnterLongLimit(2, true, shareQuantity, Closes[2][0], "BuyLong2");}
    Last edited by alabell; 12-28-2012, 11:32 AM.

    #2
    Hello,

    I'm not seeing anything obviously wrong with the provided code.

    What is CalculateOnBarClose set to?

    If you were to add the line following line above your second enter long limit is the order reached?

    Print("Buy long 2 is reached");

    I look forward to assisting you further.
    LanceNinjaTrader Customer Service

    Comment


      #3
      EDIT: Now that I see the code below outside of NT I think I see my problem, so I wold just ask for confirmation as to the following: in my second trade, I can not use Closes[2][0] as my limit price; i must define the price as something that does not update with every tick bar, is this correct?

      Comment


        #4
        That line is in; I have yet to see it appear.

        Comment


          #5
          Hello,

          Originally posted by alabell View Post
          EDIT: Now that I see the code below outside of NT I think I see my problem, so I wold just ask for confirmation as to the following: in my second trade, I can not use Closes[2][0] as my limit price; i must define the price as something that does not update with every tick bar, is this correct?
          Nice catch.

          If you would like to submit a market order use EnterLong()


          However this doesn't appear to be what's causing the issue.

          I would recommend trying to create this setup with a simpler strategy (only using one data series). Without seeing the rest of your code I cannot determine what could be causing the condition to not be set to true.

          Try using Print() statements to verify values are what you expect each step of the way - Debugging your NinjaScript code.

          Additionally, be mindful of your calculate on bar close setting. If this is set to true, your strategy will only be checking for the values at the close of each bar and not with each tick.

          Please let me know if I can be of further assistance.
          LanceNinjaTrader Customer Service

          Comment


            #6
            Additionally, be mindful of your calculate on bar close setting. If this is set to true, your strategy will only be checking for the values at the close of each bar and not with each tick.
            The strategy is running on tick bars, however so it should check on every tick, no?

            Comment


              #7
              Hello,

              Only if CalculateOnBarClose is set to false


              or if you had it running on a 1 tick, tick chart
              Last edited by NinjaTrader_Lance; 12-28-2012, 12:13 PM.
              LanceNinjaTrader Customer Service

              Comment


                #8
                or if you had it running on a 1 tick, tick chart
                Yes, this option is what is happening.

                Comment


                  #9
                  Actually let me clarify, I am sure this is the case but just to confirm:

                  the default bar for my strategy in the UI is "1 minute bars", but none of the calculations run off of minute bars.

                  Instead, all strategy values and order "pricechecks" are done off of the Closes[2][x] dataseries, which is set to "1 tick" bars.

                  So all of my orders are in fact being processed on a tick by tick basis, correct? The default bar is minute, but I never use the code for a default or "unspecified" bar.....

                  Comment


                    #10
                    Hello,

                    Assuming there aren't any errors you will be calling OnBarUpdate each time your third series receives a new tick. However it is still possible results may not be as you expect depending on your method of order handling.

                    You could always add print statements at the start of your OnBarUpdate to monitor frequency.

                    Print(Closes[0][0]);
                    Print(Closes[1][0]);
                    Print(Closes[2][0]);

                    Let me know if I can assist further.
                    LanceNinjaTrader Customer Service

                    Comment


                      #11
                      Thanks Lance, this is pretty much as I have always understood things.

                      Regards,

                      Andrew

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by bmartz, Today, 09:30 AM
                      2 responses
                      11 views
                      0 likes
                      Last Post bltdavid  
                      Started by f.saeidi, Today, 11:02 AM
                      1 response
                      3 views
                      0 likes
                      Last Post NinjaTrader_BrandonH  
                      Started by geotrades1, Today, 10:02 AM
                      4 responses
                      12 views
                      0 likes
                      Last Post geotrades1  
                      Started by rajendrasubedi2023, Today, 09:50 AM
                      3 responses
                      16 views
                      0 likes
                      Last Post NinjaTrader_BrandonH  
                      Started by lorem, Today, 09:18 AM
                      2 responses
                      11 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Working...
                      X