Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

2 bug but not cause of my script... i think...

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

    2 bug but not cause of my script... i think...

    Hi, i have 2 bug in my backtesting :

    1 - my script say : when you have the signal, sell limit at the close level of the current bar... the thing is that if the limit level is not hit the next bar... the order is avoid... but sometimes we can see the limit level the second or the third bar after my signal... so how can i keep the order open as long as it is not filled ? is there a specific script, here my order :
    EnterShortLimit(
    1, Close[0], "");

    2 - basicly, my signal is to sell when i have a shooting star... my script send directly the stop in the top of my shooting star and the profit target for example 2 times the amplitude of the shooting star.... the problem is that if between the time where my script sold the market and reached the target, if the market draw a new shooting star, my script put the stop on the top of the new shooting star... so how can i let the stop on the top of my original shooting star... and not move it... here my script for my stop :
    Stop = High[0]

    thanks

    #2
    Hi Thomas79, by default orders will expire at the end of the bar - you can either resubmit them to keep them alive or use this overload for entering limit orders -

    EnterShortLimit(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double limitPrice,string signalName)

    This allows you to set the order to liveUntilCancelled, so it's kept alive automatically for you until you CancelOrder() it -

    http://www.ninjatrader-support.com/H...hortLimit.html

    For the stopLoss you want to save the high of the shooting star to a variable and use this as a stopvalue, otherwise the stop gets readjusted as you noticed.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      hi Bertrand, about the entry level, that works, thx a lot...

      but i don't understand how i can define the stopvalue on the stop, here my script for my stop

      //set a stop on the top of my shooting
      SetStopLoss(CalculationMode.Price,High[0]);

      Comment


        #4
        That code puts the stop order at the price of High[0]. You have defined a stop loss at that exact price value. If you want a different value, just use a different one.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          but i don't want to change the value... i want to keep it, the problem is that if between the time where my script sold the market and reached the target, if the market draw a new shooting star, my script put the stop on the top of the new shooting star... so how can i let the stop on the top of my original shooting star... and not move it...

          Bertrand told me to save the high of the shooting star to a variable and use this as a stopvalue,

          what i have to write on the variable to save the high of the shooting star and what i have to write on my SetStopLoss ?

          Comment


            #6
            Save it into a variable when you reach conditions. Only do this once or else you will overwrite your previously saved value.

            stopValue = High[0];

            then when you want to call your stop loss at that value:

            SetStopLoss(CalculationMode.Price, stopValue);
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              i quiet lost with the variable... i write what you said...

              Comment


                #8
                Thomas79, you would need to save this in the OnBarUpdate() when you reach your condition for tradeentry, for example -
                Code:
                 
                if (Close[0] > Close[5])
                {
                EnterLong();
                double myStop = Low[0] - TickSize;
                }
                This stores the Low - one tick offset into the variable named myStop when you enter the Long position. You can then later refer to this stop value for exiting.
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Have you declared variable stopValue, i.e. double stopValue? You can apply High[0] only at runtime (i.e. OnBarUpdate) and not during variabaes' declaration.

                  Regards
                  Ralph

                  Comment


                    #10
                    hi Bertrand, i made what you said... but it does not work, wacht my script and the result




                    Comment


                      #11
                      Thomas79, try saving it right under BackColor line when you detect your shooting star.
                      BertrandNinjaTrader Customer Service

                      Comment


                        #12
                        that not works... i tried to write :

                        'SetStopLoss(stopValue);' against that 'SetStopLoss(CalculationMode.Price, stopValue);'

                        but that not works

                        Comment


                          #13
                          Thomas79, please post your code so we can take a look and advise - thanks!
                          BertrandNinjaTrader Customer Service

                          Comment


                            #14
                            it is to long to do a copy-paste, so i give it to you as a picture

                            Comment


                              #15
                              Please describe exactly what doesn't work? What behavior are you seeing instead?
                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by pjsmith, Today, 01:00 AM
                              1 response
                              10 views
                              0 likes
                              Last Post NT-Roland  
                              Started by alejandro888, Yesterday, 08:41 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post alejandro888  
                              Started by UltraNIX, Today, 02:14 AM
                              0 responses
                              8 views
                              0 likes
                              Last Post UltraNIX  
                              Started by augustfay, Yesterday, 12:06 PM
                              1 response
                              13 views
                              0 likes
                              Last Post NinjaTrader_Jason  
                              Started by klaus w, Yesterday, 12:13 PM
                              2 responses
                              24 views
                              0 likes
                              Last Post klaus w
                              by klaus w
                               
                              Working...
                              X