Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to do this?

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

    How to do this?

    I have an idea for a strategy but need help figuring out how to implement a certain function. I want to enter a trade when Close is above a set number of ticks from when a MA started to rise. So I would have to store the last price of when MA went from falling to rising and then enter a trade once my set number of ticks above that MA is reached. How would I do this?

    Thank you in advance.

    #2
    Relogical,

    Thank you for your post.

    The example below should give an outline of how to accomplish this-
    Code:
    if(Rising(SMA(14)))
    {
    	storedValue = SMA(14)[0];
    }
    			
    if(Close[0] > storedValue + 2 * TickSize)
    {
    	EnterLong();
    }
    Let me know if I can be of further assistance.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      I can't seem to get it to enter a trade when Close is > then my tick setting. I am using Forex. Are the ticks sizes the same as in stocks or is it something else? I have tried setting from .001 to 10000 and nothing works. Positions are being entered anyway. Is there anything I need to do extra?
      Last edited by relogical; 03-06-2014, 12:18 PM.

      Comment


        #4
        You can try using limit orders.

        The example I gave you submits a Market Order.

        Code:
        EnterLongLimit(storedValue + 2 * TickSize);
        http://www.ninjatrader.com/support/h...rlonglimit.htm
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          But doing a limit order won't work if I want to enter a position on a MA crossover. I have tried both ways and it's just not entering a position where I specify. It's almost like it not storing storedValue.

          Comment


            #6
            Originally posted by relogical View Post
            But doing a limit order won't work if I want to enter a position on a MA crossover. I have tried both ways and it's just not entering a position where I specify. It's almost like it not storing storedValue.
            Rising( sma) would always happen so the stored value is always updated. .hence close never gets above it by 2 ticks.

            Comment


              #7
              Here's my code. Please tell me why it;s not entering trades on my signal. Thank you

              Code:
              // Start Long
                          if (CrossBelow(T3(500, 3, 0.7), T3(500, 3, 0.7),1))
                          {
                              storedValue1 = T3(500, 3, 0.7)[0];
                          }
                          
                          if (Position.MarketPosition == MarketPosition.Flat
                              && Close[0] < storedValue1 - 100 * TickSize
                             && CrossBelow(T3(100, 3, 0.7), T3(200, 3, 0.7), 1))    
                              
                          {
                              EnterLong(DefaultQuantity, "Start Long");
                          }

              Comment


                #8
                Originally posted by relogical View Post
                Here's my code. Please tell me why it;s not entering trades on my signal. Thank you

                Code:
                // Start Long
                            if (CrossBelow(T3(500, 3, 0.7), T3(500, 3, 0.7),1))
                            {
                                storedValue1 = T3(500, 3, 0.7)[0];
                            }
                            
                            if (Position.MarketPosition == MarketPosition.Flat
                                && Close[0] < storedValue1 - 100 * TickSize
                               && CrossBelow(T3(100, 3, 0.7), T3(200, 3, 0.7), 1))    
                                
                            {
                                EnterLong(DefaultQuantity, "Start Long");
                            }
                because your first statement is looking for a cross below of two exact same T3s, thus no cross below...

                Comment


                  #9
                  That crossover is correct because it's looking for T3 to be lower then T3 one bar ago. But even if I change that to something else like
                  Code:
                  if(SMA(14)[1] > if(SMA(14)[2] && SMA(14)[0] < if(SMA(14)[1] )
                  it still does not enter trades based on my TickSize setting. Please note I am using EURUSD.

                  Comment


                    #10
                    Originally posted by relogical View Post
                    That crossover is correct because it's looking for T3 to be lower then T3 one bar ago. But even if I change that to something else like
                    Code:
                    if(SMA(14)[1] > if(SMA(14)[2] && SMA(14)[0] < if(SMA(14)[1] )
                    it still does not enter trades based on my TickSize setting. Please note I am using EURUSD.
                    What tasker said.


                    If it was correct it would be working :-)



                    It doesn't work the way you are thinking it does.

                    Try T3(500,3,0.7)[1] as one of the parameters.
                    Last edited by sledge; 03-06-2014, 05:36 PM.

                    Comment


                      #11
                      I really appreciate the help but how is that supposed to work if I only use T3(500,3,0.7)[1] as the only parameter? I am trying to store the price at the point of when T3 500 started to fall.

                      Comment


                        #12
                        Originally posted by relogical View Post
                        I really appreciate the help but how is that supposed to work if I only use T3(500,3,0.7)[1] as the only parameter? I am trying to store the price at the point of when T3 500 started to fall.
                        && CrossBelow(T3(100, 3, 0.7), T3(200, 3, 0.7)[1], 1))

                        You probably will need a currentbar check if you don't have one.

                        Comment


                          #13
                          I don't see how that code determines the point at which T3(500, 3, 0.7) is beginning to fall. My example does that (see below). My issue is that the entrees are done without considering my TickSize distance.

                          if(T3(500, 3, 0.7)[1] > if(T3(500, 3, 0.7)[2]
                          && T3(500, 3, 0.7)[0] < if(T3(500, 3, 0.7)[1] )

                          Comment


                            #14
                            Originally posted by relogical View Post
                            Here's my code. Please tell me why it;s not entering trades on my signal. Thank you

                            Code:
                            // Start Long
                                        if (CrossBelow(T3(500, 3, 0.7), T3(500, 3, 0.7),1))
                                        {
                                            storedValue1 = T3(500, 3, 0.7)[0];
                                        }
                                        
                                        if (Position.MarketPosition == MarketPosition.Flat
                                            && Close[0] < storedValue1 - 100 * TickSize
                                           && CrossBelow(T3(100, 3, 0.7), T3(200, 3, 0.7), 1))    
                                            
                                        {
                                            EnterLong(DefaultQuantity, "Start Long");
                                        }
                            Put a Print() or Draw...() statement in your order block to verify that it even gets entered. You conditions look so restrictive that I think you are not even entering the block at all.

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by stafe, Yesterday, 08:34 PM
                            1 response
                            15 views
                            0 likes
                            Last Post NinjaTrader_ChelseaB  
                            Started by jclose, Yesterday, 09:37 PM
                            1 response
                            11 views
                            0 likes
                            Last Post NinjaTrader_Gaby  
                            Started by firefoxforum12, Yesterday, 08:53 PM
                            1 response
                            15 views
                            0 likes
                            Last Post NinjaTrader_BrandonH  
                            Started by kmunroe478, Yesterday, 05:39 PM
                            2 responses
                            15 views
                            0 likes
                            Last Post NinjaTrader_Jesse  
                            Started by kevinenergy, 02-17-2023, 12:42 PM
                            115 responses
                            2,700 views
                            1 like
                            Last Post kevinenergy  
                            Working...
                            X