
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I implemented it with OnTimer() and nothing came out of it. Unfortunately the onTimer() event doesn't calculate the indicator and the delay is saved, maybe a loud statement and I've done something wrong, please correct. Thanks!
What you have done is not an implementation through OnTimer(). You only get values there (all of history, and every second, without any checks). In general, it is unlikely that you will be able to implement it by yourself. Wait for answer of branch author:)
I implemented it with OnTimer() and nothing came out of it. Unfortunately the onTimer() event doesn't calculate the indicator and the delay is saved, maybe a loud statement and I've done something wrong, please correct. Thanks!
//| TestCopyBuffer3.mq5 |
//| Copyright 2009, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2009, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots 1
//---- plot MA
#property indicator_label1 "MA"
#property indicator_type1 DRAW_LINE
#property indicator_color1 clrRed
#property indicator_style1 STYLE_SOLID
#property indicator_width1 1
//--- input parameters
bool AsSeries=true;
int period=15;
input ENUM_TIMEFRAMES TimeFrame=PERIOD_CURRENT; //Период графика
ENUM_MA_METHOD smootMode=MODE_EMA;
ENUM_APPLIED_PRICE price=PRICE_CLOSE;
int shift=0;
//--- indicator buffers
double MABuffer[];
int ma_handle;
int to_copy;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
SetIndexBuffer(0,MABuffer,INDICATOR_DATA);
Print("Параметр AsSeries = ",AsSeries);
Print("Индикаторный буфер после SetIndexBuffer() является таймсерией = ",
ArrayGetAsSeries(MABuffer));
//--- set short indicator name
IndicatorSetString(INDICATOR_SHORTNAME,"MA("+period+")"+AsSeries);
//--- set AsSeries (depends on input parameter)
ArraySetAsSeries(MABuffer,AsSeries);
Print("Индикаторный буфер после ArraySetAsSeries(MABuffer,true); является таймсерией = ",
ArrayGetAsSeries(MABuffer));
//---
ma_handle=iMA(Symbol(),TimeFrame,period,shift,smootMode,price);
EventSetTimer(1);
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[])
{
//--- check if all data calculated
if(BarsCalculated(ma_handle)<rates_total) return(0);
//--- we can copy not all data
//int to_copy;
if(prev_calculated>rates_total || prev_calculated<=0) to_copy=rates_total;
else
{
to_copy=rates_total-prev_calculated;
//--- last value is always copied
to_copy++;
}
//--- try to copy
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Timer function |
//+------------------------------------------------------------------+
void OnTimer()
{
//---
CopyBuffer(ma_handle,0,0,to_copy,MABuffer);
Print("Таймер");
}
//+------------------------------------------------------------------+
I assume that means tomove everything inOnCalculate toOnTimer
In order to rewrite it, all indicators to be included must also be under mql5
Afternoon. I'm on the Delta_RSI indicator, I have it constantly drawing (see screenshot) histo both ways at the same time (look for error). And it is possible to colour the no signal colour for above/below zero. Will you be able to see(correct)? Thank you.
describe what you do to break it ))))
chart, TF, sequence, etc.
describe what you do to break it ))))
chart, TF, sequence, etc.