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

 
Alexey Viktorov:

It's unseemly to lie so blatantly. You delete your post and blame your illiteracy on someone else. Liar.

What message?
I only wrote about prev_calculated and rates_total from the beginning.

To which I got a reply from you:

Why should you make fun of an inexperienced programmer like that?

What if there is a missed history and the difference is more than 1? But we don't really care, let's just skip one bar... you know, one more, one less. And without explanations why should we give the code? See what you get in the end?

so you're the Liar)

1

 
Taras Slobodyanik:

Yes, you either need to change the direction of the arrays or take the rates_total-2 index instead of 1


After adding.

ArraySetAsSeries(open,true);
ArraySetAsSeries(high,true);
ArraySetAsSeries(low,true);
ArraySetAsSeries(close,true);
ArraySetAsSeries(time,true);   

Defines correctly.

2021.06.02 18:33:09.480 Test (Volatility 10 Index,M1)   Up
2021.06.02 18:34:09.479 Test (Volatility 10 Index,M1)   Dn

Full code:

//+------------------------------------------------------------------+
//|                                                    test.mq5 |
//|                                  Copyright 2021, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window

#property indicator_buffers 2
#property indicator_plots   2

#property indicator_label1  "Signal UP"
#property indicator_type1   DRAW_ARROW
#property indicator_color1  clrLime
#property indicator_style1  STYLE_SOLID
#property indicator_width1  2

#property indicator_label2  "Signal DN"
#property indicator_type2   DRAW_ARROW
#property indicator_color2  clrRed
#property indicator_style2  STYLE_SOLID
#property indicator_width2  2

double up[];
double dn[];

datetime fin=0, last=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
    IndicatorSetString(INDICATOR_SHORTNAME, "Prototype");
    
   SetIndexBuffer(0,up,INDICATOR_DATA);
   PlotIndexSetInteger(0,PLOT_ARROW,233);
    
   SetIndexBuffer(1,dn,INDICATOR_DATA);
   PlotIndexSetInteger(1,PLOT_ARROW,234);
   
   
  
   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[])
   {
   
   ArraySetAsSeries(open,true);
   ArraySetAsSeries(high,true);
   ArraySetAsSeries(low,true);
   ArraySetAsSeries(close,true);
   ArraySetAsSeries(time,true);   
 
   fin=iTime(Symbol(), PERIOD_M1 ,0);
   if(last==fin) return(rates_total);
   last=fin;
   
   if(rates_total - prev_calculated == 1)
      {
         if(open[1] > close[1])
         {
           Print("Dn");
         }
    else if(open[1] < close[1])
         {
           Print("Up");
         }
     }

return(rates_total);
}
 
Taras Slobodyanik:

what message?
I only wrote about prev_calculated and rates_total from the beginning.

To which I got a reply from you:

so you're the Liar)


Yeah, I didn't delete it, I just didn't find that post right away.

Forum on trading, automated trading systems and trading strategies testing.

Any questions from newbies on MQL4 and MQL5, help and discussion on algorithms and codes

Taras Slobodyanik, 2021.06.02 16:47

Because there are no brackets.

if(rates_total - prev_calculated == 1)
   {
   //Print("Новый бар");
   if(open[1] > close[1])
        {
        Print("Dn");
        }
   else if(open[1] < close[1])
        {
        Print("Up");
        }
   }

But! Still retracting your words who are you?
 
And so it works
   ArraySetAsSeries(open,true);
   ArraySetAsSeries(high,true);
   ArraySetAsSeries(low,true);
   ArraySetAsSeries(close,true);
   ArraySetAsSeries(time,true);   
 

   if(rates_total - prev_calculated == 1)
      {
         if(open[1] > close[1])
         {
           Print("Dn");
         }
    else if(open[1] < close[1])
         {
           Print("Up");
         }
     }
 
Thanks for your help :)
 
Alexey Viktorov:

Yeah, I didn't delete it, I just didn't immediately find it.

But! Still retracting my words who are you
Alexey Viktorov:

It's rude to lie so blatantly. You delete your post and blame your illiteracy on someone else. Liar.

so i'm a Liar because i didn't delete my post and blame my illiteracy on others, original)))


I'll say it again.

Taras Slobodyanik:

I'm not suggesting you read the bar closure on the left, that's not my code)

mine only

if(rates_total - prev_calculated == 1)
 
m-r LSV:
Thanks for your help :)

please)

 
Share some more. Only on the condition that you both use a GoPro - for the story.
 
Artyom Trishkin:
Share some more. Only on the condition that you both use a GoPro - for the story.

This is the strategy of some "smart guys", to blow dust in their eyes, and when they fail, to accuse them of all sins, to hide their illiteracy and incompetence, let the opponent justify that he is not a fool.

 
Taras Slobodyanik:

This is the strategy of some "smart guys", to blow dust in their eyes, and when they fail, to accuse them of all their sins to hide their illiteracy and incompetence, let their opponent justify that he is not stupid.

Tarasik, piss off... Idiot. Look at the code that you generated after your hints... It's called "teaching how not to do it", and anyone who does not understand it is his own fault.