Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Simple Short High Tick/Buy Low Tick Strategy

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

    Simple Short High Tick/Buy Low Tick Strategy

    I am pretty new to creating strategies so a little help would be appreciated. I am trying to use the Strategy Analyzer and I cannot get this strategy to execute any buys or sells... can someone take a quick look? I am sure I am doing something stupid....

    private bool curLong = true; // Default setting for CurLong
    private bool curShort = true; // Default setting for CurShort
    private bool noPos = true; // Default setting for NoPos
    private double highTickThresh = 600; // Default setting for HighTickThresh
    private double lowTickThresh = -600; // Default setting for LowTickThresh

    protected override void Initialize()
    {
    Add("ES 12-15",PeriodType.Minute,1);
    Add("^TICK",PeriodType.Minute,1);
    CalculateOnBarClose = true;
    CurLong = false;
    CurShort = false;
    NoPos = true;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (Low[1] <= LowTickThresh)
    {
    if (CurShort == true )
    {
    ExitShort();
    CurShort = false;
    }
    if (CurLong == false)
    {
    EnterLong();
    CurLong = true;
    }
    }

    // Condition set 2
    if (High[1] >= HighTickThresh)
    {
    if (CurLong == true)
    {
    ExitLong();
    CurLong = false;
    }
    if (CurShort == false)
    {
    EnterShort();
    CurShort = true;
    }

    }
    }

    #2
    Hello,

    Thank you for the question.

    I would like to check, have you confirmed you have 1 minute data for the series you are adding before testing?

    Additionally have you used Print statements or other debugging techniques to determine where the logic is not being met? If not I would suggest using Print statements first to see if the conditions are being called, if not you could try printing the values for the variables used or the items in the conditions to see what values are being passed. We have a collection of debugging steps located at the following post: http://ninjatrader.com/support/forum...ead.php?t=3418

    I look forward to being of further assistance.

    Comment


      #3
      Thank you NinjaTrader_Jesse. This was very helpful

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      47 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      23 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      33 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      51 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      42 views
      0 likes
      Last Post CarlTrading  
      Working...
      X