• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem !!

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

    Problem !!

    Good Hello, I have some problems with a strategy that I have running. The main problem is that I can not get it there will be a downward position when the price assigns the exposure indicator (Loweer Swing), but in the opposite direction, ie upward if the operation is correct. I leave the programming to see if they are kind enough to tell me where I have the problem. Thank you very much.





    protected override void Initialize()
    {
    Add(Swing(1));
    Add(Swing(1));
    SetStopLoss("", CalculationMode.Ticks, StopLoss, false);
    SetProfitTarget("", CalculationMode.Ticks, TakeProfit);

    CalculateOnBarClose = true;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (Open[-2] >= Swing(1).SwingHigh[0])
    {
    EnterLong(DefaultQuantity, "");
    }

    // Condition set 2
    if (CrossBelow(Open, Swing(1).SwingLow, 1))
    {
    EnterShort(DefaultQuantity, "");
    }
    }

    #region Properties
    [Description("")]
    [GridCategory("Parameters")]
    public int Indicador
    {
    get { return indicador; }
    set { indicador = Math.Max(1, value); }
    }

    [Description("")]
    [GridCategory("Parameters")]
    public int StopLoss
    {
    get { return stopLoss; }
    set { stopLoss = Math.Max(1, value); }
    }

    [Description("")]
    [GridCategory("Parameters")]
    public int TakeProfit
    {
    get { return takeProfit; }
    set { takeProfit = Math.Max(1, value); }
    }
    #endregion

    #2
    Hello warly903,

    Thank you for your post.
    Originally posted by warly903 View Post
    Code:
                // Condition set 1
                if (Open[-2] >= Swing(1).SwingHigh[0])
                {
                    EnterLong(DefaultQuantity, "");
                }
    Are you attempting to look two bars back or two bars forward? Unfortunately, the latter would not work.
    Patrick H.NinjaTrader Customer Service

    Comment


      #3
      Response

      I put (-2) and that putting 0 operation opened after a candle close above the indicator (Swing) and so in this way I get to run the operation when the price is crossing the (Swing) indicator. How do I do to make this same function but on the contrary sentrido, down.

      I am attaching a screenshot if I have not explained well.

      Sorry for my English. Thank you.
      Attached Files

      Comment


        #4
        Hello warly903,

        Thank you for your response.

        The CrossBelow() should work as it is currently set, the only item I would change is the CalculateOnBarClose to false from true. This would ensure the cross is checked on each tick rather than on the close of the bar.

        Please let me know if I may be of further assistance.
        Patrick H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by jrobin747, Today, 02:37 PM
        2 responses
        11 views
        0 likes
        Last Post bltdavid  
        Started by Gav_G, Today, 01:23 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_ChrisL  
        Started by webus, Today, 01:05 PM
        2 responses
        22 views
        0 likes
        Last Post webus
        by webus
         
        Started by Wick Wrangler, Today, 12:42 AM
        1 response
        22 views
        0 likes
        Last Post NinjaTrader_Kate  
        Started by pman777, 04-15-2020, 05:09 AM
        5 responses
        49 views
        0 likes
        Last Post NinjaTrader_Kate  
        Working...
        X