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.

    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.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Shansen, 08-30-2019, 10:18 PM
        24 responses
        939 views
        0 likes
        Last Post spwizard  
        Started by Max238, Today, 01:28 AM
        0 responses
        8 views
        0 likes
        Last Post Max238
        by Max238
         
        Started by rocketman7, Today, 01:00 AM
        0 responses
        4 views
        0 likes
        Last Post rocketman7  
        Started by wzgy0920, 04-20-2024, 06:09 PM
        2 responses
        28 views
        0 likes
        Last Post wzgy0920  
        Started by wzgy0920, 02-22-2024, 01:11 AM
        5 responses
        33 views
        0 likes
        Last Post wzgy0920  
        Working...
        X