Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 -



    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 quantismo, Yesterday, 05:13 PM
                              2 responses
                              16 views
                              0 likes
                              Last Post quantismo  
                              Started by maybeimnotrader, Yesterday, 05:46 PM
                              4 responses
                              24 views
                              0 likes
                              Last Post maybeimnotrader  
                              Started by frankthearm, Today, 09:08 AM
                              6 responses
                              25 views
                              0 likes
                              Last Post frankthearm  
                              Started by adeelshahzad, Today, 03:54 AM
                              5 responses
                              33 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Started by stafe, 04-15-2024, 08:34 PM
                              7 responses
                              32 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Working...
                              X