Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

implementing my first strategy

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

    implementing my first strategy

    Hello,

    I'm discovering the great NT strategy wizard : it seems so simple that I hardly understand why I need help, but I still do

    I'd like to fix a high and a low price reference beetween 9.30 and 10.00 to trade only if a certain level is reached above the high or below the low price.

    My concern is, how can I automate the reference prices through the wizard ?

    I can see there are time and price data but can't figure out how to connect them, and how to draw the time interval.

    I guess it takes a specific way of thinking that I still haven't imagined.

    #2
    Hello platax,

    Thank you for your post and welcome to the NinjaTrader Support Forum!

    This would require unlocking the code to develop your method to find the high and low between these two times. So this would unfortunately not be possible in the Strategy Wizard.

    We have Premium Paid Educational events designed to provide you with an in depth look at programming indicators and automated strategies through the use of NinjaScript:


    If you would like to take on learning NinjaScript on your own, we have a fully documented help guide which will help you get started with Ninja Script. You will find language references to all of the methods and functions you will be using. You will also see a tutorial section which will help you create your first indicator and get you started with some of these concepts.
    A link to our Help Guide can be found below: http://www.ninjatrader.com/support/h...stribution.htm

    I am also linking you to the Educational Resources section of the Help Guide to help you get started with NinjaScript: http://www.ninjatrader.com/support/h..._resources.htm

    You will find Reference Samples online as well as some Tips and Tricks for both indicators and strategies:
    Click here to see our NinjaScript Reference Samples: http://www.ninjatrader.com/support/f...splay.php?f=30
    Click here to see our NinjaScript Tips: http://www.ninjatrader.com/support/f...ead.php?t=3229

    These samples can be downloaded, installed and modified from NinjaTrader and hopefully serve as a good base for your custom works.

    There is a also a growing library of user submitted custom indicators (100+) that can be downloaded from our support form. Please look in the NinjaScript File Sharing section of our support forum as you may find what you are looking for there: http://www.ninjatrader.com/support/f...splay.php?f=37

    If you have limited time or programming capabilities, you can discuss your requirements with any of our certified NinjaScript consultants.
    Click here for a list of certified NinjaScript Consultants: http://www.ninjatrader.com/Ecosystem/NonBroker.php#81

    Please let me know if you have any questions.

    Comment


      #3
      Thanks Patrick. I might try to code the following then : what follows is a kind of "let alone syntax" draft.



      Code:
      // user variables
      
      FirstMinuteReference // first minute of the reference period
      LastMinuteReference // last minute of the reference period
      
      FirstMinuteToEnter // first minute to enter trade.
      LastMinuteToEnter // last minute to enter trade.
      
      LastMinuteToExit //last minute to exit trade.
      
      MinBreakoutRatio // minimum breakout ratio
      
      StopLosspRatio // loss ratio tolerated before exit
      StopGainRation // gain ratio expected to exit
      
      
      
      // calculated variables
      
      Time // time in minutes from opening hour
      
      MinPriceRef // minimum price recorded during reference interval
      MaxPriceRef // maximum price recorded during reference interval
      
      LowerExitPrice // lower exit price
      UpperExitPrice // upper exit price
      
      
      if Time >= FirstMinuteReference and  <= LastMinuteReference // we are inside reference interval : let's set the reference prices
      	set MinPriceRef
      	set MaxPriceRef
      
      if Time >= FirstMinuteToEnter and  <= LastMinuteToEnter // we are inside the trade interval : let's see if there is a trade
      	if price >= MaxPriceRef + (MaxPriceRef x MinBreakoutRatio) // bullish trend
      		trade long
      		set LowerExitPrice = Price - (Price x StopLosspRatio)
      		set UpperExitPrice = Price + (Price x StopGainRatio)
      
      	if price <= MinPriceRef - (MinPriceRef  x MinBreakoutRatio) // bearish trend
      		trade short
      		set LowerExitPrice = Price - (Price x StopGainRatio)
      		set UpperExitPrice = Price + (Price x StopLosspRatio)
      		
      	if price <= LowerExitPrice or price >= UpperExitPrice or BarNumber >= MaxBarToExit // let's get out of this trade
      		close position
      I'm surprised not to find an equivalent to download : most breakout strategies I found seemed to hard codes the variables instead of letting them user defined. I'd like one that could take advantage of NT optimization function

      I can't admit that I'm the first to try this : has anyone posted a similar breakout strategy with optimization variables somewhere ?

      Comment


        #4
        Hello platax,

        Thank you for your response.

        You can check our file sharing section to see if one of our users has such a strategy available for download: http://www.ninjatrader.com/support/f...splay.php?f=37

        Comment


          #5
          How can I make any test upon time ?

          Unfortunatly I have not found what I'm looking for. BTW this will introduce me to hard coding in C#.

          I would still appreciate a good help with the wizard but this is my concern : in the condition builder, "Time value" is set in a time format (00:00 tot 23:59) and my declared variables can only be bool, double, int or string.

          How can I make any test upon time ?

          Comment


            #6
            Hello platax,

            Thank you for your response.

            Ints are used to compare the time series, so you can use ints like 80000 for 8 AM and 161500 for 4:15 PM.

            Comment


              #7
              Originally posted by NinjaTrader_PatrickH View Post
              Ints are used to compare the time series, so you can use ints like 80000 for 8 AM and 161500 for 4:15 PM.
              The wizard is more touchy : I get the message

              Originally posted by NinjaTrader_Wizard
              Return type of left expression 'DateTime' and right expression 'Int32' do not match.
              You need to select a different item

              Comment


                #8
                Hello platax,

                Thank you for your update.

                What are you attempting to do by comparing static values? I believe you wish to compare the current time against a user variable, so you would select Time Series not Time Value.

                Comment


                  #9
                  Hello Patrick,

                  Thanks for this hint,

                  You're right but... time series unit is "bars ago" which is not what I'm looking for. I would like to compare present time (9:35) or minutes elapsed since market opening (5) to user value (10)

                  If "bars ago" is the only dynamic time serie available, this makes me hard code a counter for each elapsed bar that can be substracted to present bar to now where I am in time frame. Not so neat indeed...

                  Comment


                    #10
                    Hello platax,

                    Thank you for your response.

                    You would need to hard code this into the strategy, but there would be no need for the counter as you can store the Open time and check the current time is greater, then subtract the difference.

                    Please let me know if you have any questions.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by manueldecastro, Yesterday, 10:26 AM
                    5 responses
                    24 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Started by memonic, 05-01-2024, 01:23 PM
                    5 responses
                    30 views
                    0 likes
                    Last Post memonic
                    by memonic
                     
                    Started by dcriador, Yesterday, 10:45 AM
                    2 responses
                    18 views
                    0 likes
                    Last Post dcriador  
                    Started by SnailHorn, Yesterday, 10:49 PM
                    1 response
                    10 views
                    0 likes
                    Last Post SnailHorn  
                    Started by TraderIqbal, 10-20-2023, 10:12 AM
                    2 responses
                    121 views
                    0 likes
                    Last Post Funnywo
                    by Funnywo
                     
                    Working...
                    X