Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help with simple strategy

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

    #16
    I am very happy to announce that progress is being made ( I think heh)

    SMA is at 92.13

    As the price moved up it placed filled order and bought me in at 92.09

    Here is the output code from that

    Code:
    Calculated value: 92.13
    ShortCurrentBid: 92.07 Offsetneg+Tick: -0.05 SMA: 92.132
    Calculated value: 92.02
    LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
    Calculated value: 92.14
    ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
    Calculated value: 92.03
    2013-06-03 6:16:58 AM Entered internal PlaceOrder() method at 2013-06-03 6:16:58 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
    LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
    Calculated value: 92.14
    ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
    Calculated value: 92.03
    2013-06-03 6:16:58 AM Entered internal PlaceOrder() method at 2013-06-03 6:16:58 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
    2013-06-03 6:16:58 AM Ignored PlaceOrder() method at 2013-06-03 6:16:58 AM: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
    LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
    Calculated value: 92.14
    ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
    Calculated value: 92.03
    2013-06-03 6:16:58 AM Entered internal PlaceOrder() method at 2013-06-03 6:16:58 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
    2013-06-03 6:16:58 AM Ignored PlaceOrder() method at 2013-06-03 6:16:58 AM: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
    LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
    Calculated value: 92.14
    ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
    Calculated value: 92.03
    2013-06-03 6:16:58 AM Entered internal PlaceOrder() method at 2013-06-03 6:16:58 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
    2013-06-03 6:16:58 AM Ignored PlaceOrder() method at 2013-06-03 6:16:58 AM: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
    LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
    Calculated value: 92.14
    ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
    Calculated value: 92.03
    2013-06-03 6:16:58 AM Entered internal PlaceOrder() method at 2013-06-03 6:16:58 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
    2013-06-03 6:16:58 AM Ignored PlaceOrder() method at 2013-06-03 6:16:58 AM: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
    LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
    Calculated value: 92.14
    ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
    Calculated value: 92.03
    2013-06-03 6:16:58 AM Entered internal PlaceOrder() method at 2013-06-03 6:16:58 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
    2013-06-03 6:16:58 AM Ignored PlaceOrder() method at 2013-06-03 6:16:58 AM: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
    LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
    Calculated value: 92.14
    ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
    Calculated value: 92.03
    2013-06-03 6:16:58 AM Entered internal PlaceOrder() method at 2013-06-03 6:16:58 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
    2013-06-03 6:16:58 AM Ignored PlaceOrder() method at 2013-06-03 6:16:58 AM: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
    LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
    Calculated value: 92.14
    ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
    Calculated value: 92.03
    2013-06-03 6:16:58 AM Entered internal PlaceOrder() method at 2013-06-03 6:16:58 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
    2013-06-03 6:16:58 AM Ignored PlaceOrder() method at 2013-06-03 6:16:58 AM: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
    LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
    Calculated value: 92.14
    ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
    Calculated value: 92.03
    2013-06-03 6:16:58 AM Entered internal PlaceOrder() method at 2013-06-03 6:16:58 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
    2013-06-03 6:16:58 AM Ignored PlaceOrder() method at 2013-06-03 6:16:58 AM: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
    LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
    Calculated value: 92.14
    ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
    Calculated value: 92.03
    2013-06-03 6:16:58 AM Entered internal PlaceOrder() method at 2013-06-03 6:16:58 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
    2013-06-03 6:16:58 AM Ignored PlaceOrder() method at 2013-06-03 6:16:58 AM: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
    LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
    Calculated value: 92.14
    ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
    Calculated value: 92.03
    2013-06-03 6:17:00 AM Entered internal PlaceOrder() method at 2013-06-03 6:17:00 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
    2013-06-03 6:17:00 AM Ignored PlaceOrder() method at 2013-06-03 6:17:00 AM: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
    LongCurrentAsk: 92.1 Offset+Tick: 0.05 SMA: 92.1324
    Calculated value: 92.15
    ShortCurrentBid: 92.09 Offsetneg+Tick: -0.05 SMA: 92.1324
    Calculated value: 92.04
    As the price continued on upwards it did not reverse and go short. Other then the fact that it went long when it was supposed to go short I am atleast happy that it is placing an order! I am not doing any other live or sim trading today as I am just focusing on getting this working so I am just using the market replay data while I test the code.

    I am sorry for the basic nature of my questions. But when you say put a print statement inside the conditions I assume you mean these:

    if (CrossAbove(GetCurrentAsk() + Offset * TickSize, SMA(SMAlookback), 1))
    EnterLong(DefaultQuantity, "");
    else if (CrossBelow(GetCurrentBid() + Offsetneg * TickSize, SMA(SMAlookback), 1))
    EnterShort(DefaultQuantity, "");


    unfortunately every time I try putting print somewhere in their I simply get an error.

    Comment


      #17
      Hello thorpc,

      Inside the if statement brackets:

      Code:
      if (CrossAbove(GetCurrentAsk() + Offset * TickSize, SMA(SMAlookback), 1))
      {
      	Print("LongCurrentAsk: "+GetCurrentAsk()+" Offset+Tick: "+(Offset * TickSize)+" SMA: "+SMA(SMAlookback)[0]);
      	Print("Calculated value: "+(GetCurrentAsk() + Offset * TickSize));
              EnterLong(DefaultQuantity, "");
      }
      else if (CrossBelow(GetCurrentBid() + Offsetneg * TickSize, SMA(SMAlookback), 1))
      {
      	Print("ShortCurrentBid: "+GetCurrentBid()+" Offsetneg+Tick: "+(Offsetneg * TickSize)+" SMA: "+SMA(SMAlookback)[0]);
      	Print("Calculated value: "+(GetCurrentBid() + Offsetneg * TickSize));
              EnterShort(DefaultQuantity, "");
      }
      JCNinjaTrader Customer Service

      Comment


        #18
        OK I put it in, I changed my long / short so that it is entering at the right place. My entry points are where I want them to be, but it is not reversing when the price goes through the sma.

        Code:
        ShortCurrentBid: 92.94 Offsetneg+Tick: -0.05 SMA: 92.8934
        Calculated value: 92.89
        ShortCurrentBid: 92.94 Offsetneg+Tick: -0.05 SMA: 92.8934
        Calculated value: 92.89
        2013-06-04 3:37:34 AM Entered internal PlaceOrder() method at 2013-06-04 3:37:34 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
        LongCurrentAsk: 92.96 Offset+Tick: 0.05 SMA: 92.8934
        Calculated value: 93.01
        ShortCurrentBid: 92.94 Offsetneg+Tick: -0.05 SMA: 92.8934
        Calculated value: 92.89
        2013-06-04 3:37:34 AM Entered internal PlaceOrder() method at 2013-06-04 3:37:34 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
        2013-06-04 3:37:34 AM Ignored PlaceOrder() method at 2013-06-04 3:37:34 AM: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
        LongCurrentAsk: 92.96 Offset+Tick: 0.05 SMA: 92.8934
        Calculated value: 93.01
        ShortCurrentBid: 92.94 Offsetneg+Tick: -0.05 SMA: 92.8934
        Calculated value: 92.89
        ShortCurrentBid: 92.94 Offsetneg+Tick: -0.05 SMA: 92.8934
        Calculated value: 92.89
        2013-06-04 3:37:34 AM Entered internal PlaceOrder() method at 2013-06-04 3:37:34 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
        2013-06-04 3:37:34 AM Ignored PlaceOrder() method at 2013-06-04 3:37:34 AM: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
        LongCurrentAsk: 92.95 Offset+Tick: 0.05 SMA: 92.8936
        Calculated value: 93
        ShortCurrentBid: 92.94 Offsetneg+Tick: -0.05 SMA: 92.8936
        Calculated value: 92.89
        ShortCurrentBid: 92.94 Offsetneg+Tick: -0.05 SMA: 92.8936
        Calculated value: 92.89
        2013-06-04 3:37:34 AM Entered internal PlaceOrder() method at 2013-06-04 3:37:34 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
        2013-06-04 3:37:34 AM Ignored PlaceOrder() method at 2013-06-04 3:37:34 AM: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
        System.ArgumentNullException: Value cannot be null.
        Parameter name: brush
           at System.Drawing.Graphics.DrawString(String s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format)
           at System.Drawing.Graphics.DrawString(String s, Font font, Brush brush, Single x, Single y)
           at NinjaTrader.Indicator.jtRangeMarker7.Plot(Graphics graphics, Rectangle bounds, Double min, Double max)
        LongCurrentAsk: 92.96 Offset+Tick: 0.05 SMA: 92.8938
        Calculated value: 93.01
        ShortCurrentBid: 92.95 Offsetneg+Tick: -0.05 SMA: 92.8938
        Calculated value: 92.9
        LongCurrentAsk: 92.95 Offset+Tick: 0.05 SMA: 92.8934
        Calculated value: 93
        ShortCurrentBid: 92.94 Offsetneg+Tick: -0.05 SMA: 92.8934
        Calculated value: 92.89
        ShortCurrentBid: 92.94 Offsetneg+Tick: -0.05 SMA: 92.8934
        Calculated value: 92.89
        2013-06-04 3:37:37 AM Entered internal PlaceOrder() method at 2013-06-04 3:37:37 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
        2013-06-04 3:37:37 AM Ignored PlaceOrder() method at 2013-06-04 3:37:37 AM: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
        LongCurrentAsk: 92.95 Offset+Tick: 0.05 SMA: 92.8934
        Calculated value: 93
        ShortCurrentBid: 92.94 Offsetneg+Tick: -0.05 SMA: 92.8934
        Calculated value: 92.89
        ShortCurrentBid: 92.94 Offsetneg+Tick: -0.05 SMA: 92.8934
        Calculated value: 92.89
        2013-06-04 3:37:37 AM Entered internal PlaceOrder() method at 2013-06-04 3:37:37 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
        2013-06-04 3:37:37 AM Ignored PlaceOrder() method at 2013-06-04 3:37:37 AM: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
        LongCurrentAsk: 92.94 Offset+Tick: 0.05 SMA: 92.8932
        Calculated value: 92.99
        ShortCurrentBid: 92.93 Offsetneg+Tick: -0.05 SMA: 92.8932
        Calculated value: 92.88
        ShortCurrentBid: 92.93 Offsetneg+Tick: -0.05 SMA: 92.8932
        Calculated value: 92.88
        2013-06-04 3:37:38 AM Entered internal PlaceOrder() method at 2013-06-04 3:37:38 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
        2013-06-04 3:37:38 AM Ignored PlaceOrder() method at 2013-06-04 3:37:38 AM: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
        System.ArgumentNullException: Value cannot be null.
        Double min, Double max)
        LongCurrentAsk: 92.94 Offset+Tick: 0.05 SMA: 92.8932
        Calculated value: 92.99
        ShortCurrentBid: 92.93 Offsetneg+Tick: -0.05 SMA: 92.8932
        Calculated value: 92.88
        ShortCurrentBid: 92.93 Offsetneg+Tick: -0.05 SMA: 92.8932
        Calculated value: 92.88
        2013-06-04 3:37:39 AM Entered internal PlaceOrder() method at 2013-06-04 3:37:39 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
        2013-06-04 3:37:39 AM Ignored PlaceOrder() method at 2013-06-04 3:37:39 AM: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
        LongCurrentAsk: 92.94 Offset+Tick: 0.05 SMA: 92.8932
        Calculated value: 92.99
        ShortCurrentBid: 92.93 Offsetneg+Tick: -0.05 SMA: 92.8932
        Calculated value: 92.88
        ShortCurrentBid: 92.93 Offsetneg+Tick: -0.05 SMA: 92.8932
        Calculated value: 92.88
        2013-06-04 3:37:39 AM Entered internal PlaceOrder() method at 2013-06-04 3:37:39 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
        2013-06-04 3:37:39 AM Ignored PlaceOrder() method at 2013-06-04 3:37:39 AM: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
        LongCurrentAsk: 92.94 Offset+Tick: 0.05 SMA: 92.8932
        Calculated value: 92.99
        ShortCurrentBid: 92.93 Offsetneg+Tick: -0.05 SMA: 92.8932
        Calculated value: 92.88
        ShortCurrentBid: 92.93 Offsetneg+Tick: -0.05 SMA: 92.8932
        Calculated value: 92.88
        2013-06-04 3:37:39 AM Entered internal PlaceOrder() method at 2013-06-04 3:37:39 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
        2013-06-04 3:37:39 AM Ignored PlaceOrder() method at 2013-06-04 3:37:39 AM: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
        LongCurrentAsk: 92.94 Offset+Tick: 0.05 SMA: 92.8932
        Calculated value: 92.99
        ShortCurrentBid: 92.93 Offsetneg+Tick: -0.05 SMA: 92.8932
        Calculated value: 92.88
        ShortCurrentBid: 92.93 Offsetneg+Tick: -0.05 SMA: 92.8932
        Calculated value: 92.88
        2013-06-04 3:37:39 AM Entered internal PlaceOrder() method at 2013-06-04 3:37:39 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
        2013-06-04 3:37:39 AM Ignored PlaceOrder() method at 2013-06-04 3:37:39 AM: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
        LongCurrentAsk: 92.94 Offset+Tick: 0.05 SMA: 92.8932
        Calculated value: 92.99
        ShortCurrentBid: 92.93 Offsetneg+Tick: -0.05 SMA: 92.8932
        Calculated value: 92.88
        ShortCurrentBid: 92.93 Offsetneg+Tick: -0.05 SMA: 92.8932
        Calculated value: 92.88
        2013-06-04 3:37:39 AM Entered internal PlaceOrder() method at 2013-06-04 3:37:39 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
        2013-06-04 3:37:39 AM Ignored PlaceOrder() method at 2013-06-04 3:37:39 AM: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
        LongCurrentAsk: 92.94 Offset+Tick: 0.05 SMA: 92.8932
        Calculated value: 92.99
        ShortCurrentBid: 92.93 Offsetneg+Tick: -0.05 SMA: 92.8932
        Calculated value: 92.88
        2013-06-04 3:37:39 AM Entered internal PlaceOrder() method at 2013-06-04 3:37:39 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
        2013-06-04 3:37:39 AM Ignored PlaceOrder() method at 2013-06-04 3:37:39 AM: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
        LongCurrentAsk: 92.93 Offset+Tick: 0.05 SMA: 92.8932
        Calculated value: 92.98
        As you can see in the code their it when long at 92.96 which is great! unfortunately as the price went down to 92.86 it did not reverse and go short?

        Comment


          #19
          Hello thorpc,

          If you get two signals to go long and short at once since it looks like they are being fired off at the same time you will get the ignored message as you can only enter in one direction before it gets filled.

          You Output does not seem to match with just the Print() statements inside of your conditions. Are you keeping the Print() outside of the conditions as well?
          JCNinjaTrader Customer Service

          Comment


            #20
            Here is my current code for the strategy.

            Code:
            #region Using declarations
            using System;
            using System.ComponentModel;
            using System.Diagnostics;
            using System.Drawing;
            using System.Drawing.Drawing2D;
            using System.Xml.Serialization;
            using NinjaTrader.Cbi;
            using NinjaTrader.Data;
            using NinjaTrader.Indicator;
            using NinjaTrader.Gui.Chart;
            using NinjaTrader.Strategy;
            #endregion
            
            // This namespace holds all strategies and is required. Do not change it.
            namespace NinjaTrader.Strategy
            {
                /// <summary>
                /// bam
                /// </summary>
                [Description("bam")]
                public class MA3 : Strategy
                {
                    #region Variables
                    // Wizard generated variables
                    private int sMAlookback = 50; // Default setting for SMAlookback
                    private int offset = 5; // Default setting for Offset
                    private int offsetneg = -5; // Default setting for Offsetneg
                    // User defined variables (add any user defined variables below)
                    #endregion
            
                    /// <summary>
                    /// This method is used to configure the strategy and is called once before any strategy method is called.
                    /// </summary>
                    protected override void Initialize()
                    {
                        Add(SMA(SMAlookback));
                        Add(SMA(SMAlookback));
            
                        CalculateOnBarClose = false;
            			
            			TraceOrders = true;
                    }
            
                    /// <summary>
                    /// Called on each bar update event (incoming tick)
                    /// </summary>
                    protected override void OnBarUpdate()
                    {
            			Print("LongCurrentAsk: "+GetCurrentAsk()+" Offset+Tick: "+(Offset * TickSize)+" SMA: "+SMA(SMAlookback)[0]);
            			Print("Calculated value: "+(GetCurrentAsk() + Offset * TickSize));
            			
            			Print("ShortCurrentBid: "+GetCurrentBid()+" Offsetneg+Tick: "+(Offsetneg * TickSize)+" SMA: "+SMA(SMAlookback)[0]);
            			Print("Calculated value: "+(GetCurrentBid() + Offsetneg * TickSize));
            			
                        if (CrossAbove(GetCurrentAsk() + (Offset * TickSize), SMA(SMAlookback), 1))
            			{
                            Print("LongCurrentAsk: "+GetCurrentAsk()+" Offset+Tick: "+(Offset * TickSize)+" SMA: "+SMA(SMAlookback)[0]);
            				Print("Calculated value: "+(GetCurrentAsk() + (Offset * TickSize)));
            				EnterShort(DefaultQuantity, "");
            			}
                        else if (CrossBelow(GetCurrentBid() + (Offsetneg * TickSize), SMA(SMAlookback), 1))
            			{
                        	Print("ShortCurrentBid: "+GetCurrentBid()+" Offsetneg+Tick: "+(Offsetneg * TickSize)+" SMA: "+SMA(SMAlookback)[0]);
            				Print("Calculated value: "+(GetCurrentBid() + (Offsetneg * TickSize)));
            				EnterLong(DefaultQuantity, "");
            			}
                    }
            		
            		
            
                    #region Properties
                    [Description("")]
                    [GridCategory("Parameters")]
                    public int SMAlookback
                    {
                        get { return sMAlookback; }
                        set { sMAlookback = Math.Max(50, value); }
                    }
            
                    [Description("")]
                    [GridCategory("Parameters")]
                    public int Offset
                    {
                        get { return offset; }
                        set { offset = Math.Max(5, value); }
                    }
            
                    [Description("")]
                    [GridCategory("Parameters")]
                    public int Offsetneg
                    {
                        get { return offsetneg; }
                        set { offsetneg = Math.Max(-5, value); }
                    }
                    #endregion
                }
            }

            I had to delete some of the output that looked redundant to me to get under the 10k character max, I will make a second post next with just the output window so I wont have to delete anything.

            In the output code, atleast I am entering long where I am supposed to enter long, and entering short where I am supposed to enter short. However there is no output at all when the price crosses through and where it should reverse.

            IE: that last example it went long at .96 but there was no attempt to even try and go short at .86

            Comment


              #21
              Code:
              LongCurrentAsk: 92.08 Offset+Tick: 0.05 SMA: 92.132
              Calculated value: 92.13
              ShortCurrentBid: 92.07 Offsetneg+Tick: -0.05 SMA: 92.132
              Calculated value: 92.02
              LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
              Calculated value: 92.14
              ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
              Calculated value: 92.03
              LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
              Calculated value: 92.14
              2013-06-03 6:16:58 AM Entered internal PlaceOrder() method at 2013-06-03 6:16:58 AM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
              LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
              Calculated value: 92.14
              ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
              Calculated value: 92.03
              LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
              Calculated value: 92.14
              2013-06-03 6:16:58 AM Entered internal PlaceOrder() method at 2013-06-03 6:16:58 AM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
              2013-06-03 6:16:58 AM Ignored PlaceOrder() method at 2013-06-03 6:16:58 AM: Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Sell short' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
              LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
              Calculated value: 92.14
              ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
              Calculated value: 92.03
              LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
              Calculated value: 92.14
              2013-06-03 6:16:58 AM Entered internal PlaceOrder() method at 2013-06-03 6:16:58 AM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
              2013-06-03 6:16:58 AM Ignored PlaceOrder() method at 2013-06-03 6:16:58 AM: Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Sell short' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
              LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
              Calculated value: 92.14
              ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
              Calculated value: 92.03
              LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
              Calculated value: 92.14
              2013-06-03 6:16:58 AM Entered internal PlaceOrder() method at 2013-06-03 6:16:58 AM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
              2013-06-03 6:16:58 AM Ignored PlaceOrder() method at 2013-06-03 6:16:58 AM: Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Sell short' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
              LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
              Calculated value: 92.14
              ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
              Calculated value: 92.03
              LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
              Calculated value: 92.14
              2013-06-03 6:16:58 AM Entered internal PlaceOrder() method at 2013-06-03 6:16:58 AM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
              2013-06-03 6:16:58 AM Ignored PlaceOrder() method at 2013-06-03 6:16:58 AM: Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Sell short' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
              LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
              Calculated value: 92.14
              ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
              Calculated value: 92.03
              LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
              Calculated value: 92.14
              2013-06-03 6:16:58 AM Entered internal PlaceOrder() method at 2013-06-03 6:16:58 AM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
              2013-06-03 6:16:58 AM Ignored PlaceOrder() method at 2013-06-03 6:16:58 AM: Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Sell short' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
              LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
              Calculated value: 92.14
              ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
              Calculated value: 92.03
              LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
              Calculated value: 92.14
              2013-06-03 6:16:58 AM Entered internal PlaceOrder() method at 2013-06-03 6:16:58 AM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
              2013-06-03 6:16:58 AM Ignored PlaceOrder() method at 2013-06-03 6:16:58 AM: Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Sell short' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
              LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
              Calculated value: 92.14
              ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
              Calculated value: 92.03
              LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
              Calculated value: 92.14
              2013-06-03 6:16:58 AM Entered internal PlaceOrder() method at 2013-06-03 6:16:58 AM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
              2013-06-03 6:16:58 AM Ignored PlaceOrder() method at 2013-06-03 6:16:58 AM: Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Sell short' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
              LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
              Calculated value: 92.14
              ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
              Calculated value: 92.03
              LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
              Calculated value: 92.14
              2013-06-03 6:16:58 AM Entered internal PlaceOrder() method at 2013-06-03 6:16:58 AM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
              2013-06-03 6:16:58 AM Ignored PlaceOrder() method at 2013-06-03 6:16:58 AM: Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Sell short' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
              LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
              Calculated value: 92.14
              ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
              Calculated value: 92.03
              LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
              Calculated value: 92.14
              2013-06-03 6:16:58 AM Entered internal PlaceOrder() method at 2013-06-03 6:16:58 AM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
              2013-06-03 6:16:58 AM Ignored PlaceOrder() method at 2013-06-03 6:16:58 AM: Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Sell short' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
              LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
              Calculated value: 92.14
              ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
              Calculated value: 92.03
              LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
              Calculated value: 92.14
              2013-06-03 6:16:58 AM Entered internal PlaceOrder() method at 2013-06-03 6:16:58 AM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
              2013-06-03 6:16:58 AM Ignored PlaceOrder() method at 2013-06-03 6:16:58 AM: Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Sell short' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
              There is the output window of where it went long ill post the 2nd part of it next

              Comment


                #22
                2nd part of output window where it went long

                Code:
                LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
                Calculated value: 92.14
                ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
                Calculated value: 92.03
                LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
                Calculated value: 92.14
                2013-06-03 6:16:58 AM Entered internal PlaceOrder() method at 2013-06-03 6:16:58 AM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
                2013-06-03 6:16:58 AM Ignored PlaceOrder() method at 2013-06-03 6:16:58 AM: Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Sell short' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
                System.ArgumentNullException: Value cannot be null.
                Parameter name: brush
                   at System.Drawing.Graphics.DrawString(String s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format)
                   at System.Drawing.Graphics.DrawString(String s, Font font, Brush brush, Single x, Single y)
                   at NinjaTrader.Indicator.jtRangeMarker7.Plot(Graphics graphics, Rectangle bounds, Double min, Double max)
                LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
                Calculated value: 92.14
                ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
                Calculated value: 92.03
                LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
                Calculated value: 92.14
                2013-06-03 6:16:59 AM Entered internal PlaceOrder() method at 2013-06-03 6:16:59 AM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
                2013-06-03 6:16:59 AM Ignored PlaceOrder() method at 2013-06-03 6:16:59 AM: Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Sell short' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
                LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
                Calculated value: 92.14
                ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
                Calculated value: 92.03
                LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
                Calculated value: 92.14
                2013-06-03 6:16:59 AM Entered internal PlaceOrder() method at 2013-06-03 6:16:59 AM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
                2013-06-03 6:16:59 AM Ignored PlaceOrder() method at 2013-06-03 6:16:59 AM: Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Sell short' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
                LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
                Calculated value: 92.14
                ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
                Calculated value: 92.03
                LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
                Calculated value: 92.14
                2013-06-03 6:17:00 AM Entered internal PlaceOrder() method at 2013-06-03 6:17:00 AM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
                2013-06-03 6:17:00 AM Ignored PlaceOrder() method at 2013-06-03 6:17:00 AM: Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Sell short' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
                LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
                Calculated value: 92.14
                ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
                Calculated value: 92.03
                LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
                Calculated value: 92.14
                2013-06-03 6:17:00 AM Entered internal PlaceOrder() method at 2013-06-03 6:17:00 AM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
                2013-06-03 6:17:00 AM Ignored PlaceOrder() method at 2013-06-03 6:17:00 AM: Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Sell short' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
                LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
                Calculated value: 92.14
                ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
                Calculated value: 92.03
                LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
                Calculated value: 92.14
                2013-06-03 6:17:00 AM Entered internal PlaceOrder() method at 2013-06-03 6:17:00 AM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
                2013-06-03 6:17:00 AM Ignored PlaceOrder() method at 2013-06-03 6:17:00 AM: Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Sell short' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
                LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
                Calculated value: 92.14
                ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
                Calculated value: 92.03
                LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
                Calculated value: 92.14
                2013-06-03 6:17:00 AM Entered internal PlaceOrder() method at 2013-06-03 6:17:00 AM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
                2013-06-03 6:17:00 AM Ignored PlaceOrder() method at 2013-06-03 6:17:00 AM: Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Sell short' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
                LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
                Calculated value: 92.14
                ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
                Calculated value: 92.03
                LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
                Calculated value: 92.14
                2013-06-03 6:17:00 AM Entered internal PlaceOrder() method at 2013-06-03 6:17:00 AM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
                2013-06-03 6:17:00 AM Ignored PlaceOrder() method at 2013-06-03 6:17:00 AM: Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Sell short' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
                LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
                Calculated value: 92.14
                ShortCurrentBid: 92.08 Offsetneg+Tick: -0.05 SMA: 92.1322
                Calculated value: 92.03
                LongCurrentAsk: 92.09 Offset+Tick: 0.05 SMA: 92.1322
                Calculated value: 92.14
                2013-06-03 6:17:00 AM Entered internal PlaceOrder() method at 2013-06-03 6:17:00 AM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
                2013-06-03 6:17:00 AM Ignored PlaceOrder() method at 2013-06-03 6:17:00 AM: Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Sell short' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
                LongCurrentAsk: 92.1 Offset+Tick: 0.05 SMA: 92.1324
                Calculated value: 92.15
                ShortCurrentBid: 92.09 Offsetneg+Tick: -0.05 SMA: 92.1324
                Calculated value: 92.04
                LongCurrentAsk: 92.1 Offset+Tick: 0.05 SMA: 92.1324
                Calculated value: 92.15
                ShortCurrentBid: 92.09 Offsetneg+Tick: -0.05 SMA: 92.1324
                Calculated value: 92.04
                LongCurrentAsk: 92.1 Offset+Tick: 0.05 SMA: 92.1324
                Calculated value: 92.15
                ShortCurrentBid: 92.09 Offsetneg+Tick: -0.05 SMA: 92.1324

                Comment


                  #23
                  Hello Thorpc,

                  Thank you for the info.

                  I had a chance to look over your code and the recent post, #20, shows your code with entering long with the Bid price has crossed below the SMA and entering short when the Ask price has crossed above the SMA.

                  As such, your output code shows this to be correct. It entered short when the Ask crossed above the SMA and will enter long when the Bid crosses below the SMA.

                  I ran a test on your code and noticed that the cross of Bid below the SMA very rarely happened but it did happen.

                  You will need to tweak the entry methods of your orders if you want to show the entry orders either more often or where you want them to occur.

                  Please let me know if you have any questions.
                  Cal H.NinjaTrader Customer Service

                  Comment


                    #24
                    Your code should not even compile like this:

                    Code:
                    if (CrossAbove(GetCurrentAsk() + Offset * TickSize, SMA(SMAlookback), 1))
                    Because CrossAbove/CrossBelow methods expect the first parameter to be of type DataSeries.

                    CrossAbove(IDataSeries series1, double value, int lookBackPeriod)
                    CrossAbove(IDataSeries series1, IDataSeries series2, int lookBackPeriod)

                    Check the reference manual http://www.ninjatrader.com/support/h...crossabove.htm

                    Comment


                      #25
                      Thankyou so much for your replies!

                      Nailz420: Perhaps I misunderstand what you mean - the GetCurrentAsk I believe is a data series? Atleast it is found in the data section of my help guide?

                      NinjaTrader_Cal: I removed the bid and changed it for ask so now the code looks like this

                      Code:
                              {
                                  if (CrossAbove((GetCurrentAsk() + (Offset * TickSize)), SMA(SMAlookback), 1))
                      			{
                      				Print("LongCurrentAsk: "+GetCurrentAsk()+" (Offset+Tick): "+(Offset * TickSize)+" SMA: "+SMA(SMAlookback)[0]);
                      				Print("Calculated value: "+(GetCurrentAsk() + (Offset * TickSize)));
                                      EnterShort();
                      			}
                                  else if (CrossBelow((GetCurrentAsk() + (Offsetneg * TickSize)), SMA(SMAlookback), 1))
                      			{
                      				Print("ShortCurrentAsk: "+GetCurrentAsk()+" (Offsetneg+Tick): "+(Offsetneg * TickSize)+" SMA: "+SMA(SMAlookback)[0]);
                      				Print("Calculated value: "+(GetCurrentAsk() + (Offsetneg * TickSize)));
                                      EnterLong();
                      			}
                              }
                      Essentially it is still doing the same thing.

                      Ideally what I am attempting to have happen is this: If the price is below the SMA as it moves up, 5 ticks below the sma it enters short. If the price continues move up at 5 ticks above the sma it would reverse and go long. (or vice versa if the price was falling)

                      Currently it is doing the first part of the code. If the price is below the sma and gets to within the 5 ticks it will enter short, but as the price continues through it does not want to reverse my position and go long.

                      I am sorry I am new to programming so I am not sure if my logic is incorrect or I am just missing something very simply :P

                      Originally I used the strategy wizard to help create a code. When it failed to accomplish what I wanted I looked at the view code from the sample MA crossover strat (which will reverse position depending on whether the fast/slow periods was crossed above or crossed below.

                      Essentially I am attempting to do the same as the MA crossover but rather then a fast SMA I am using the current price crossing the SMA.

                      Thankyou so much for your guys assistance! I will keep reading the help manual and plugging away at it until we can get it working!

                      Comment


                        #26


                        Method Return Value
                        A double value representing the current ask price

                        you need to switch SMA and the GetCurrentAsk around in your cross over methods.

                        Comment


                          #27
                          Thanks Nailz420 for the help!

                          So when I switch the code around so it is like this:

                          Code:
                                  {
                                      if (CrossAbove(SMA(SMAlookback), (GetCurrentAsk() + (Offset * TickSize)), 1))
                          			{
                          				Print("ShortCurrentAsk: "+GetCurrentAsk()+" (Offset+Tick): "+(Offset * TickSize)+" SMA: "+SMA(SMAlookback)[0]);
                          				Print("Calculated value: "+(GetCurrentAsk() + (Offset * TickSize)));
                                          EnterShort();
                          			}
                                      if (CrossBelow(SMA(SMAlookback), (GetCurrentAsk() + (Offsetneg * TickSize)), 1))
                          			{
                          				Print("LongCurrentAsk: "+GetCurrentAsk()+" (Offsetneg+Tick): "+(Offsetneg * TickSize)+" SMA: "+SMA(SMAlookback)[0]);
                          				Print("Calculated value: "+(GetCurrentAsk() + (Offsetneg * TickSize)));
                                          EnterLong();
                          			}
                                  }
                          Only the enter short will work, no matter which way the price comes from - if the price is above the sma it has to go 5 ticks below the sma before it enters short, or if the price is below the sma it has to get within 5 ticks below before entering short.

                          Comment


                            #28
                            Originally posted by [email protected] View Post
                            Thanks Nailz420 for the help!

                            So when I switch the code around so it is like this:

                            Code:
                                    {
                                        if (CrossAbove(SMA(SMAlookback), (GetCurrentAsk() + (Offset * TickSize)), 1))
                                        {
                                            Print("ShortCurrentAsk: "+GetCurrentAsk()+" (Offset+Tick): "+(Offset * TickSize)+" SMA: "+SMA(SMAlookback)[0]);
                                            Print("Calculated value: "+(GetCurrentAsk() + (Offset * TickSize)));
                                            EnterShort();
                                        }
                                        if (CrossBelow(SMA(SMAlookback), (GetCurrentAsk() + (Offsetneg * TickSize)), 1))
                                        {
                                            Print("LongCurrentAsk: "+GetCurrentAsk()+" (Offsetneg+Tick): "+(Offsetneg * TickSize)+" SMA: "+SMA(SMAlookback)[0]);
                                            Print("Calculated value: "+(GetCurrentAsk() + (Offsetneg * TickSize)));
                                            EnterLong();
                                        }
                                    }
                            Only the enter short will work, no matter which way the price comes from - if the price is above the sma it has to go 5 ticks below the sma before it enters short, or if the price is below the sma it has to get within 5 ticks below before entering short.
                            Do you have any StopLoss order active?

                            Comment


                              #29
                              1. How are you testing it? I dont think GetCurrentAsk/Bid is available in backtest. you might want to use Market Replay for this.
                              2. You have GetCurrentAsk thresholds in both long and short conditions. Shouldn't you use GetCurrentBid() for one of them?

                              Comment


                                #30
                                No I do not, I have been wondering about that. Many times the stop loss is a straightforward 10 ticks (if the price reversal comes in the same bar that the entry point comes at. However if a bar has finished and a new one has printed then the SMA value has changed and the reversal point could be less then or more then 10 ticks away.

                                I originally thought I would have to put that in the code somewhere but the MAcrossover strat which reverses every time there is a crossover does not have a stoploss order as far as I know

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                647 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                368 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                108 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                571 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                573 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X