Display Arrow from HTF Indicator

 

Hi all,

I have spent days searching the forum and code base but could not find a hint...

What I want to do is display an arrow on a e.g. H4 chart (entry TF) if some H4 indicators have the right value and iOsMA(W1) > 0 && iOsMA(D1) >0.

Any help or hint is highly appreciated.

Thanks all


//============================= INDEX CALCULATION ===================================================================================

   Long_Pos = 0;
   Short_Pos = 0;
   Long_Ex_Pos = 0;
   Short_Ex_Pos = 0;

  int limit;//, iChart, iTF, delta=0;
//  datetime TimeArray[];
//  if(Prime_TF>Period()) delta=MathCeil(Prime_TF/Period());
//  Print(IntegerToString(delta)); 
  int counted_bars=IndicatorCounted();
  //---- check for possible errors
  if(counted_bars<0) return(-1);
  //---- the last counted bar will be recounted
  if(counted_bars>0) counted_bars--;
//  limit=MathMax(Bars-counted_bars,delta);
  limit=Bars-counted_bars;


   for (i=limit; i>0; i--)
   {

      Long_Buffer[i] = 0;
      Short_Buffer[i] = 0;
      Long_Ex_Buffer[i] = 0;
      Short_Ex_Buffer[i] = 0;

      MAO_Prime   = iOsMA(NULL,10080,12,26,9,0,i+MAO_Offset);
      MAO_Trend   = iOsMA(NULL,1440,12,26,9,0,i+MAO_Offset);
      MAO_Entry   = iOsMA(NULL,240,12,26,9,0,i+MAO_Offset);
      SMA_Entry_F   = iMA(NULL,240,SMA_fast,0,MODE_SMA,PRICE_CLOSE,i+SMA_Offset);
      SMA_Entry_F_1 = iMA(NULL,240,SMA_fast,0,MODE_SMA,PRICE_CLOSE,i+SMA_Offset+1);
      SMA_Entry_S   = iMA(NULL,240,SMA_slow,1,MODE_SMA,PRICE_CLOSE,i+SMA_Offset);
      SMA_Entry_S_1 = iMA(NULL,240,SMA_slow,1,MODE_SMA,PRICE_CLOSE,i+SMA_Offset+1);

//      Print(iTime(NULL,0,i)," ", DoubleToString(MAO_Prime,5), " ", DoubleToString(MAO_Trend,5), " ", DoubleToString(MAO_Entry,5));
//      Func_Calc_Indicator();
      
//      if (JUMP_Sig_Code == 233) //is going long
      if (MAO_Prime > 0 && MAO_Trend > 0 && MAO_Entry > 0 && SMA_Entry_F > SMA_Entry_S) //is going long
      {
      Long_Buffer[i] = Low[i] - Sig_Dist * TV_Pip_Adj * Point;
      Long_Pos = 1;
      Long_Ex_Pos = 0;
      Long_Ex_Buffer[i] = 0;
      Short_Pos = 0;
      Short_Ex_Pos = 0;
      Short_Ex_Buffer[i] = 0;
      }
 
Blackriver67: I have spent days searching
You spent days? Your image shows the fractal indicator putting arrows above and below bars. Why doesn't your code do it the same exact way?
 
WHRoeder:
Blackriver67: I have spent days searching
You spent days? Your image shows the fractal indicator putting arrows above and below bars. Why doesn't your code do it the same exact way?

Hi WHRoeder, As you can see I adopted another indicator to draw the OsMA (D1) and OsMA (W1) in the sub windows (2 and 3) on a H4 chart. But I cannot get the other indicator working to draw an arrow (dodgerblue ones in chart window) if OsMA (W1), OsMA (D1) OsMA (H4) are either above zero (long) or below zero (Short). Based on the code lines I posted it draws all these blue arrows but they are not the way as intended and I cannot comprehend why it draws these arrows...


Or to put it in other words my problem is not how to draw arrows but how to get it working with an indicator signal from a higher timeframe.

 
 for (i=limit; i>0; i--)
   {

      Long_Buffer[i] = 0;
      Short_Buffer[i] = 0;
      Long_Ex_Buffer[i] = 0;
      Short_Ex_Buffer[i] = 0;

      MAO_Prime   = iOsMA(NULL,10080,12,26,9,0,i+MAO_Offset);
      MAO_Trend   = iOsMA(NULL,1440,12,26,9,0,i+MAO_Offset);
      MAO_Entry   = iOsMA(NULL,240,12,26,9,0,i+MAO_Offset);
      SMA_Entry_F   = iMA(NULL,240,SMA_fast,0,MODE_SMA,PRICE_CLOSE,i+SMA_Offset);
      SMA_Entry_F_1 = iMA(NULL,240,SMA_fast,0,MODE_SMA,PRICE_CLOSE,i+SMA_Offset+1);
      SMA_Entry_S   = iMA(NULL,240,SMA_slow,1,MODE_SMA,PRICE_CLOSE,i+SMA_Offset);
      SMA_Entry_S_1 = iMA(NULL,240,SMA_slow,1,MODE_SMA,PRICE_CLOSE,i+SMA_Offset+1);
You are mixing apples and oranges
 
WHRoeder:
You are mixing apples and oranges

OK, I read the other thread and I think what you want to tell me is that as long as I do not exceed bar[6] in the calculation on H4 I am within bar[1] on D1 and therefore I cannot use "i" for the D1 and W1 timeframe...

Thanks a lot, WHRoeder that´s obviouse now. But still I am not sure how to solve this. Clear is I would need 3 counters. "i" for H4 and then "iD1" and "iW1"... But actually I cannot use the numbers of H4 bars to trigger

the D1 and W1 counter but I have to use the time of the bars... Hmm, any other hint for me or maybe an example where I can have a look at it?

 
Blackriver67: but I have to use the time of the bars...
You didn't follow both links https://www.mql5.com/en/forum/110170
 
WHRoeder:
You didn't follow both links https://www.mql5.com/en/forum/110170


Dear WHRoeder, now I did follow both links and I basically understand the problem and tried to implement a solution (in two ways) but I have no good idea why it still does not work...

Can you please take another look at the code. By the way Prime_TF is 10080, Trend_TF = 1440 and Entry_TF = 240

//============================= INDEX CALCULATION ===================================================================================

   Long_Pos = 0;
   Short_Pos = 0;
   Long_Ex_Pos = 0;
   Short_Ex_Pos = 0;

   int limit, i_PTF, i_TTF, delta_PTF=0, delta_TTF=0;
   datetime TimeArray_PTF[];
   datetime TimeArray_TTF[];
   if(Prime_TF > Period()) delta_PTF = MathCeil(Prime_TF / Period());
   if(Trend_TF > Period()) delta_TTF = MathCeil(Trend_TF / Period());
//   Print(IntegerToString(delta_PTF), " ", IntegerToString(delta_TTF)); 
   int counted_bars=IndicatorCounted();
   //---- check for possible errors
   if(counted_bars<0) return(-1);
   //---- the last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=MathMax(Bars-counted_bars,delta_PTF);

//   ArrayCopySeries(TimeArray_PTF,MODE_TIME,Symbol(),Prime_TF);
//   ArrayCopySeries(TimeArray_TTF,MODE_TIME,Symbol(),Trend_TF);
  
   i_PTF=0;
   i_TTF=0;

   for(i_ETF=0; i_ETF<limit; i_ETF++)
     {
//      while(Time[i_ETF] < TimeArray_PTF[i_PTF]) i_PTF++;
      i_PTF = iBarShift(Symbol(), Prime_TF, Time[i_ETF]);
      MAO_Prime   = iOsMA(NULL,Prime_TF,12,26,9,0,i_PTF+(MAO_Offset*delta_PTF));

//      while(Time[i_ETF] < TimeArray_TTF[i_TTF]) i_TTF++;
      i_TTF = iBarShift(Symbol(), Trend_TF, Time[i_ETF]);
      MAO_Trend   = iOsMA(NULL,Trend_TF,12,26,9,0,i_TTF+(MAO_Offset*delta_TTF));

      MAO_Entry   = iOsMA(NULL,Entry_TF,12,26,9,0,i_ETF+MAO_Offset);
      SMA_Entry_F   = iMA(NULL,240,SMA_fast,0,MODE_SMA,PRICE_CLOSE,i_ETF+SMA_Offset);
      SMA_Entry_F_1 = iMA(NULL,240,SMA_fast,0,MODE_SMA,PRICE_CLOSE,i_ETF+SMA_Offset+1);
      SMA_Entry_S   = iMA(NULL,240,SMA_slow,1,MODE_SMA,PRICE_CLOSE,i_ETF+SMA_Offset);
      SMA_Entry_S_1 = iMA(NULL,240,SMA_slow,1,MODE_SMA,PRICE_CLOSE,i_ETF+SMA_Offset+1);

      Long_Buffer[i_ETF] = 0;
      Short_Buffer[i_ETF] = 0;
      Long_Ex_Buffer[i_ETF] = 0;
      Short_Ex_Buffer[i_ETF] = 0;

      Print(TimeToStr(Time[i_ETF],TIME_DATE)," ", DoubleToString(MAO_Prime,5), " ", DoubleToString(MAO_Trend,5), " ", DoubleToString(MAO_Entry,5));
//      Func_Calc_Indicator();
      
//      if (JUMP_Sig_Code == 233) //is going long
      if (MAO_Prime > 0 && MAO_Trend > 0 && MAO_Entry > 0 && SMA_Entry_F > SMA_Entry_S) //is going long
      {
      Long_Buffer[i_ETF] = Low[i_ETF] - Sig_Dist * TV_Pip_Adj * Point;
      Long_Pos = 1;
      Long_Ex_Pos = 0;
      Long_Ex_Buffer[i_ETF] = 0;
      Short_Pos = 0;
      Short_Ex_Pos = 0;
      Short_Ex_Buffer[i_ETF] = 0;
      }
 
Solved it, thanks.
Reason: