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

Conditions met but order not being placed

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

    Conditions met but order not being placed

    All the conditions for this to take a position appear to have been met but strategy does not place the order.

    close below prior low; swing low (10), average price, Minimum low (14) and MACD.diff is less than zero. All the same conditions were met on the last entry yet it will not take the next entry. Any thoughts on why this might be?

    Here is entry code:
    Code:
    if ((Position.Quantity == 2700)
    				 && (Close[0] < Low[1])
    				 && (Close[0] < Swing1.SwingLow[0])
    				 && (Close[0] < Position.AveragePrice)
    				 && (Close[0] < MIN1[1])
    				 && (MACD1.Diff[0] < 0))
    Here is the definitions for the indicators:
    Code:
    else if (State == State.Configure)
    			{
    				//AddDataSeries("EURUSD", BarsPeriod.BarsPeriodType, 4 * BarsPeriod.Value, Data.MarketDataType.Last);
    				AddDataSeries("EURUSD", Data.BarsPeriodType.Minute, 240, Data.MarketDataType.Last);
    				AddDataSeries("EURUSD", Data.BarsPeriodType.Day, 1, Data.MarketDataType.Last);
    				AddPlot(Brushes.Lime, "Average price"); //PLOTTING AVERAGE ENTRY PRICE
    				//SetStopLoss(CalculationMode.Percent, 0.03);
    			}
    			else if (State == State.DataLoaded)
    			{				
    				RSI1				= RSI(Closes[1], Convert.ToInt32(RSI_Period), 2);
    				RSI2				= RSI(Close, Convert.ToInt32(RSI_Period), 2);
    				Swing1				= Swing(Close, 10);
    				MIN1				= MIN(Low, 14); //minimum low last 14 bars
    				EMA1				= EMA(Close, 55);
    				ADX1				= ADX(Closes[0], 14);
    				SMA1				= SMA(Close,200);
    				MACD1				= MACD(Closes[0], 34, 55, 13);
    				EMA2				= EMA(ADX1, 14);
    			}
    I also have these defined as well:
    Code:
    		private int Initial_Position_Size;
    		private RSI RSI1;
    		private RSI RSI2;
    		private Swing Swing1;
    		private MIN MIN1;
    		private EMA EMA1;
    		private ADX ADX1;
    		private SMA SMA1;
    		private MACD MACD1;
    		private EMA EMA2;
    Attached Files
    Last edited by ShruggedAtlas; 05-31-2018, 08:58 AM.

    #2
    Hello ShruggedAtlas,

    Thanks for your post.

    Have you confirmed that each condition for your entry is becoming true by adding debugging prints to your strategy? Adding prints will help to confirm if a) the conditions are becoming true, and b) if the order method is getting reached.

    You may also wish to use TraceOrders to see if the order is getting submitted, accepted, working, and filled or if there was an issue somewhere with the order submission.

    Finally, it is important to understand the Internal order Handling Rules that reduce unwanted positions in case the order submission is getting ignored.

    Debugging - https://ninjatrader.com/support/help...script_cod.htm

    TraceOrders - https://ninjatrader.com/support/help...aceorders2.htm

    Internal Order Handling Rules - https://ninjatrader.com/support/help...antedPositions

    Please let us know if we can be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      I have the indicators the code references/uses on the chart so from that I don't understand why it's not taking the order but i'll experiment with some print statements to the log and see if I can figure it out.

      Comment


        #4
        The problem seems to be with the MACD.Diff part of the code. When I comment it out it properly takes the entry.

        (MACD1.Diff[0] < 0)) //This should reference the 4hr bars

        because of this code:
        MACD1 = MACD(Closes[0], 34, 55, 13); // which references:

        AddDataSeries("EURUSD", Data.BarsPeriodType.Minute, 240, Data.MarketDataType.Last); //4 hr bar
        AddDataSeries("EURUSD", Data.BarsPeriodType.Day, 1, Data.MarketDataType.Last);

        Do I have this understood?

        Closes[0] references the first added data series (the 240 min)

        Comment


          #5
          Hello ShruggedAtlas,

          Closes[0] represents the primary data series that the NinjaScript is applied to. Closes[1] will represent the first added data series.

          The Multi Time Frame and Instruments section of the help guide explains how Price Data should be referenced in a Multi Bars script and provides a complete walk through for creating and using a Multi Series NinjaScript. I'll provide a link below.

          Multi Time Frame and Instruments - https://ninjatrader.com/support/help...nstruments.htm

          I look forward to being of any further help.
          JimNinjaTrader Customer Service

          Comment


            #6
            Ok that may very well be the source of my problem then. I will confirm and report back

            Comment


              #7
              That was the source of my problem! Thanks!!!!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by CortexZenUSA, Today, 12:53 AM
              0 responses
              1 view
              0 likes
              Last Post CortexZenUSA  
              Started by CortexZenUSA, Today, 12:46 AM
              0 responses
              0 views
              0 likes
              Last Post CortexZenUSA  
              Started by usazencortex, Today, 12:43 AM
              0 responses
              2 views
              0 likes
              Last Post usazencortex  
              Started by sidlercom80, 10-28-2023, 08:49 AM
              168 responses
              2,262 views
              0 likes
              Last Post sidlercom80  
              Started by Barry Milan, Yesterday, 10:35 PM
              3 responses
              10 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Working...
              X