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 zstheorist, Today, 07:52 PM
        0 responses
        7 views
        0 likes
        Last Post zstheorist  
        Started by pmachiraju, 11-01-2023, 04:46 AM
        8 responses
        150 views
        0 likes
        Last Post rehmans
        by rehmans
         
        Started by mattbsea, Today, 05:44 PM
        0 responses
        6 views
        0 likes
        Last Post mattbsea  
        Started by RideMe, 04-07-2024, 04:54 PM
        6 responses
        33 views
        0 likes
        Last Post RideMe
        by RideMe
         
        Started by tkaboris, Today, 05:13 PM
        0 responses
        6 views
        0 likes
        Last Post tkaboris  
        Working...
        X