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

developing Strategy

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

    developing Strategy

    good evening, greetings, I am developing a strategy but, I have found that:

    1. I can not adjust the offset parameters so that in purchases I start buying right after the close of the bar 0 + 1 tick is higher than the high of the first. and for sales by the low taking as gain the close 1 tick.

    2. when I run the strategy with the analyzer gives me another result than running in playback, although the desired one really shows me the playback, with the analyzer I have to modify the code, which I recommend you do to avoid running the risk when running it to reality

    Thanks in advance

    Simon Rodriguez

    #2
    Hello Simon, thanks for your post and welcome to the NinjaTrader forum.

    For #1 could you provide an example of this? Off the cuff, if you change a variable or any code in the OnStateChanged method, you must remove the script from the chart and re-start it for the changes to take effect. If you change any code within any other code area, reloading the NinjaScript with "F5" will suffice.

    For #2 please read this post from our colleague Chelsea, it describes the differences you can see between a live test and a backtest and how to minimize the error.

    I look forward to hearing from you.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      greetings and thanks for the response, I want in the case of purchases that event 0 starts to buy once it has exceeded the price of the high [1] ... y try do that whit the strategy builder but dont take efects look my image th code:

      if(close[0] > high[1]){

      EnterLong();
      }...

      can u help me please thanks... i was reading about Offset patrameters but i dn know how its work
      Last edited by simonerg; 07-22-2019, 12:20 PM.

      Comment


        #4
        Hello Simon, thanks for your reply.

        This code creates signals for me:

        Code:
        else if (State == State.Configure)
                    {
                        SetStopLoss(CalculationMode.Ticks, 10);
                    }
                }
        
        ...
        
        protected override void OnBarUpdate()
                {
                    if(CurrentBar < 1)
                        return;
        
                    if(Close[0] > High[1])
                    {
                        EnterLong();
                    }
                }
        The offset setting will add or subtract the value entered from whatever the indicator or price series returns. So if I apply a +5 tick offset to the High[1] price, then that will always add 5 ticks to the returned value.

        Please let me know if I can assist any further.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          regards,

          the code:

          protected override void OnBarUpdate ()
          {


          if (CurrentBar &lt;1)
          return;

          // Set 1
          if (
          (Close[0] > High[1] + (5 * TickSize) )
          )
          {
          Draw.ArrowUp (this, @ "FaTres1 Up Arrow_1", false, 0, 0, Brushes.CornflowerBlue);
          EnterLong (Convert.ToInt32 (DefaultQuantity), "");
          }

          whats is the correct code for do as the second pic, "buy or sell " AFTER HIGH[1] + 1 TICK

          thanks

          PD: in the strategy builder i do as u tell me.
          the signal it produces in my strategy analyzer:
          Last edited by simonerg; 07-24-2019, 09:23 AM.

          Comment


            #6
            Hello Simon, thanks for your reply.

            You would need to change this (Close[0] > High[1] + (5 * TickSize) ) to this: (Close[0] > High[1] + (1 * TickSize)), so all you need to change is the tick offset to 1. You are seeing the entry on the opening of the next bar because your strategy is running OnBarClose, so the bars you would need to look at at the one directly before the entry bar and the one before that.

            I look forward to assisting further.
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Hi chris thanks for u reply, yes in this moment is running OnBarClose, i need to change too this property to OnEachTick?..., i think that some defaults are bad my code is that:

              Description = @"Escriba la descripción de su nuevo cliente Estrategia aquí.";
              Name = "FaTres1";
              Calculate = Calculate.OnBarClose;
              EntriesPerDirection = 1;
              EntryHandling = EntryHandling.AllEntries;
              IsExitOnSessionCloseStrategy = true;
              ExitOnSessionCloseSeconds = 30;
              IsFillLimitOnTouch = false;
              MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
              OrderFillResolution = OrderFillResolution.Standard;
              Slippage = 0;
              StartBehavior = StartBehavior.WaitUntilFlat;
              TimeInForce = TimeInForce.Gtc;
              TraceOrders = false;
              RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
              StopTargetHandling = StopTargetHandling.PerEntryExecution;
              BarsRequiredToTrade = 20;
              // Disable this property for performance gains in Strategy Analyzer optimizations
              // See the Help Guide for additional information
              IsInstantiatedOnEachOptimizationIteration = true;
              Target = 30;
              Stop = 15;


              Comment


                #8
                Hi Chris, thanks for u reply,

                1. yes, the strategy is running in OnBarClose, but i THink that would be OnEachTick, think u that i should change that or in the code some defaults value add or remove:

                Description = @"Escriba la descripción de su nuevo cliente Estrategia aquí.";
                Name = "FaTres1";
                Calculate = Calculate.OnBarClose;
                EntriesPerDirection = 1;
                EntryHandling = EntryHandling.AllEntries;
                IsExitOnSessionCloseStrategy = true;
                ExitOnSessionCloseSeconds = 30;
                IsFillLimitOnTouch = false;
                MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
                OrderFillResolution = OrderFillResolution.Standard;
                Slippage = 1;
                StartBehavior = StartBehavior.WaitUntilFlat;
                TimeInForce = TimeInForce.Gtc;
                TraceOrders = false;
                RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
                StopTargetHandling = StopTargetHandling.PerEntryExecution;
                BarsRequiredToTrade = 20;
                // Disable this property for performance gains in Strategy Analyzer optimizations
                // See the Help Guide for additional information
                IsInstantiatedOnEachOptimizationIteration = true;
                Target = 30;
                Stop = 15;

                Comment


                  #9
                  Hi Chris thanks for reply, yes, of course im runing the strategy OnBarClose, Think U tha i should change?, and change another property mi code add or remove??:


                  Description = @"Escriba la descripción de su nuevo cliente Estrategia aquí.";
                  Name = "FaTres1";
                  Calculate = Calculate.OnBarClose;
                  EntriesPerDirection = 1;
                  EntryHandling = EntryHandling.AllEntries;
                  IsExitOnSessionCloseStrategy = true;
                  ExitOnSessionCloseSeconds = 30;
                  IsFillLimitOnTouch = false;
                  MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
                  OrderFillResolution = OrderFillResolution.Standard;
                  Slippage = 1;
                  StartBehavior = StartBehavior.WaitUntilFlat;
                  TimeInForce = TimeInForce.Gtc;
                  TraceOrders = false;
                  RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
                  StopTargetHandling = StopTargetHandling.PerEntryExecution;
                  BarsRequiredToTrade = 20;
                  // Disable this property for performance gains in Strategy Analyzer optimizations
                  // See the Help Guide for additional information
                  IsInstantiatedOnEachOptimizationIteration = true;
                  Target = 30;
                  Stop = 15;

                  Comment


                    #10

                    Description = @"Escriba la descripción de su nuevo cliente Estrategia aquí.";
                    Name = "FaTres1";
                    Calculate = Calculate.OnBarClose;
                    EntriesPerDirection = 1;
                    EntryHandling = EntryHandling.AllEntries;
                    IsExitOnSessionCloseStrategy = true;
                    ExitOnSessionCloseSeconds = 30;
                    IsFillLimitOnTouch = false;
                    MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
                    OrderFillResolution = OrderFillResolution.Standard;
                    Slippage = 1;
                    StartBehavior = StartBehavior.WaitUntilFlat;
                    TimeInForce = TimeInForce.Gtc;
                    TraceOrders = false;
                    RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
                    StopTargetHandling = StopTargetHandling.PerEntryExecution;
                    BarsRequiredToTrade = 20;
                    // Disable this property for performance gains in Strategy Analyzer optimizations
                    // See the Help Guide for additional information
                    IsInstantiatedOnEachOptimizationIteration = true;
                    Target = 30;
                    Stop = 15

                    Comment


                      #11
                      hi thanks crhis thin u that i should change some properties for my strategy work awsome??... i do the change tha u tellme but doesnt work
                      Last edited by simonerg; 07-24-2019, 10:51 AM.

                      Comment


                        #12
                        Hello simonerg, thanks for your reply.

                        Yes, you would need to change your High[1] offset to 1 tick instead of 5 ticks in the builder (if you are still using the builder). This would define the condition you mentioned in your last post. If you can Export your strategy if you're still having trouble and I can take a look at it.



                        Chris L.NinjaTrader Customer Service

                        Comment


                          #13
                          hi Chris thnks for continous reply, ur awsome, i send u the code por inbox thanks

                          Comment


                            #14
                            i have a create some indicators, additionally it is if these must also be configured by default Calcule.oneachTick or .BarClose ??

                            Comment


                              #15
                              Hi simonerg, thanks for your reply.

                              I'm not sure if I understand. If you are using these indicators in your strategy, then the indicator will use the same calculation mode of the host strategy.

                              Best regards.
                              Chris L.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by RookieTrader, Today, 09:37 AM
                              3 responses
                              14 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by kulwinder73, Today, 10:31 AM
                              0 responses
                              5 views
                              0 likes
                              Last Post kulwinder73  
                              Started by terofs, Yesterday, 04:18 PM
                              1 response
                              22 views
                              0 likes
                              Last Post terofs
                              by terofs
                               
                              Started by CommonWhale, Today, 09:55 AM
                              1 response
                              3 views
                              0 likes
                              Last Post NinjaTrader_Erick  
                              Started by Gerik, Today, 09:40 AM
                              2 responses
                              7 views
                              0 likes
                              Last Post Gerik
                              by Gerik
                               
                              Working...
                              X