Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Automatic five bar strategy

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

    Automatic five bar strategy

    Hi,

    I'm trying to setup a strategy that trades the another instrument based on the action of IBM. However, when I apply the strategy to the instrutment I'm trading, it seems to execute the trade based on the action of the instrument I'm trading, and not the action of IBM.

    Any pointers on what I'm doing wrong?

    Here is my code:

    private int tradesize = 5;
    private double stoppoints = 6;
    private double profitpoints = 3;

    private IOrder LE = null;
    private IOrder SE = null;
    private IOrder LSL = null;
    private IOrder LPT = null;
    private IOrder SSL = null;
    private IOrder SPT = 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 = true;

    //Adding IBM Period Chart
    Add("IBM", PeriodType.Minute, 1);
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    //Trade creteria'
    if (Open[4] < Close[4]
    && Open[3] < Close[3])

    // Enter short if true
    SE=EnterShort(0,tradesize,"SE");
    }

    #2
    Hello,

    Yes, you will want to isolate your code using BarsInProgress. This link will help:

    DenNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    102 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    144 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    71 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    125 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    79 views
    0 likes
    Last Post PaulMohn  
    Working...
    X