Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Where to start if I want to create a strategy on a trading set-up?

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

    #16
    Thanks Ryan. I will check the lookback period and hope it will resolve the issue.

    Please help confirm my understanding on the following:

    1. I have "&&" to specify that all these conditions must be met before entering short, right?? Do not want a surprise that the system thought only one condition only for entry.


    // Condition set 2 Go Short
    if (d9ParticleOscillatorWVertLineR(7, 0).RawTrend[0]<0 && (DonMA(14).MAFalling[0] < DonMA(14).MAFalling[1]) && (EMA_Colors_Paint_v01(30, 60, 14).EMAdown[0] < EMA_Colors_Paint_v01(30, 60, 14).EMAup[1]))
    {
    EnterShort(DefaultQuantity,
    "");

    }


    2. I used || to tell the system that only one of these 2 conditions is required for an early exit. Am I right?

    // Exit with warning signals of trend reversal
    if (CrossBelow(d9ParticleOscillatorWVertLineR(7, 0).RawTrend, _Sharkfin(6).Rising, 1)|| (d9ParticleOscillatorWVertLine(7, 0).DotL[0]==0))


    ExitLong();

    My trillion thanks again.

    Comment


      #17
      Hi Belecona,

      Yes, this is correct.

      && == "And"
      || == "Or"


      See page below for full list of C# operators.

      Ryan M.NinjaTrader Customer Service

      Comment


        #18
        Thanks Ryan for your prompt confirmation. Glad that I have && and || in good order.

        More questions please:

        1. [0] for the Signal Bar and [1] for the previous bar before the Signal Bar, right?

        2. I'm telling the system to exit if the CrossAbove happens within the last bar, right?

        if (CrossAbove(d9ParticleOscillatorWVertLineR(
        7, 0).RawTrend, _Sharkfin(6).Falling, 1)
        ExitShort();

        3. I'm telling the system to exit when the DotU[0] on the Signal Bar is 0, right?

        if (d9ParticleOscillatorWVertLine(7, 0).DotU[0]==0)

        ExitShort();

        Your confirmation will help timing my entry/exit properly. Thank you Ryan!

        Comment


          #19
          Yes, Belecona. 1,2,3 all look like correct assumptions. Let us know if something doesn't work the way you expect.
          Ryan M.NinjaTrader Customer Service

          Comment


            #20
            Great news! Thanks Ryan.

            I'm still working very diligently on adding a breakeven (B/E) filter to my strategy. No luck yet unfortunately.

            If you are aware of a link that may have samples, please give me a shout! It's heart-breaking when all efforts spent so far have not triggered a B/E signal.

            Will continue exploring.

            Comment


              #21
              Glad to hear.

              You were close to a breakeven adjustment to your stop losses. The reference sample below helps with this.



              The code below is from your snippet in post #6, but one item was changed to move the stop to your entry point.

              Code:
              if (Close[0] == Position.AvgPrice + (8 * TickSize))
              { 
              SetStopLoss("", CalculationMode.Price, [B][COLOR=red]Position.AvgPrice,[/COLOR][/B] false);
              }
              Ryan M.NinjaTrader Customer Service

              Comment


                #22
                My "petite" heart is now mended. It may beat again very soon. Thanks to you Ryan!

                Can't wait to backtest the strategies with the fixed B/E filter. You've made my afternoon/evening. Thank you!

                Oh, I will check out the suggested sample and learn from it. Will be very occupied. Possibly knock .. knock .. again tomorrow .. smile ..

                Have a Nice afternoon/Great evening.

                Comment


                  #23
                  knock .. knock .. Good morning Ryan

                  Good news: I used the sample strategy (only replaced the Entry condition) to test out the B/E filter. It works this morning so far. Thanks to you!

                  Questions for newly raised issues:

                  1. Strategies with similar B/E condition got stopped. Notice the sample strategy does not have false in it. Please advise what may have happened. Should I remove "false" from my strategies so that it will work on sim?

                  SetStopLoss("", CalculationMode.Price, Position.AvgPrice, false);

                  2. Another strategy that I ran yesterday and only have one trade at one time, ie flat position before entering a new trade. I did not know what I did to the script last night. This morning, it has been entering trades constantly, ie NOT waiting for a trade to close. Please give me some hints so that I know where to look and resolve it promptly.

                  Thank you very much Ryan. Have a Great day.

                  Comment


                    #24
                    Hello Belecona,

                    1) False here refers to whether or not your order is simulated. You can see the overloads for SetStopLoss() below:


                    This setting will have no effect on backtesting or simulated trading. If set to true in live trading it will keep your stop order on your local machine until ready to submit.

                    2) Make sure your position check is working the way you expect. Also look at EntriesPerDirection setting if it's entering more than once per direction.
                    Ryan M.NinjaTrader Customer Service

                    Comment


                      #25
                      Hi Ryan

                      Thanks for your swift response (as always). I checked most of my scripts and they do not have either one of the following:

                      EntryHandling = EntryHandling.AllEntries;
                      EntryHandling = EntryHandling.UniqueEntries;

                      What's the system default if the script does not have one of the above? Seemed that my 2 computers have different default when one keeps adding new trades and one stays with only one until position close. Appreciate your enlightening me again. Thank you.

                      I now have a better understanding on "false". Prefer to have the pending orders with the server (not local computer) and will have "false" in my scripts unless you advise my understanding is wrong.

                      If the B/E condition is scripted correctly, it will be triggered when backtesting the strategy, right Ryan?

                      My trillion thanks again for making my strategy learning a smoother venture. I felt so helpless when I thought there's no one to turn to. Thank YOU!

                      Comment


                        #26
                        Hi Belecona,


                        If your trade is entering multiple times before waiting for a close, the setting to look for is EntriesPerDirection. EntryHandling works closely with this property though. The default for EntryHandling is "All Entries".

                        You can set both of these settings when you apply a strategy. When you apply to a chart or run from strategy analzyer these are available to you without having to declare in the code.


                        If the B/E condition is scripted correctly, it will be triggered when backtesting the strategy, right Ryan?



                        That's the idea, but note that in backtesting you only have OHLC values and can't look within the bar. A breakeven strategy requires an exact sequence of events and this sequence isn't always clear when just looking at OHLC values.


                        Prefer to have the pending orders with the server (not local computer) and will have "false" in my scripts unless you advise my understanding is wrong.
                        Orders will not always be resting at the server with this setting. If you are using OCO then one order will be at server and the other order simulated. Leaving at false still seems like what you want.

                        Last edited by NinjaTrader_RyanM1; 03-04-2010, 11:37 AM. Reason: missed one question initially
                        Ryan M.NinjaTrader Customer Service

                        Comment


                          #27
                          Hi Ryan

                          I'm getting close to run my revised strategy .. thanks to You!

                          1. Just added a StopLoss if a short position is open (highlighted in blue below). Please confirm I've it right. I used "else if" and not sure if I should change it (+ the one for long position) to "if"??

                          // Resets the stop loss to the original value when all positions are closed
                          if (Position.MarketPosition == MarketPosition.Flat)
                          {
                          SetStopLoss(CalculationMode.Ticks, stoplossticks);
                          }

                          // If a long position is open, allow for stop loss modification to breakeven
                          elseif (Position.MarketPosition == MarketPosition.Long)
                          {
                          // Once the price is greater than entry price +8 ticks, set stop loss to breakeven
                          if (Close[0] > Position.AvgPrice + 8 * TickSize)
                          {
                          SetStopLoss(CalculationMode.Price, Position.AvgPrice);
                          }
                          }

                          // If a short position is open, allow for stop loss modification to breakeven

                          elseif (Position.MarketPosition == MarketPosition.Short)
                          {
                          // Once the price is smaller than entry price -8 ticks, set stop loss to breakeven
                          if (Close[0] < Position.AvgPrice - 8 * TickSize)
                          {
                          SetStopLoss(CalculationMode.Price, Position.AvgPrice);
                          }
                          }

                          2. Yes, having the pending orders with the server is my preference. I live in a small city and will occasionally encounter power/computer failure.

                          I tried to add "false" to the script
                          SetStopLoss(CalculationMode.Price, Position.AvgPrice, false);

                          and got the following error message:

                          No overload for method 'SetStopLoss' takes '3' arguments.

                          Please help!! Thank you.

                          Comment


                            #28
                            Hi Belecona,

                            1) This looks good.

                            2) You don't have to explicitly declare false. It will be false unless you use true here. Take a look at the page below which provides all supported overloads for SetStopLoss()


                            If you want access to that field, use one of the two overloads below:
                            Code:
                             
                            SetStopLoss(double currency, bool simulated)
                            SetStopLoss(string fromEntrySignal, CalculationMode mode, double value, bool simulated)
                            Ryan M.NinjaTrader Customer Service

                            Comment


                              #29
                              My trillion .. trillion thanks again! My revised strategy is now waiting to kick-off in 5 minutes (1:45 pm EST). Wish me luck!

                              Comment


                                #30
                                Great to hear! Good Luck!
                                Ryan M.NinjaTrader Customer Service

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                649 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                370 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                109 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                574 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                576 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X