Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Use fixed prices as "User Defined Inputs". Possible?

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

    Use fixed prices as "User Defined Inputs". Possible?

    Im quite a newbie with a "Strategy Analizer' and i will apprecieate a little help with my strategy.

    Core idea of the strategy:

    We have a range of prices (manually settled) of CrudeLight instrument.
    (for example)
    HighPrice is: 73,50
    Low price is: 70,50
    and "middle price" is: 72,00.

    Trading conditions:
    if ask = Middle price"

    action:

    settup 2 break-out orders.
    stop-long at ""HighPrice"" and stop-sell order at "LowPrice"
    ===============================

    Plus these "prices" must be changed few times during the day, and there will be a few trades overall.



    So, should i go in such way as this looks like on these two screenshots?

    1)


    2)



    or its not the best(impossible) way to go?

    Can you advice something more?

    #2
    For the type of the variables, choose double.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Im still have some weird troubles here.
      I guess i just dont understand how to "start| my strategy or real-time (demo account).



      From the 1min chart, from the top "strategies" menyu, ive launched y system. Everything goes well, but, nothing happens when the "condition" trigger supposed to start trading....


      But, what even more weird (for me), then when i shutdows the strategy. On the chart i can see different sell and\or buy arrows. And its looks like the stategy tryed to trade there... but it didnt happened in real-time. And on previous data.


      Here is how my code looks lika at the moment.
      Any adviced?



      /// <summary>
      /// Enter the description of your strategy here
      /// </summary>
      [Description("Enter the description of your strategy here")]
      public class Hydra : Strategy
      {
      #region Variables
      // Wizard generated variables
      private double highprice = 73; // Default setting for Highprice
      private double middle = 71.75; // Default setting for Middle
      private double lowprice = 68; // Default setting for Lowprice
      // User defined variables (add any user defined variables below)
      #endregion

      /// <summary>
      /// This method is used to configure the strategy and is called once before any strategy method is called.
      /// </summary>
      protected override void Initialize()
      {
      SetStopLoss("", CalculationMode.Ticks, 30, false);
      SetProfitTarget("", CalculationMode.Ticks, 30);

      CalculateOnBarClose = true;
      }

      /// <summary>
      /// Called on each bar update event (incoming tick)
      /// </summary>
      protected override void OnBarUpdate()
      {

      // Condition set 2
      if (GetCurrentAsk() == Middle)
      {
      EnterLongStopLimit(1, Highprice, Highprice, "");
      EnterShortStopLimit(1, Lowprice, Lowprice, "");
      }

      }

      #region Properties
      [Description("Highprice")]
      [Category("Parameters")]
      public double Highprice
      {
      get { return highprice; }
      set { highprice = Math.Max(73.000, value); }
      }

      [Description("Middle")]
      [Category("Parameters")]
      public double Middle
      {
      get { return middle; }
      set { middle = Math.Max(71.75, value); }
      }

      [Description("Lowprice")]
      [Category("Parameters")]
      public double Lowprice
      {
      get { return lowprice; }
      set { lowprice = Math.Max(68, value); }
      }
      #endregion

      Comment


        #4
        Imbah, I would suggest you test with one entry side only first, as in this setup you most likely run into the 'Internal Order Handling Rules' - http://www.ninjatrader-support.com/H...verview36.html (bottom section of this link)

        Also 'TraceOrders' are very helpful to debug strategies - http://www.ninjatrader-support2.com/...ead.php?t=3627
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Hmmm, and now i even more confused. After readin these links which you gave me, i`ve decide that at first i must try to launch some super easy strategy onto chart, just to test whenever it will work or not.

          So, i`ve created a easy strategy (for a test), and i launched in onto chart via (strategies) window.

          Blah.. nothing happens.
          All i see is "old trades" which just shows me what does the strategy "supposed to do" on revious bars. But on a real-time basis nothing happens.


          Here is my code:

          /// <summary>
          /// Enter the description of your strategy here
          /// </summary>
          [Description("Enter the description of your strategy here")]
          public class Hydra2 : Strategy
          {
          #region Variables
          // Wizard generated variables
          private int myInput0 = 1; // Default setting for MyInput0
          // User defined variables (add any user defined variables below)
          #endregion

          /// <summary>
          /// This method is used to configure the strategy and is called once before any strategy method is called.
          /// </summary>
          protected override void Initialize()
          {
          SetProfitTarget("", CalculationMode.Ticks, 5);

          CalculateOnBarClose = true;
          }

          /// <summary>
          /// Called on each bar update event (incoming tick)
          /// </summary>
          protected override void OnBarUpdate()
          {
          // Condition set 1
          if (GetCurrentAsk() == 68.68)
          {
          EnterLong(DefaultQuantity, "");
          }
          }

          #region Properties
          [Description("")]
          [Category("Parameters")]
          public int MyInput0
          {
          get { return myInput0; }
          set { myInput0 = Math.Max(1, value); }
          }
          #endregion



          ================



          So, as you can see, only one "rule" here.

          I`ve tested it 10 mins ago on CL 10-09 instrument. Market touches 68.68 price for about 15 times..... nothing happens.



          I have a strange feelings, that im just forget to push some final button....
          otherwise i dont understand how a strategy with 1 rule dont work anyhow.

          Comment


            #6
            Imbah,
            On the chart you need to right click and click on "STrategies" or ("Ctrl+S") and from it to pick a strategy. Not from Strategies on Control Center!

            Baruch

            Comment


              #7
              Originally posted by Baruch View Post
              Imbah,
              On the chart you need to right click and click on "STrategies" or ("Ctrl+S") and from it to pick a strategy. Not from Strategies on Control Center!

              Baruch
              thats exactly how i do it all the time!






              btw, on that screen you can see that the sterategy "draws" an arrows'ebtryes'exit on previous data..... but it doesnt repeat same things when its about real-time....

              Comment


                #8
                Set CalculateOnBarClose =false;

                Baruch

                Comment


                  #9
                  Originally posted by Baruch View Post
                  Set CalculateOnBarClose =false;

                  Baruch

                  On these parameters (which are in picture in previous post) or should i do it on StrategyAalizer in the first window of strategy wizzard? (there is "calculate on bar close checkbox too).

                  Comment


                    #10
                    ohhhh its workin. finnaly.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by wzgy0920, 04-20-2024, 06:09 PM
                    2 responses
                    26 views
                    0 likes
                    Last Post wzgy0920  
                    Started by wzgy0920, 02-22-2024, 01:11 AM
                    5 responses
                    32 views
                    0 likes
                    Last Post wzgy0920  
                    Started by wzgy0920, Yesterday, 09:53 PM
                    2 responses
                    49 views
                    0 likes
                    Last Post wzgy0920  
                    Started by Kensonprib, 04-28-2021, 10:11 AM
                    5 responses
                    192 views
                    0 likes
                    Last Post Hasadafa  
                    Started by GussJ, 03-04-2020, 03:11 PM
                    11 responses
                    3,234 views
                    0 likes
                    Last Post xiinteractive  
                    Working...
                    X