Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

strategy only plot the last 2 arrows

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

    strategy only plot the last 2 arrows

    attached the screenshot.


    this codes only plot two arrows. the logic look okay. but I want it to be able to plot on the chart across all trading hours. Why it only plots two arrows ?



    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 1)
    return;

    // Set 1
    if (MACD1.Diff[0] > 0)
    {
    Draw.Text(this, @"plotMACDBuySell Text_1", @"macd diff > 0", 0, (Close[0] + 30) );
    MacdAboveZero = true;
    }

    // Set 2
    if (MACD1.Diff[0] < 0)
    {
    Draw.Text(this, @"plotMACDBuySell Text_1", @"macd diff < 0", 0, (Close[0] + 30) );
    MacdBelowZero = true;
    }

    // Set 3
    if ((MacdBelowZero == true)
    && (CrossAbove(MACD2.Default, MACD2.Avg, 1)))
    {
    Draw.ArrowUp(this, @"plotMACDBuySell Arrow up_1", true, 0, (Low[0] + (-12 * TickSize)) , Brushes.Lime);
    MacdBuy = true;
    }

    // Set 4
    if ((CrossBelow(MACD2.Default, MACD2.Avg, 1))
    && (MacdAboveZero == true))
    {
    Draw.ArrowDown(this, @"plotMACDBuySell Arrow down_1", true, 0, High[0], Brushes.Red);
    MacdSell = true;
    }

    }​​
    Attached Files

    #2
    Hello sysmatrix,

    To have many drawing objects they need a unique name. You can do something like the following:

    Draw.ArrowUp(this, @"plotMACDBuySell Arrow up_1" + CurrentBar, true, 0, (Low[0] + (-12 * TickSize)) , Brushes.Lime);
    ​Draw.ArrowDown(this, @"plotMACDBuySell Arrow down_1" + CurrentBar, true, 0, High[0], Brushes.Red);

    Adding CurrentBar to the string will give you a unique name per bar so you can have multiple objects. When you re use a tag that just updates the existing object on the chart to the new values.
    ​​

    Comment


      #3
      Thank you Josse. It works perfectly.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      88 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      134 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      119 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      69 views
      0 likes
      Last Post PaulMohn  
      Working...
      X