Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Reversals (Unmanaged)

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

    Reversals (Unmanaged)

    Hello,

    I have written code that works, but when I try and increase the sample range to anything above 40 days, nothing loads. I have a very powerful PC(s) and have tested things on a tick by tick basis on long sessions for 4000 days. Even for 10 days it takes a very long time. I left it over night last night and nothing too.

    This is the first time I have not used DefaultQuantity in SubmitOrder, and have tried the code by using Default quantity instead of the initial '1' (this is the only place possible). I believe you will understand what I am talking about when you read my code. I have also tried it on 2 different computers, and on a number of different products and on intervals from 10 seconds to 60 minutes. Finally, when I launch the strat on a small period upon starting the programme, I get a message saying: "External Data Feed. There is no market data available to drive the simulation engine. affected Order: Buy 2 Stop @ 12098". This is in the DAX, but in every market the affected order is buying 2 Stops @ a certain price.

    Here is my code. I look forward to hearing from you greatly!

    #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>
    /// Enter the description of your strategy here
    /// </summary>
    [Description("Enter the description of your strategy here")]
    public class Reversal60 : Strategy
    {
    #region Variables

    // User defined variables (add any user defined variables below)

    private IOrder longOrder = null;
    private IOrder shortOrder = null;

    #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()
    {
    CalculateOnBarClose = false;
    Unmanaged = true;
    ExitOnClose = true;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {

    if(ToTime(Time[0]) > ToTime(8, 00, 00) && ToTime(Time[0]) < ToTime(8, 01, 01))
    {
    longOrder = SubmitOrder(0, OrderAction.Buy, OrderType.Stop, DefaultQuantity, First607amOHLC().CurrentHigh[0] + (2*TickSize), First607amOHLC().CurrentHigh[0] + (2*TickSize), "Long", "Long Order");
    shortOrder = SubmitOrder(0, OrderAction.SellShort, OrderType.Stop, DefaultQuantity, First607amOHLC().CurrentLow[0] - (2*TickSize), First607amOHLC().CurrentLow[0] - (2*TickSize), "Short", "Short Order");
    }

    }

    protected override void OnExecution(IExecution execution)
    {

    // If longOrder (1 lot) filled, cancel shortOrder and submit shortOrder again (2 lots)

    if(execution.MarketPosition == MarketPosition.Long
    && execution.Order != null
    && execution.Order.Filled > 0 )

    {
    double stop = First607amOHLC().CurrentLow[0] - (2*TickSize);

    if ( shortOrder != null )
    CancelOrder(shortOrder);
    shortOrder = null;

    shortOrder = SubmitOrder(0, OrderAction.SellShort, OrderType.Stop, 2, First607amOHLC().CurrentLow[0] - (2*TickSize), First607amOHLC().CurrentLow[0] - (2*TickSize), "Short", "Short Order");

    }


    // If shortOrder1 (1 lot), filled, cancel longOrder1 and submit longOrder1 again (2 lots)

    if(execution.MarketPosition == MarketPosition.Short
    && execution.Order != null
    && execution.Order.Filled > 0 )

    {
    double stop = First607amOHLC().CurrentHigh[0] + (2*TickSize);

    if (longOrder != null )
    CancelOrder(longOrder);
    longOrder = null;

    longOrder = SubmitOrder(0, OrderAction.Buy, OrderType.Stop, 2, First607amOHLC().CurrentHigh[0] + (2*TickSize), First607amOHLC().CurrentHigh[0] + (2*TickSize), "Long", "Long Order");

    }

    }

    }
    }


    Thank again

    #2
    I have just tried other strategies on the computers and everything is working as normal...

    Comment


      #3
      Hello Griberit,

      Thanks for your posts.

      Please send me your log and trace files for today so that I may look into what occurred.

      You can do this by going to the Control Center-> Help-> Mail to Platform Support.

      Please reference Atten Paul and the title of this thread in the subject line

      Comment


        #4
        Paul,

        I have replied and gone through the steps you indicated.

        Thanks so much and I look forward to hearing from you.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        630 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        364 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        566 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        568 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X