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 NullPointStrategies, Today, 05:17 AM
      0 responses
      50 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      126 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      69 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      42 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      46 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X