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 tradingnasdaqprueba, 04-09-2024, 09:52 AM
        6 responses
        26 views
        0 likes
        Last Post tradingnasdaqprueba  
        Started by PaulMohn, Today, 02:06 AM
        1 response
        2 views
        0 likes
        Last Post PaulMohn  
        Started by Mindset, Today, 01:27 AM
        0 responses
        4 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by EB Worx, 03-07-2023, 05:05 AM
        4 responses
        97 views
        1 like
        Last Post cls71
        by cls71
         
        Started by patricia70, 11-23-2020, 10:17 AM
        17 responses
        548 views
        1 like
        Last Post PaulMohn  
        Working...
        X