Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1486

 
MakarFX:
Wrong, it needs the time of the previous candle

Well, you can also telepathize the zero candle :) because it is the last one, not the previous one.

If we do psychic analysis we can suppose that we are looking for the value inside one hour candlestick, which brings us back to my previous post about iLowest and iHighest.

 
ANDREY:

Thank you.

PapaYozh was right, because according to your condition

if (Bid - iLow( NULL ,PERIOD_H1,1)>=0.0030)

you're not looking for a low, you're looking for a pullback from a low.

 
PapaYozh:

Yes, I wasn't paying attention.

I wasn't paying attention...

 
Vladislav Andruschenko:


just leave it?


Well just checked. it's not executing in mt5. build flatt 2940

Or have you removed OnCalculate?



aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa :-) created a script and put it in the indicators folder

Unique.

More like an exception, you just stuck the script in the indicators folder and the terminal gobbled it up.

Yeah, that's the trick/problem... Confused folders at first, then took it as a feature... A good feature, one time execution after oninit.

 
Valeriy Yastremskiy:

Yes, that's the trick/problem... Got the folders confused at first, then took it as a feature... A good feature, one time execution after oninit.

So it's just a script that executes in the chart thread.

 

Makar, you gave a link to an indicator with an answer to my question. Nothing works( I did it by gut feeling, I don't have the brains for it. I need your help!

https://www.mql5.com/ru/forum/160683/page1465#comment_22167585

Любые вопросы новичков по MQL4 и MQL5, помощь и обсуждение по алгоритмам и кодам
Любые вопросы новичков по MQL4 и MQL5, помощь и обсуждение по алгоритмам и кодам
  • 2021.05.03
  • www.mql5.com
В этой ветке я хочу начать свою помощь тем, кто действительно хочет разобраться и научиться программированию на новом MQL4 и желает легко перейти н...
 
ifitstrue:

Makar, you gave a link to an indicator with an answer to my question. Nothing works( I did it by gut feeling, I don't have the brains for it. I need your help!

https://www.mql5.com/ru/forum/160683/page1465#comment_22167585

//+------------------------------------------------------------------+
//|                                                   MTF_Moving.mq4 |
//|                        Copyright 2017, MetaQuotes Software Corp. |
//|                             https://www.mql5.com/ru/users/melnik |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link      "https://www.mql5.com/ru/users/melnik"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_width1 2
#property indicator_width2 2
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_type1 DRAW_LINE
#property indicator_type2 DRAW_LINE

double ma_buffer_high[];
double ma_buffer_low[];

//--- input parameters
input int                     PeriodMaHigh   =1;            //Period High Ma
input int                     PeriodMaLow    =1;            //Period Low Ma
input ENUM_APPLIED_PRICE      PriceMaH       =PRICE_HIGH;   //Applied price
input ENUM_APPLIED_PRICE      PriceMaL       =PRICE_LOW;    //Applied price
input ENUM_MA_METHOD          MethodMa       =MODE_SMA;     //Method Ma
input ENUM_TIMEFRAMES         Timeframe      =PERIOD_D1;    //Timeframe for calculate

ENUM_TIMEFRAMES prd;

int index=-1;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0, ma_buffer_high, INDICATOR_DATA);
   SetIndexBuffer(1, ma_buffer_low, INDICATOR_DATA);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   if((rates_total-prev_calculated-PeriodMaHigh)<=0)return(0);
  
   if(Period()>Timeframe) prd=PERIOD_CURRENT;
   if(Period()<=Timeframe) prd=prd=Timeframe;
  
   for(int i=rates_total-prev_calculated-PeriodMaHigh-1;i>=0;i--)
   {
      if(TimeMinute(time[i])==0)index=iBarShift(Symbol(), prd, time[i], false);
      
      ma_buffer_high[i]=iMA(Symbol(), prd, PeriodMaHigh, 0, MethodMa, PriceMaH, index+1);
      ma_buffer_low[i] =iMA(Symbol(), prd, PeriodMaLow, 0, MethodMa, PriceMaL, index+1);
   }
  
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
MakarFX:

I tried to get a picture like that.

Files:
2.png  31 kb
 

It turns out like this.

Files:
3.png  26 kb
 
ifitstrue:

It goes like this.

If you want the previous day, see the previous post,

and if it's the current day, correct it.

      ma_buffer_high[i]=iMA(Symbol(), prd, PeriodMaHigh, 0, MethodMa, PriceMaH, index);
      ma_buffer_low[i] =iMA(Symbol(), prd, PeriodMaLow, 0, MethodMa, PriceMaL, index);