Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

simple strategy MACD and RSI

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

    #16
    Hello trelling,

    This is good the time of the bar is printing.

    It looks like you selected Time > Time series instead of Time > Date series, so the date is not included.

    As long as your test is only over a single day this should be an issue.

    Next you need to add the values compared in the entry condition to the string builder.
    Start by adding a string for the label for the first value compared in the condition set, the MarketPosition, then add a new string and select Strategy > Current market position.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #17
      ok print data and time and nothing else

      Comment


        #18
        Hello trelling,

        Next you need to add the values compared in the entry condition to the string builder.
        Start by adding a string for the label for the first value compared in the condition set, the MarketPosition, then add a new string and select Strategy > Current market position.​
        Chelsea B.NinjaTrader Customer Service

        Comment


          #19
          This?
          // Set 3
          if ((MarketPosition.Flat == Position.MarketPosition)
          && (CrossAbove(RSI1.Avg, RSI1.Avg, 1)))
          {
          EnterLong(Convert.ToInt32(NumberOfContracts), "");
          }
          {
          Print(Convert.ToString(Times[0][0]));
          }​

          Comment


            #20
            Hello trelling,

            Below is a link to a video of debugging with the strategy builder.


            Please watch this video.

            Follow the video to print the time of the bar in a condition set with no conditions.

            Then add a string for a label 'MarketPosition', and add a string for Strategy > Current market position.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #21
              thanks, the problem is that I don't see anything so I can't react to the messages as well as not knowing how to program. I redid an even more simpler strategy: buy when the blue line (7) exceeds the yellow (3) and sell when the blue is below the yellow. tell me what's wrong with it
              {
              public class MyTest1 : Strategy
              {
              private RSI RSI1;

              protected override void OnStateChange()
              {
              if (State == State.SetDefaults)
              {
              Description = @"Enter the description for your new custom Strategy here.";
              Name = "MyTest1";
              Calculate = Calculate.OnBarClose;
              EntriesPerDirection = 1;
              EntryHandling = EntryHandling.AllEntries;
              IsExitOnSessionCloseStrategy = true;
              ExitOnSessionCloseSeconds = 30;
              IsFillLimitOnTouch = false;
              MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
              OrderFillResolution = OrderFillResolution.Standard;
              Slippage = 0;
              StartBehavior = StartBehavior.WaitUntilFlat;
              TimeInForce = TimeInForce.Day;
              TraceOrders = true;
              RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
              StopTargetHandling = StopTargetHandling.PerEntryExecution;
              BarsRequiredToTrade = 2;
              // Disable this property for performance gains in Strategy Analyzer optimizations
              // See the Help Guide for additional information
              IsInstantiatedOnEachOptimizationIteration = true;
              StartTime = DateTime.Parse("07:00", System.Globalization.CultureInfo.InvariantCulture) ;
              StopTime = DateTime.Parse("22:30", System.Globalization.CultureInfo.InvariantCulture) ;
              TargetInTicks = 40;
              StopInTicks = 40;
              NumberOfContracts = 1;
              }
              else if (State == State.Configure)
              {
              }
              else if (State == State.DataLoaded)
              {
              RSI1 = RSI(Close, 7, 3);
              SetProfitTarget("", CalculationMode.Ticks, TargetInTicks);
              SetStopLoss("", CalculationMode.Ticks, StopInTicks, false);
              }
              }

              protected override void OnBarUpdate()
              {
              if (BarsInProgress != 0)
              return;

              if (CurrentBars[0] < 1)
              return;

              // Set 1
              if ((Position.MarketPosition == MarketPosition.Flat)
              && (CrossAbove(RSI1.Default, RSI1.Default, 1)))
              {
              EnterLong(Convert.ToInt32(NumberOfContracts), "");
              }

              // Set 2
              if ((Position.MarketPosition == MarketPosition.Flat)
              && (CrossBelow(RSI1.Default, RSI1.Default, 1)))
              {
              EnterShort(Convert.ToInt32(NumberOfContracts), "");
              }

              }
              Attached Files

              Comment


                #22
                Hello trelling,

                Debugging prints allow you to see if the condition will evaluate as true or false and why.

                If the order is not being submitted, the condition did not evaluate as true.

                This means you need to print the values compared in the condition to see why this is evaluating as false.

                Your condition is looking for the position to be flat and for the RSI Default plot to cross itself.

                So print the time of the bar, print the position, and print the RSI Default on the previous bar and the current bar. Look for where the position prints as flat, the default plot is less than itself on the previous bar and greater than itself on the current bar.


                You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services.

                You can search our extensive library of NinjaScript consultants through the link below. Simply enter a consultant name or search by using our filter categories. Once you have identified your consultants of choice, please visit each consultant's site for more information or contact them directly to learn more!
                Programming Services - https://ninjatraderecosystem.com/sea...mming-services
                Educators - https://ninjatraderecosystem.com/sea...ures=education

                You can locate the contact information for the consultants on their direct websites for any additional questions you may have. Since these consultants are third party services for NinjaTrader all pricing and support information will need to be obtained through the consultant.

                This NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The companies and services listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.​
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NullPointStrategies, Yesterday, 05:17 AM
                0 responses
                72 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                143 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                76 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                47 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                51 views
                0 likes
                Last Post TheRealMorford  
                Working...
                X