Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

3 bar up / down trend

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

    #16
    ok the strategy works but whats happening is its buying after the 3rd bar up which is fine but then if theres another 3 bars after that its buying again , i want it to only buy after that trend is over , is this possible ?

    see the red and green arrows , these are my buy and sell signals, this is what i want the strategy to look like ,
    Attached Files

    Comment


      #17
      Hello benrock,
      Yes, it can be done if you code your strategy via the NinjaScript editor. A basic concept will be you set a boolean to true/false to turn on/off entering into a position.

      in the variable region declare 2 boolean fields
      Code:
      private bool isBuy = true;
      private bool isSell = true;
      in OnBarUpdate
      Code:
      if (isBuy && other buy entry conditions)
      {
          isBuy = false;   //setting it to false makes sure there is no additional buys
          isSell = true;     //resets isSell so that buy orders can be taken
         //rest of the buy order codes
      }
      
      if (isSell && other sell entry conditions)
      {
          isBuy = true;   //resets buy so that buy orders can be taken
          isSell = false;   //set isSell to false so that no other sell is taken
          
          //rest of the sell order codes
      }
      Please let me know if I can assist you any further.
      JoydeepNinjaTrader Customer Service

      Comment


        #18
        put the codes in but i got about 20 error messages

        Comment


          #19
          please have a look , im not getting anything close to what im looking for

          thanks guys





          #region Using declarations
          using System;
          using System.ComponentModel;
          using System.Diagnostics;
          using System.Drawing;
          using System.Drawing.Drawing2D;
          using System.Xml.Serialization;
          using NinjaTrader.Cbi;
          using NinjaTrader.Data;
          using NinjaTrader.Indicator;
          using NinjaTrader.Gui.Chart;
          using NinjaTrader.Strategy;
          #endregion

          // This namespace holds all strategies and is required. Do not change it.
          namespace NinjaTrader.Strategy
          {
          /// <summary>
          /// Enter the description of your strategy here
          /// </summary>
          [Description("Enter the description of your strategy here")]
          public class MyCustomStrategy : Strategy
          {
          #region Variables
          // Wizard generated variables
          // 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, 2);
          SetStopLoss("", CalculationMode.Ticks, 3, false);

          CalculateOnBarClose = true;
          }
          private bool isBuy = true;
          private bool isSell = true;

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


          {if (CurrentBar < 3) return;
          //rest of the codes

          {
          isBuy = false; //setting it to false makes sure there is no additional buys
          isSell = true; //resets isSell so that buy orders can be taken
          //rest of the buy order codes
          }


          {
          isBuy = true; //resets buy so that buy orders can be taken
          isSell = false; //set isSell to false so that no other sell is taken

          //rest of the sell order codes
          }
          // Condition set 1
          if (Close[0] > Close[1]
          && Close[1] > Close[2]
          && Close[2] == Close[3])
          {
          EnterLong(DefaultQuantity, "");
          EnterShort(DefaultQuantity, "");
          }
          }

          #region Properties
          #endregion
          }
          }

          Comment


            #20
            Hello,

            Unfortunately we cannot debug custom code. We would reply on NinjaScript consultants for this.



            If you have any specific questions we are able to answer them for you.

            -Brett
            BrettNinjaTrader Product Management

            Comment


              #21
              i dont understand one guy helps me write it and then another guy tells me he cant help with it ., ? whats with that ? im not going to hold you resposible if it dosent work , you should come up with a wavier for people to sign so we can get proper help , this is crazy to lead me all this way then tell me u cant help me

              Comment


                #22
                Sorry if you feel you were mislead.

                We try to assist when possible, however code review and assisting with code debug is unfortunately not something we can assist with. With NinjaScript support we are here to answer and specific questions you have and we are happy to do so.

                -Brett
                BrettNinjaTrader Product Management

                Comment


                  #23
                  Hi Benrock,

                  I was a little intrigued about your three bars idea so had a quick go at it.
                  It has some value as an idea but needs work.
                  I have attached a basic strategy type you can have a play and change it around through the wizard. Its for longs only to keep it simple when you get it going then make the shorts.

                  It is understandable that the support staff cant exactly run around writting code for everyone or there would be no end to it. If you get interested you can start out with a book c# for dummies and there is heaps of websites etc. Just google c# tuition or better yet Tony Alcoma from ninja programming school.



                  raef
                  Attached Files

                  Comment


                    #24
                    thanks raef , that was very nice of you . yea i dont know why one guy from support helps you and then another tells you they dont do that and erases your post . politics i guess !!!

                    anyway i founf an indicator that we might be able to use if i can get them to work , the NBARUPTREND, NBARDOWNTREND , they are signals for something like what i was looking for .

                    do you know how i can use them in the strategy ? thanks again

                    Comment


                      #25
                      Hi,

                      They all good blokes very helpfull when you are stuck I was surprised joydeep went the extra mile for you.


                      Its easy to use any indicator in a strategy. 2 ways to do that is tools / edit ninja script then edit the indicator. Right click and save the indicator as somthing else. I have played with that one as well however the problem resides in what is actually happenning. If you get 3 or more bars in one direction chances are the price is headed in that direction. The best results I was getting from your three bars idea was a buy/sell stop above the x period high in the direction of those three bars.

                      the other way is to use the strategy wizard and apply the indicator to the chart with a == true or whatever way that actually triggers the indicator.

                      You should perhaps consider playing with the indicator to see how you get best results. http://www.bigmiketrading.com/ has heaps of strategies and indicators you can download and play with for $50 elite members circle. No point re inventing the wheel.

                      But if you are interested in proving your ideas with script then prepare yourself for learning c# and ninja script it makes life easier.

                      raef
                      Last edited by raefon72; 04-09-2012, 10:28 PM.

                      Comment


                        #26
                        yes joydeep was awsome but i cant get her to answer now , i am a elite member at bigmikes .
                        im trying to learn the script , its just the way i learn the best is to just do it , learning from scratch dosent work for me , i guess its the way im wired , lol

                        ill get it going jae , and ill keep you posted

                        Comment


                          #27
                          i also use a few other indicators with the 3 bar , and i use renko 2 bar or 512 tick and 8/10 times i can scalp 2 ticks from the signal ,

                          i make a few hundred a day with it now , but if i could automate it , it would be golden .

                          i might just have to pay someone to make it for me , i just heard few problems with the code makers ninja recomends

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                          0 responses
                          648 views
                          0 likes
                          Last Post Geovanny Suaza  
                          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                          0 responses
                          369 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by Mindset, 02-09-2026, 11:44 AM
                          0 responses
                          108 views
                          0 likes
                          Last Post Mindset
                          by Mindset
                           
                          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                          0 responses
                          572 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by RFrosty, 01-28-2026, 06:49 PM
                          0 responses
                          573 views
                          1 like
                          Last Post RFrosty
                          by RFrosty
                           
                          Working...
                          X