Please use the source button.
iLowest gives you the shift to the required bar. you can use this shift to get the time reference for your arrow. I don't want to re do all your code but hopefully the following will give you the idea...
int lowshift=iLowest(NULL,0,MODE_OPEN,CntBars,0); double Minimum=Open[lowshift]; // Minimal price datetime lowtime=Time[lowshift]; // Other code --- ObjectCreate("DnSymbolA", OBJ_ARROW, 0, lowtime,Minimum);
I haven't tested it, but I think that would get the job done
V
Please use the source button.
iLowest gives you the shift to the required bar. you can use this shift to get the time reference for your arrow. I don't want to re do all your code but hopefully the following will give you the idea...
I haven't tested it, but I think that would get the job done
V
Thanks! Viffer! Worked like a charm!
Here's the ammend code:
//--------------------------------------------------------------------
// extremumprice.mq4
// The code should be used for educational purpose only.
//--------------------------------------------------------------------
extern int CntBars=30; // Amount of bars
ObjectsDeleteAll();
//--------------------------------------------------------------------
int start() // Special funct. start()
{
int i, n, m; // Bar number
int lowshift=iLowest(NULL,0,MODE_OPEN,CntBars,0);
double Minimum=Open[lowshift]; // Minimal price
datetime lowtime=Time[lowshift];
int maxshift=iHighest(NULL,0,MODE_OPEN,CntBars,0);
double Maximum=Open[maxshift]; // Minimal price
datetime maxtime=Time[maxshift];
for(i=0;i<CntBars-1;i++) // From zero (!) to..
{ // ..Quant_Bars-1 (!)
if (Low[i]< Minimum) // If < than known
{Minimum=Low[i]; n = i; // it will be min
ObjectCreate("UpSymbolA", OBJ_ARROW, 0, lowtime,Minimum);
//ObjectCreate("UpSymbolA", OBJ_ARROW, 0, Time[0],Minimum); //draw an up arrow
ObjectSet("UpSymbolA", OBJPROP_ARROWCODE, SYMBOL_ARROWUP);
ObjectSet("UpSymbolA", OBJPROP_COLOR,Lime);
}
if (High[i]> Maximum) // If > than known
{Maximum=High[i]; m = i; // it will be max
ObjectCreate("DnSymbolA", OBJ_ARROW, 0, maxtime,Maximum);
//ObjectCreate("DnSymbolA",OBJ_ARROW, 0, Time[0], Maximum); //draw a dn arrow
ObjectSet("DnSymbolA", OBJPROP_ARROWCODE, SYMBOL_ARROWDOWN);
ObjectSet("DnSymbolA", OBJPROP_COLOR,Red);
}
}
Alert("For the last ",CntBars," bars Min = ",DoubleToStr(Minimum,Digits)," at Bar # ",n," Max = ",DoubleToStr(Maximum,Digits)," at Bar # ",m);
return; // Exit start()
}
//--------------------------------------------------------------------
Is it possible to mark past bars with and arrow, rather than current, to identify highs and lows, at the actual bar where they occured,

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Is it possible to mark past bars with and arrow, rather than current, to identify highs and lows, at the actual bar where they occured, for a specified number of past bars?
example:
//--------------------------------------------------------------------
// extremumprice.mq4
// The code should be used for educational purpose only.
//--------------------------------------------------------------------
extern int CntBars=30; // Amount of bars
ObjectsDeleteAll();
//--------------------------------------------------------------------
int start() // Special funct. start()
{
int i, n, m; // Bar number
double Minimum=Open[iLowest(NULL,0,MODE_OPEN,CntBars,0)], // Minimal price
Maximum=Open[iHighest(NULL,0,MODE_OPEN,CntBars,0)]; // Maximal price
for(i=0;i<CntBars-1;i++) // From zero (!) to..
{ // ..Quant_Bars-1 (!)
if (Low[i]< Minimum) // If < than known
{Minimum=Low[i]; n = i; // it will be min
ObjectCreate("UpSymbolA", OBJ_ARROW, 0, Time[0],Minimum); //draw an up arrow
ObjectSet("UpSymbolA", OBJPROP_ARROWCODE, SYMBOL_ARROWUP);
ObjectSet("UpSymbolA", OBJPROP_COLOR,Lime);
}
if (High[i]> Maximum) // If > than known
{Maximum=High[i]; m = i; // it will be max
ObjectCreate("DnSymbolA",OBJ_ARROW, 0, Time[0], Maximum); //draw a dn arrow
ObjectSet("DnSymbolA", OBJPROP_ARROWCODE, SYMBOL_ARROWDOWN);
ObjectSet("DnSymbolA", OBJPROP_COLOR,Red);
}
}
Alert("For the last ",CntBars," bars Min = ",DoubleToStr(Minimum,Digits)," at Bar # ",n," Max = ",DoubleToStr(Maximum,Digits)," at Bar # ",m);
return; // Exit start()
}
//--------------------------------------------------------------------
Thanks!