1

I am trying to draw Arrows Based on another indicator's signal from higher timeframe, but the problem i am facing is that it draws the arrow on multiple candles

For example : If I check the arrow visibility on W1 timeframe and have the my indicator draw the arrow on D1 timeframe it will draw 5 arrows on 5 daily candles for the weekly candle where the arrow appeared , but i cant figure out how to limit it to only place the arrow on one candle and not all five.

enter image description here

here is my code:

   for(int i = limit-1; i >= 0; i--)
     {
       
      int barshift_W1 = iBarShift(Symbol(), PERIOD_W1, Time[i]);
      if(barshift_W1 < 0) continue;
      
      //Indicator Buffer 1
      if(iCustom(NULL, PERIOD_W1, "Arrow Indicator", 0, barshift_W1) != EMPTY_VALUE  
      )
        {
         Buffer1[i] = iLow(NULL, PERIOD_W1, barshift_W1) - iATR(NULL, PERIOD_CURRENT, 14, i);  
        }
      else
        {
         Buffer1[i] = EMPTY_VALUE;
        }
      //Indicator Buffer 2
      if(iCustom(NULL, PERIOD_W1, "Arrow Indicator", 1, barshift_W1) != EMPTY_VALUE  
      )
        {
         Buffer2[i] = iHigh(NULL, PERIOD_W1, barshift_W1) + iATR(NULL, PERIOD_CURRENT, 14, i);  
        }
      else
        {
         Buffer2[i] = EMPTY_VALUE;
        }
     }
Sam
  • 161
  • 1
  • 11

1 Answers1

0

Try this code below. I haven't tested it, but the concept is, if you're not on a W1 chart, you want to only draw an arrow once on the first bar of the week, probably...:

for(int i = limit-1; i >= 0; i--)
     {
       
      int barshift_W1 = iBarShift(Symbol(), PERIOD_W1, Time[i]);
      if(barshift_W1 < 0) continue;
      
      //Indicator Buffer 1
      if(iCustom(NULL, PERIOD_W1, "Arrow Indicator", 0, barshift_W1) != EMPTY_VALUE && (Period()==PERIOD_W1 || i != limit-1 && (i * Period() / 10080 != (i+1) * Period() / 10080)
      )
        {
         Buffer1[i] = iLow(NULL, PERIOD_W1, barshift_W1) - iATR(NULL, PERIOD_CURRENT, 14, i);  
        }
      else
        {
         Buffer1[i] = EMPTY_VALUE;
        }
      //Indicator Buffer 2
      if(iCustom(NULL, PERIOD_W1, "Arrow Indicator", 1, barshift_W1) != EMPTY_VALUE && (Period()==PERIOD_W1 || i != limit-1 && (i * Period() / 10080 != (i+1) * Period() / 10080)  
      )
        {
         Buffer2[i] = iHigh(NULL, PERIOD_W1, barshift_W1) + iATR(NULL, PERIOD_CURRENT, 14, i);  
        }
      else
        {
         Buffer2[i] = EMPTY_VALUE;
        }
     }
Investing TS
  • 184
  • 1
  • 2
  • 13