Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1020

 
Vladimir Karputov:

In an EA or in an indicator? For the current timeframe or for another one?

Preferably in an indicator, current timeframe.

 
yiduwi:

Preferably in an indicator, current timeframe.

The indicators already have OHLC, time and volume arrays:OnCalculate

int  OnCalculate( 
   const int        rates_total,       // размер входных таймсерий 
   const int        prev_calculated,   // количество обработанных баров на предыдущем вызове 
   const datetime&  time[],            // массив Time 
   const double&    open[],            // массив Open 
   const double&    high[],            // массив High 
   const double&    low[],             // массив Low 
   const double&    close[],           // массив Close 
   const long&      tick_volume[],     // массив Tick Volume 
   const long&      volume[],          // массив Real Volume 
   const int&       spread[]           // массив Spread 
   );

So, you just need to access arrays high and low.

You just need to do this trick first:

//+------------------------------------------------------------------+
//| 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(N>rates_total-1)
      return(0);
   ArraySetAsSeries(high,true);
   ArraySetAsSeries(low,true);
   ***
//--- return value of prev_calculated for next call
   return(rates_total);
  }

After that, high and low arrays will have index [0] corresponding to the rightmost bar on the chart.

 
Vladimir Karputov:

The indicators already have OHLC, time and volume arrays:OnCalculate

So you just need to refer to high and low arrays.

You just need to do the following trick first:

After that, the high and low arrays will have index [0] corresponding to the rightmost bar on the chart.

Thank you.

 

Are there any instructions on how to convert the robot from spot instruments to futures?

I am trying to test it - it works on FX and CFD, but not on indices, for example. In log there is some activity, order-positions-transactions, but the result - all with 0 profit (price IN and OUT different!) And balance graph - horizontal line.

Piece of the test log:

Results:



Anyway, something I'm misunderstanding on a global level... In the "Stock Trading" section it's all about specifics...

 
Igor Zakharov:

...all with 0 profit (price IN and OUT different!) and the balance graph is a horizontal line...

Could this be a bug in the tester?

 
Igor Zakharov:

Are there any instructions on how to convert the robot from spot instruments to futures?

I am trying to test it - it works on FX and CFD, but not on indices, for example. In log there is some activity, order-positions-transactions, but the result - all with 0 profit (price IN and OUT different!) And balance graph - horizontal line.

A slice of the test log:

Results:



Anyway, something I'm misunderstanding on a global level... In "Stock Trading" we`re just talking about details...

What iscurrency of deposit?

Show me the instrument specification.

You need to have tools to convert your profit to the currency of your deposit in the Market Watch.

 
Andrey Khatimlianskii:

What isthe currency of the deposit?

Show the specification of the instrument.

You need to have tools available in the market overview to convert the profit into the deposit currency.

USD, there is no need to recalculate. Open ALL available (Show All)


Obtained: on commodity futures - works on all (randomly selected oil, cocoa, etc...) Index futures - all from 0.
 
Comments not related to this topic have been moved to "Questions from MQL4 MT4 MetaTrader 4 beginners".
 
Vladimir Karputov:
Comments not relevant to this topic have been moved toMQL4 MT4 MetaTrader 4 Beginner's Questions.

Vladimir, so my question was about five. The last time I asked you a question about five, and you deleted it here.

And there's no one to answer in that topic now, Artem says he's busy ((

 
psyman:

Vladimir, my question was about a five. Last time in the Fours topic you gave me the finger for a fives question, but now you deleted it here.

There's no one to answer in that thread now, Artem says he's busy ((

I did not threaten anyone. You are dreaming.

Also you have mixed up MQL5 and MQL4. MQL5 code are files with .mq5 extension.
Reason: