Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Programing question

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

    Programing question

    I am trying to program a automated trading strategy that just follows the flow of price movement for my entrys and my exits, am always in the market,whether long or short, no indicators at all. I exit my short position on the first break above the previous bars, high of that bar if price has been moving down and I would simultaneously than go long. I would than stay long till the break of the previous bars low of that bar which than I would exit my long position and go short. I wrote some code as you can see below, but its missing something(s) to make it run properly and am not sure what it would take to make the strategy run, any input would be greatly appreciated.

    /// <summary>
    /// LONG AND SHORT
    /// </summary>
    [Description("LONG AND SHORT")]
    [Gui.Design.DisplayName("STEVE")]
    public class FLOWTRADING : Strategy
    {
    #region Variables
    // Wizard generated variables
    private int myInput0 = 1; // Default setting for MyInput0
    // 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 (Bars.CurrentAsk == High[1] + 1 * TickSize
    && Low[1] < Low[2]
    && High[1] <= High[2])
    {
    EnterLongLimit(DefaultQuantity, Bars.CurrentAsk, "");
    }

    // Condition set 2
    if (Low[2] < Low[3]
    && Bars.CurrentAsk == High[1] + 1 * TickSize
    && High[1] <= High[2])
    {
    EnterLongLimit(DefaultQuantity, Bars.CurrentAsk, "");
    }

    // Condition set 3
    if (Bars.CurrentAsk == High[1] + 1 * TickSize
    && Low[3] < Low[4]
    && High[1] <= High[2]
    && High[2] <= High[3])
    {
    EnterLongLimit(DefaultQuantity, Bars.CurrentAsk, "");
    }

    // Condition set 4
    if (Bars.CurrentAsk == High[1] + 1 * TickSize
    && Low[4] < Low[5]
    && High[1] <= High[2]
    && High[2] <= High[3]
    && High[3] <= High[4])
    {
    EnterLongLimit(DefaultQuantity, Bars.CurrentAsk, "");
    }

    // Condition set 5
    if (Bars.CurrentAsk == High[1] + 1 * TickSize
    && Low[5] < Low[6]
    && High[1] <= High[2]
    && High[2] <= High[3]
    && High[3] <= High[4]
    && High[4] <= High[5])
    {
    EnterLongLimit(DefaultQuantity, Bars.CurrentAsk, "");
    }

    // Condition set 6
    if (Bars.CurrentAsk == High[1] + 1 * TickSize
    && High[1] > High[2]
    && Low[1] < Low[2])
    {
    EnterLongLimit(DefaultQuantity, Bars.CurrentAsk, "");
    }

    // Condition set 7
    if (Bars.CurrentAsk == High[1] + 1 * TickSize
    && Low[0] < Low[1])
    {
    EnterLongLimit(DefaultQuantity, Bars.CurrentAsk, "");
    }

    // Condition set 8
    if (Bars.CurrentBid == Low[1] + -1 * TickSize
    && High[1] > High[2]
    && Low[1] >= Low[2])
    {
    EnterShortLimit(DefaultQuantity, Bars.CurrentBid, "");
    }

    // Condition set 9
    if (Bars.CurrentBid == Low[1] + -1 * TickSize
    && High[2] > High[3]
    && Low[1] >= Low[2])
    {
    EnterShortLimit(DefaultQuantity, Bars.CurrentBid, "");
    }

    // Condition set 10
    if (Bars.CurrentBid == Low[1] + -1 * TickSize
    && High[3] > High[4]
    && Low[1] >= Low[2]
    && Low[2] >= Low[3])
    {
    EnterShortLimit(DefaultQuantity, Bars.CurrentBid, "");
    }

    // Condition set 11
    if (Bars.CurrentBid == Low[1] + -1 * TickSize
    && High[4] > High[5]
    && Low[1] >= Low[2]
    && Low[2] >= Low[3]
    && Low[3] >= Low[4])
    {
    EnterShortLimit(DefaultQuantity, Bars.CurrentBid, "");
    }

    // Condition set 12
    if (Bars.CurrentBid == Low[1] + -1 * TickSize
    && High[5] > High[6]
    && Low[1] >= Low[2]
    && Low[2] >= Low[3]
    && Low[3] >= Low[4]
    && Low[4] >= Low[5])
    {
    EnterShortLimit(DefaultQuantity, Bars.CurrentBid, "");
    }

    // Condition set 13
    if (Bars.CurrentBid == Low[1] + -1 * TickSize
    && Low[1] < Low[2]
    && High[1] > High[2])
    {
    EnterShortLimit(DefaultQuantity, Bars.CurrentBid, "");
    }

    // Condition set 14
    if (Bars.CurrentBid == Low[1] + -1 * TickSize
    && High[0] > High[1])
    {
    EnterShortLimit(DefaultQuantity, Bars.CurrentBid, "");
    }
    }


    #region Properties
    [Description("")]
    [Category("Parameters")]
    public int MyInput0
    {
    get { return myInput0; }
    set { myInput0 = Math.Max(1, value); }
    }
    #endregion
    }
    }


    #2
    imported post

    Sorry your strategy is way too complex to comment.

    I suggest:
    - start of a real simple wizard generated sample
    - check if that is working as expected
    - add logic step by step to see where it breaks
    DierkNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by POTTER16, Today, 03:31 PM
    0 responses
    6 views
    0 likes
    Last Post POTTER16  
    Started by enricbcn, 05-08-2018, 01:36 AM
    78 responses
    43,520 views
    1 like
    Last Post Wessel
    by Wessel
     
    Started by Wessel, Today, 12:50 PM
    0 responses
    8 views
    0 likes
    Last Post Wessel
    by Wessel
     
    Started by asmmbillah, Today, 12:39 PM
    0 responses
    8 views
    0 likes
    Last Post asmmbillah  
    Started by dtmtradingco, Today, 12:30 PM
    0 responses
    7 views
    0 likes
    Last Post dtmtradingco  
    Working...
    X