Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problems getting a simple strat working

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

    Problems getting a simple strat working

    This is undoubtedly me being a numpty but I cant seem to get what I consider a simple strat to work. Basically I want to wait until an FX spread is say 2 pips and then place a Bid and Ask in between. I've gone through the wizard to produce this 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>
    /// When spread is greater than 2
    /// </summary>
    [Description("When spread is greater than 2")]
    public class GBPUSDSpread : Strategy
    {
    #region Variables
    // Wizard generated variables
    // 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()
    {

    CalculateOnBarClose = false;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (SpreadDisplay().Spread[0] > 0.0002)
    {
    EnterLongLimit(DefaultQuantity, GetCurrentBid() + GetCurrentBid() + 1 * TickSize * TickSize, "");
    EnterShortLimit(DefaultQuantity, GetCurrentAsk() + -1 * TickSize, "");
    }
    }

    #region Properties
    #endregion
    }
    }

    Can you tell me why its not working ? Thanks

    #2
    Actually want I really want is to place Bid and Ask OCO orders inside the spread and then when either is taken to place an offset trade 1 pip in profit. If you can add that it would be great. Thanks

    Comment


      #3
      Hello,

      Thanks for the note.

      Can you please clarify on what you mean by it is not working? What specifically is it doing or not doing?

      I look forward to assisting you further.

      Comment


        #4
        Well, even in those time when the spread widened, no trades were placed. I changed the FLASE to TRUE (CalculateOnBarClose) and this got one side placed but not both. I'd like both Bid and Ask to be placed and when one is taken the other is canceled and a take profit of 1 pip placed as an offset (if that's the right term).

        Comment


          #5
          Hello,

          Ok, in this case if this statement here executes then the orders are placed:

          if (SpreadDisplay().Spread[0] > 0.0002)


          We need to check into if this is executing or if it is executing but ther orders not ffilling.

          PLease do the following.



          Then add in a Print statement to verify this line of code is getting run and when it runs.



          Let me know if I can answer any questions.

          I look forward to assisting you further.

          Comment


            #6
            You would have to use StopLimit() orders: Limit() orders cancel each other out.
            Last edited by koganam; 04-18-2011, 11:27 PM.

            Comment


              #7
              Thanks for the help guys but I'm going to leave it and get the strat written by someone else who understands NT7 better than me.

              PS Can someone explain why forum threads sometimes start from the end and sometimes from the beginning. It really is confusing and somewhat random.....

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by wzgy0920, 04-20-2024, 06:09 PM
              2 responses
              27 views
              0 likes
              Last Post wzgy0920  
              Started by wzgy0920, 02-22-2024, 01:11 AM
              5 responses
              32 views
              0 likes
              Last Post wzgy0920  
              Started by wzgy0920, 04-23-2024, 09:53 PM
              2 responses
              49 views
              0 likes
              Last Post wzgy0920  
              Started by Kensonprib, 04-28-2021, 10:11 AM
              5 responses
              193 views
              0 likes
              Last Post Hasadafa  
              Started by GussJ, 03-04-2020, 03:11 PM
              11 responses
              3,235 views
              0 likes
              Last Post xiinteractive  
              Working...
              X