- how to create indicator that draw line at open prices on 10, 10 o'clock bars.
- 2 QQE combined and anchored - Need help
- How to code?
#property strict #property indicator_chart_window #property indicator_buffers 1 double OP, O[], RS_Open[10]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0, O); SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 1, clrBlue); ArrayInitialize(RS_Open, 0.0); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- //--- } //+------------------------------------------------------------------+ //| 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[] ) { for(int a = Bars-2; a >= 0; a--) { if(TimeHour(Time[a]) != TimeHour(Time[a+1])) { ArrayInitialize(RS_Open, 0.0); for(int i = 1; i <= 10; i++) { int x = 0; if(i == 1) x = i; else if(i > 1) x = (i-1) * 24; int Shift = iBarShift(Symbol(), PERIOD_H1, TimeCurrent()-(TimeCurrent() & 3600) - (60 * 60 *(Hour() + x + 23))); RS_Open[i-1] = Open[Shift]; OP = RS_Open[i-1]; } } O[a] = NormalizeDouble(OP, Digits); } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+this is my code. someone has any solution?
Can use a switch.
//+------------------------------------------------------------------+ int bars=240;//24hr*10bars double openprice[];ArrayResize(openprice,bars,0); for(int i=0;i<bars;i++) { switch(TimeHour(iTime(Symbol(),PERIOD_H1,i))) { case 10: openprice[i]=iOpen(Symbol(),PERIOD_H1,i); Print(" Time: ", TimeToString(iTime(Symbol(), PERIOD_H1,i), TIME_MINUTES), " Open: ", DoubleToString(openprice[i], Digits())); break; } } //+------------------------------------------------------------------+
It need some fine tuning but i hope you get the idea.
Can use a switch.
It need some fine tuning but i hope you get the idea.
thank you very much!
Can use a switch.
It need some fine tuning but i hope you get the idea.
i tried to create indicator but i can't. could you halp me?
//+------------------------------------------------------------------+
#property strict
#property indicator_chart_window
#property indicator_buffers 1
double oprice[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
SetIndexBuffer(0, oprice);
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 1, clrBlue);
//---
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[])
{
//---
for(int a = Bars - 2; a >= 0; a--)
{
int bars=240;//24hr*10bars
double openprice[]; ArrayResize(openprice,bars,0);
for(int i=0;i<bars;i++)
{
switch(TimeHour(iTime(Symbol(),PERIOD_H1,i)))
{
case 15:
openprice[i]=iOpen(Symbol(),PERIOD_H1,i);
break;
}
oprice[a] = openprice[i];
}
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
You can just use it as a script a script runs once and prints the desired results.
I am not sure what you want to do with those bar prices.
if you want to use it in a indicator you can switch for every bar that is 10hr or every bar that is 15 hr.
If you only want the ten last bars you have to add a counter, and start at bar 0 then once it has counted ten 10hr or 15 hr bars you can terminate the process.
So you set it up to count all bars at first, and starting at bar 0 the last bar, then when you have your ten bars simply break out of the calculation.
It would be very handy if you explain a bit more about your goals.
You can just use it as a script a script runs once and prints the desired results.
I am not sure what you want to do with those bar prices.
if you want to use it in a indicator you can switch for every bar that is 10hr or every bar that is 15 hr.
If you only want the ten last bars you have to add a counter, and start at bar 0 then once it has counted ten 10hr or 15 hr bars you can terminate the process.
So you set it up to count all bars at first, and starting at bar 0 the last bar, then when you have your ten bars simply break out of the calculation.
It would be very handy if you explain a bit more about your goals.
i want to change this code:
//+------------------------------------------------------------------+
//| Quatiles.mq4 |
//| Copyright 2016, R.T. Software Corp. |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, R.T. Software Corp."
#property link ""
#property version "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 7
extern int Quartile = 1000;
double Quartile_Number1 = 0.25, Quartile_Number2 = 0.50, Quartile_Number3 = 0.75,
price, H3[], H2[], H1[], M[], L1[], L2[], L3[], LQ_High[1000], LQ_Low[1000],
Hi_LQ1, Lo_LQ1, Hi_LQ2, Lo_LQ2, Hi_LQ3, Lo_LQ3;
int n;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
SetIndexBuffer(0, H3);
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 1, clrBlue);
SetIndexBuffer(1, H2);
SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 1, clrRed);
SetIndexBuffer(2, H1);
SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, 1, clrYellow);
SetIndexBuffer(3, M);
SetIndexStyle(3, DRAW_LINE, STYLE_SOLID, 1, clrBlack);
SetIndexBuffer(4, L1);
SetIndexStyle(4, DRAW_LINE, STYLE_SOLID, 1, clrYellow);
SetIndexBuffer(5, L2);
SetIndexStyle(5, DRAW_LINE, STYLE_SOLID, 1, clrRed);
SetIndexBuffer(6, L3);
SetIndexStyle(6, DRAW_LINE, STYLE_SOLID, 1, clrBlue);
ArrayResize( LQ_High, Quartile);
ArrayResize( LQ_Low, Quartile);
ArrayInitialize( LQ_High, 0.0);
ArrayInitialize( LQ_Low, 0.0);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
//---
}
//+------------------------------------------------------------------+
//| 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[] )
{
for(int a = Bars-2; a >= 0; a--)
{
if(TimeHour(Time[a]) != TimeHour(Time[a+1]))
{
ArrayInitialize(LQ_High, 0.0);
ArrayInitialize(LQ_Low, 0.0);
for(int i = 1; i <= Quartile; i++)
{
LQ_High[i-1] = iHigh(Symbol(), PERIOD_H1, i) - iOpen(Symbol(), PERIOD_H1, i);
LQ_Low[i-1] = iOpen(Symbol(), PERIOD_H1, i) - iLow(Symbol(), PERIOD_H1, i);
}
ArraySort( LQ_High);
ArraySort( LQ_Low);
n = (int)MathRound(Quartile*Quartile_Number1);
Hi_LQ1 = LQ_High[n];
Lo_LQ1 = LQ_Low[n];
n = (int)MathRound(Quartile*Quartile_Number2);
Hi_LQ2 = LQ_High[n];
Lo_LQ2 = LQ_Low[n];
n = (int)MathRound(Quartile*Quartile_Number3);
Hi_LQ3 = LQ_High[n];
Lo_LQ3 = LQ_Low[n];
price = Open[a];
}
H3[a] = NormalizeDouble(price + Hi_LQ3, Digits);
H2[a] = NormalizeDouble(price + Hi_LQ2, Digits);
H1[a] = NormalizeDouble(price + Hi_LQ1, Digits);
M[a] = NormalizeDouble(price,Digits);
L1[a] = NormalizeDouble(price - Lo_LQ1, Digits);
L2[a] = NormalizeDouble(price - Lo_LQ2, Digits);
L3[a] = NormalizeDouble(price - Lo_LQ3, Digits);
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
i want to use not all open prices. i want to use only prices of 10 o'clock bars. could you fix it?
Maybe this will help you.
Maybe this will help you.
no it does not. i want to create indicator that draw line or arrow at open prices on all, 10 o'clock bars. i need buffer of every 10 o'clock open price.
//+------------------------------------------------------------------+ int bars=1000; for(int i=0;i<bars;i++) { if(TimeHour(iTime(Symbol(),PERIOD_H1,i))==10) { ObjectCreate(0,"line "+IntegerToString(i),OBJ_VLINE,0,iTime(Symbol(),PERIOD_H1,i),0); } } //+------------------------------------------------------------------+
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use