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

New User Woes

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

    #31
    And is it possible to use the macd histogram values per bar in the wizard, or by code?? If code that is fine i will just have to figure it out

    Or is there a way to use the cross above but by a certain value, like the fast line has crossed above the slow line by so much??

    You dont have to fully explain, just yes or no and perhaps a small point in the direction. I dont want to waste anyones time. Thanks

    Tim

    Comment


      #32
      Ok I give,

      under performance what does

      MFE, MAE, ETD mean

      i cant search this forumn for a 3 letter word, and i been looking for an hour in the help section

      i think

      ETD

      is estimated trade drawdown

      Comment


        #33
        In NT 6.5 there are definitions for all metrics in the Help Guide.
        RayNinjaTrader Customer Service

        Comment


          #34
          Ok getting farther and now ready to delve into the coding more.

          Here is my question:

          I made a strategy in the wizard which i like. The only thing I want now is to have ti stop trading if it loses 10 tick. and stop if it gains 20 ticks on the day.

          I did research and found the coding and have a couple questions:

          Prevents further trading if the current session's realized profit exceeds $1000 or if realized losses exceed $400.
          Also prevent trading if 10 trades have already been made in this session. */
          Is session defined as you start NT turn the strategy on. And fromt hat point till you stop the strategy manually it keps track??

          As in everyday I would like it to do this not keep track of the life time of the strategy.

          if i paste this under variables will it just work??

          And how do i make it ticks instead of currency. I apologize i am really trying to learn and it isnt easy for everyone.

          The storing of prior i dont want (below code) so do i just leave it out??

          // At the start of a new session
          if (Bars.FirstBarOfSession)
          {
          // Store the strategy's prior cumulated realized profit and number of trades
          priorTradesCount = Performance.RealtimeTrades.Count;
          priorTradesCumProfit = Performance.AllTrades.TradesPerformance.Currency.C umProfit;

          /* NOTE: Using .AllTrades will include both historical virtual trades as well as real-time trades.
          If you want to only count profits from real-time trades please use .RealtimeTrades. */
          }

          /* Prevents further trading if the current session's realized profit exceeds $1000 or if realized losses exceed $400.
          Also prevent trading if 10 trades have already been made in this session. */
          if (Performance.AllTrades.TradesPerformance.Currency. CumProfit - priorTradesCumProfit >= 1000
          || Performance.AllTrades.TradesPerformance.Currency.C umProfit - priorTradesCumProfit <= -400
          || Performance.AllTrades.Count - priorTradesCount > 10)
          {
          /* TIP FOR EXPERIENCED CODERS: This only prevents trade logic in the context of the OnBarUpdate() method. If you are utilizing
          other methods like OnOrderUpdate() or OnMarketData() you will need to insert this code segment there as well. */
          // Returns out of the OnBarUpdate() method. This prevents any further evaluation of trade logic in the OnBarUpdate() method.
          return;

          Comment


            #35
            Ok figuring it out, I am posting this incase others search for help also:

            if (Performance.RealtimeTrades.TradesPerformance.Points.CumProfit - priorTradesCumProfit >= 5
            || Performance.AllTrades.TradesPerformance.Currency.C umProfit -priorTradesCumProfit <= -5
            || Performance.AllTrades.Count - priorTradesCount > 10)

            If i am correct this should:

            use only realtime trades.

            Stop trading at 5 point gain or loss

            Stop trading at 10 trades

            If this is correct please let me know

            Comment


              #36
              Ok now looking inot it further I am curious about the strategy stopping, Is it using current trades or just closed ones. If it sees i made my 5 points of gain but it has a trade current what happens?? when it stops the strategy will it leave that trade out there?/

              is there code to flatten all positions before strategy end??

              Thanks Tim

              Comment


                #37
                So in order for me to stop the strategy and close all orders This is what i have figured out.

                if (Performance.RealtimeTrades.TradesPerformance.Poin ts.CumProfit >= 5
                || Performance.RealtimeTrades.TradesPerformance.Point s.CumProfit <=-5
                )

                StopStrategy();

                return;
                privatevoid StopStrategy()
                {
                // If our Long Limit order is still active we will need to cancel it.
                CancelOrder(myEntryOrder);

                // If we have a position we will need to close the position
                if (Position.MarketPosition == MarketPosition.Long)
                ExitLong();
                elseif (Position.MarketPosition == MarketPosition.Short)
                ExitShort();


                I beleive this code should do what i want if you see any problem please let me know

                Comment


                  #38
                  Name does not exist in current context??

                  Ok i tried my best and am now irritated

                  First it basically made my strategy no longer backtest: now i cant get past this error

                  The name 'priorTradesCumProfit' does not exist in the current context

                  here is the code

                  ///<summary>
                  /// Called on each bar update event (incoming tick)
                  ///</summary>
                  protectedoverridevoid OnBarUpdate()
                  {
                  // At the start of a new session
                  if (Bars.FirstBarOfSession)
                  {
                  // Store the strategy's prior cumulated realized profit and number of trades
                  priorTradesCount = Performance.AllTrades.Count;
                  priorTradesCumProfit = Performance.AllTrades.TradesPerformance.Points.Cum Profit;

                  }
                  if (Performance.AllTrades.TradesPerformance.Points.Cu mProfit - priorTradesCumProfit >= 5
                  || Performance.AllTrades.TradesPerformance.Points.Cum Profit - priorTradesCumProfit <= 5
                  || Performance.AllTrades.Count - priorTradesCount > 10)

                  {


                  StopStrategy();
                  return;


                  I am basically irritated becasue i have the sample file next to mine and its the same thing and is supposedly ok.

                  HELP

                  Comment


                    #39
                    Still cant get it to work right

                    So I took the sample that was prided by NT and bactested it. It backtests fine but definelty does not work.
                    f you change the loss of 400 to say 4 dollars it loses more than that on any given day.

                    Still trying and cant get that code to work in my strategy with same error from previous post
                    I

                    Comment


                      #40
                      I dont understand I cut and pasted now exactly what it says in the Sample and i still get theis not in current context issue.





                      Can anyone help??

                      Comment


                        #41
                        woohoo

                        Ok I think i got it

                        What was wrong is i never inputed the variables, I used the find in the sample to find it. <<<<< very handy

                        Comment


                          #42
                          OK Common for after unlock optimize wont work??

                          Ok got things goin now even larned some code

                          Here is my problem now:

                          Once i unlocked the code and got it to do what i want the buttons no longer do anything on the optimizer, as in trail stop etc. you can change them but they doont do anything for the results and no longer show up on dom etc

                          Is this waht happens after unlock??

                          Comment


                            #43
                            Hi timmyb,

                            Glad you resolved the coding issues you were having earlier in the day. Can you clarify which buttons you are referring to? Are you talking about when you use your strategy in the Strategy Analyzer? After you unlock your code you cannot revert back to using the wizard.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #44
                              Well I hade buttons under optimization and backtesting:

                              FAST

                              SLOW

                              TRAIL

                              GAIN

                              these were all adjustable or chooseable when u wanted to optimize. now they are there but when optimizing or backtestesing changing them does nothing.

                              I been looking at code from a new one to see if i coulda messed it up.



                              the only other question I have is I cant get bars since exit to work. basically i want it to make a trade then not trade again till so many bars since exit. I did this in wizard but then it did nothing.


                              And is there code for the cross over or under so that it has to cross over or under by a certain value??


                              Is it possible to use teh MACD histogram bars for a strategy, i cant seem to figure out how


                              just yes or no is ok for answers i dont want to waste anyone time a newbie. I jsut learned the manual coding i did today so , well i feel like i made progreess

                              thanks

                              tim

                              Comment


                                #45
                                Hi timmyb,

                                Those "buttons" are your user definable variables. Depending on how they are used throughout your code they can/cannot be optimized. Generally in the optimizer you set a range of values and increment you want to optimize each variable against. Not sure exactly what you mean by "does nothing". Optimizer will go through every iteration within your inputted range and backtest the strategy to determine which set of values produces highest results.

                                Please see this article for BarsSinceExit(): http://www.ninjatrader-support.com/H...SinceExit.html

                                Yes you can use CrossAbove() and CrossBelow() versus a value instead of another indicator. Please see this article: http://www.ninjatrader-support.com/H...rossAbove.html
                                Use the first syntaxing.

                                You can use the MACD histogram. You need to access the appropriate plot on the MACD. Please see this article: http://www.ninjatrader-support.com/H...deV6/MACD.html
                                In your case, the histogram is the "Diff" plot.
                                Josh P.NinjaTrader Customer Service

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Kaledus, Today, 01:29 PM
                                0 responses
                                3 views
                                0 likes
                                Last Post Kaledus
                                by Kaledus
                                 
                                Started by PaulMohn, Today, 12:36 PM
                                1 response
                                16 views
                                0 likes
                                Last Post NinjaTrader_Gaby  
                                Started by yertle, Yesterday, 08:38 AM
                                8 responses
                                37 views
                                0 likes
                                Last Post ryjoga
                                by ryjoga
                                 
                                Started by rdtdale, Today, 01:02 PM
                                1 response
                                6 views
                                0 likes
                                Last Post NinjaTrader_LuisH  
                                Started by alifarahani, Today, 09:40 AM
                                3 responses
                                19 views
                                0 likes
                                Last Post NinjaTrader_Jesse  
                                Working...
                                X