Alert Problem

 

Hello community


i'm not the best in programming so i like to ask for help


i have a code for an inside bar indicator and now i like to get an alert when an inside bar is indicated



the problem is, i get the alert when i stay on the right timeframe, this means i see the alert on the 1h timeframe when my chart is open on the 1h timeframe

its possible to see also the alerts from the other timeframe?


int start()
{
string Cmnt = IndName;
if (Show_Remain_Bar_Time) Cmnt = Cmnt+"\n"+GetRemainingBarTime();
Comment(Cmnt);

static datetime prevtime = 0;
int shift;
int shift1;
int shift2;
double L, L1, H, H1;

if (Show_Daily_Open_Line)
{
int counted_bars = IndicatorCounted();
if (counted_bars > 0) counted_bars--;
int last_bar = Bars - counted_bars;
DrawDailyOpen(0, last_bar);
}
if (prevtime == Time[0]) return(0);

prevtime = Time[0];

for (shift = 0; shift < Bars; shift++)
{
shift1 = shift;
shift2 = shift + 1;

H = High[shift1];
H1 = High[shift2];
L = Low[shift1];
L1 = Low[shift2];

// Check IB's
if ((H <= H1) && (L >= L1))
{
if (Show_IB == true)
{
ib1[shift] = High[shift]; //Hochwert vom Innenbar
ib2[shift] = Low[shift]; // Tiefwert vom Innebar
ibPips[shift] = (ib1[shift] -ib2[shift])*MathPow(10,Digits);




}
}
}

if ( M5 == true && Period() == PERIOD_M5 ) {
if ( High[0] <= High[1] && Low[0] >= Low[1] ){

Alert("Innenbar " + Symbol() + " " + Period());
Sleep(10000);
}
}

if ( M15 == true && Period() == PERIOD_M15 ) {
if ( High[0] <= High[1] && Low[0] >= Low[1] ){

Alert("Innenbar " + Symbol() + " " + Period());
Sleep(10000);
}
}

if ( M30 == true && Period() == PERIOD_M30 ) {
if ( High[0] <= High[1] && Low[0] >= Low[1] ){

Alert("Innenbar " + Symbol() + " " + Period());
Sleep(10000);
}
}






return(0);
}

 

Yep, you will need to use the Timeseries access functions. check out the documentation.

.

Basically instead of using Time[] Close[] Open[] predefined variables etc.., you will use iTime() iClose() iOpen functions where you will specify which chart and timeframe to fetch it from.

.

Jon

 
Archael:

Yep, you will need to use the Timeseries access functions. check out the documentation.

.

Basically instead of using Time[] Close[] Open[] predefined variables etc.., you will use iTime() iClose() iOpen functions where you will specify which chart and timeframe to fetch it from.

.

Jon

how must this script looks with iTime() and so on?

thanks for help

 

it works but now i have the next problem


i get the alarm when i change the timeframe on the current Symbol()

this means i dont get the infromation from E/U when i have as current chart G/U


also i must change the timeframe to get any alert


int start()
{
string Cmnt = IndName;
if (Show_Remain_Bar_Time) Cmnt = Cmnt+"\n"+GetRemainingBarTime();
Comment(Cmnt);

static datetime prevtime = 0;
int shift;
int shift1;
int shift2;
double L, L1, H, H1;

if (Show_Daily_Open_Line)
{
int counted_bars = IndicatorCounted();
if (counted_bars > 0) counted_bars--;
int last_bar = Bars - counted_bars;
DrawDailyOpen(0, last_bar);
}
if (prevtime == Time[0]) return(0);

prevtime = Time[0];

for (shift = 0; shift < Bars; shift++)
{
shift1 = shift;
shift2 = shift + 1;

H = High[shift1];
H1 = High[shift2];
L = Low[shift1];
L1 = Low[shift2];

// Check IB's
if ((H <= H1) && (L >= L1))
{
if (Show_IB == true)
{
ib1[shift] = High[shift]; //Hochwert vom Innenbar
ib2[shift] = Low[shift]; // Tiefwert vom Innebar
ibPips[shift] = (ib1[shift] -ib2[shift])*MathPow(10,Digits);




}
}
}


if ( M1 == true ) {
if ( iHigh(NULL,PERIOD_M1,1) <= iHigh(NULL,PERIOD_M1,2) && iLow(NULL,PERIOD_M1,1) >= iLow(NULL,PERIOD_M1,2) ){

Alert("Innenbar " + Symbol() + " " + "M1");
Sleep(10000);
}
}



if ( M5 == true ) {
if ( iHigh(NULL,PERIOD_M5,1) <= iHigh(NULL,PERIOD_M5,2) && iLow(NULL,PERIOD_M5,1) >= iLow(NULL,PERIOD_M5,2) ){

Alert("Innenbar " + Symbol() + " M5");
Sleep(10000);
}
}


if ( M15 == true ) {
if ( iHigh(NULL,PERIOD_M15,1) <= iHigh(NULL,PERIOD_M15,2) && iLow(NULL,PERIOD_M15,1) >= iLow(NULL,PERIOD_M15,2) ){

Alert("Innenbar " + Symbol() + " " + " M30");
Sleep(10000);
}
}

if ( M30 == true ) {
if ( iHigh(NULL,PERIOD_M30,1) <= iHigh(NULL,PERIOD_M30,2) && iLow(NULL,PERIOD_M30,1) >= iLow(NULL,PERIOD_M30,2) ){

Alert("Innenbar " + Symbol() + " M30");
Sleep(10000);
}
}



return(0);
}