MQL4 Learning - page 71

 

Finding the Highest or Lowest price since opening an order

Hello All,

I have been searching and trying ideas for most of this morning, could someone post a short script of how to find the highest high or lowest low in price for the current chart since opening an order.

I can obtain the open time using the OrderOpenTime() function so I then need to find the highest high/lowest low from that time until the present.

Previously I have used iHighest() to obtain the highest price from the last x number of bars, but I am unsure how I can use time to define this.

Thanks for any advice on this or a function I can use to simply achieve it. I guess the current time could be calculated using iTime() and then subtracting the OrderOpenTime() from this, before then calculating this in terms of a number of bars from the current bar, but that seems like an awfully complex method.

I have been programming a while and am happy with most concepts, but can't seem to figure out a simple solution here.

Thanks again for any replies from this excellent community,

Howard

 
 

I guess you can do it yourself. Replace all Close[shift+..] to Open[shift+..].

 

thank you

thank you..I am zero in programming but i kind of thought about it...seems logical...will give it a try...thanks again

 

one more & I am happy

This is Stochastic Syber Cycle...is it possible to make it work on Open of the bar?

//+------------------------------------------------------------------+

//| StochasticCyberCycle.mq4 |

//| |

//| Stochastic Cyber Cycle |

//| |

//| Algorithm taken from book |

//| "Cybernetics Analysis for Stock and Futures" |

//| by John F. Ehlers |

//| |

//| contact@mqlsoft.com |

//| EA Programming for MetaTrader | MQLsoft - [mql, programming, programmer, service, coding, mql4, ea, forex, trading, automated, metatrader, indicator, expert advisor, ea, strategy, ea programming, robot, custom indicators, algorithmic, professional, f |

//+------------------------------------------------------------------+

#property copyright "Coded by Witold Wozniak"

#property link "www.mqlsoft.com"

#property indicator_separate_window

#property indicator_buffers 2

#property indicator_color1 Red

#property indicator_color2 Blue

#property indicator_level1 0

#property indicator_minimum -1

#property indicator_maximum 1

double StocCC[];

double Trigger[];

double Smooth[];

double Cycle[];

double Value1[];

extern double Alpha = 0.07;

extern int Length = 8;

int buffers = 0;

int drawBegin = 0;

int init() {

drawBegin = Length;

initBuffer(StocCC, "Stochastic Cyber Cycle", DRAW_LINE);

initBuffer(Trigger, "Trigger", DRAW_LINE);

initBuffer(Smooth);

initBuffer(Cycle);

initBuffer(Value1);

IndicatorBuffers(buffers);

IndicatorShortName("Stochastic Cyber Cycle [" + DoubleToStr(Alpha, 2) + ", " + Length + "]");

return (0);

}

int start() {

if (Bars <= drawBegin) return (0);

int countedBars = IndicatorCounted();

if (countedBars < 0) return (-1);

if (countedBars > 0) countedBars--;

int s, limit = Bars - countedBars - 1;

for (s = limit; s >= 0; s--) {

Smooth[s] = (P(s) + 2.0 * P(s + 1) + 2.0 * P(s + 2) + P(s + 3)) / 6.0;

Cycle[s] = (1.0 - 0.5 * Alpha) * (1.0 - 0.5 * Alpha) * (Smooth[s] - 2.0 * Smooth[s + 1] + Smooth[s + 2])

+ 2.0 * (1.0 - Alpha) * Cycle[s + 1]

- (1.0 - Alpha) * (1.0 - Alpha) * Cycle[s + 2];

if (s > Bars - 8) {

Cycle[s] = (P(s) - 2.0 * P(s + 1) + P(s + 2)) / 4.0;

}

double hh = Cycle[s], ll = Cycle[s];

for (int i = 0; i < Length; i++) {

double tmp = Cycle[s + i];

hh = MathMax(hh, tmp);

ll = MathMin(ll, tmp);

}

Value1[s] = 0.0;

if (hh != ll) {

Value1[s] = (Cycle[s] - ll) / (hh - ll);

}

StocCC[s] = (4.0 * Value1[s] + 3.0 * Value1[s + 1] + 2.0 * Value1[s + 2] + Value1[s + 3]) / 10.0;

StocCC[s] = 2.0 * (StocCC[s] - 0.5);

Trigger[s] = 0.96 * (StocCC[s + 1] + 0.02);

}

return (0);

}

double P(int index) {

return ((High + Low) / 2.0);

}

void initBuffer(double array[], string label = "", int type = DRAW_NONE, int arrow = 0, int style = EMPTY, int width = EMPTY, color clr = CLR_NONE) {

SetIndexBuffer(buffers, array);

SetIndexLabel(buffers, label);

SetIndexEmptyValue(buffers, EMPTY_VALUE);

SetIndexDrawBegin(buffers, drawBegin);

SetIndexShift(buffers, 0);

SetIndexStyle(buffers, type, style, width);

SetIndexArrow(buffers, arrow);

buffers++;

}

 

Simple coding question .. plz help !!

Hello Folks;

Am trying to draw a circle in the background:

Tried the following code w/o success..

SetIndexBuffer(0,ExtUpFractalsBuffer);

SetIndexBuffer(1,ExtDownFractalsBuffer);

SetIndexStyle(0,DRAW_ARROW);

SetIndexArrow(0,161);

ObjectSet(0,OBJPROP_BACK,True);

Any ideas what I am doing wrong ??

Looked at the manual but nothing apprent jumps out ..

Thnx a bunch

 

Need to find the time/date of the last trade

Is there a function to return the time/date of the last trade?

I need to find the time of the last trade that was taken while discriminating based on magic number weather it is still open or has been closed.

If some one could point me to some code samples for something like this I would be grateful.

Thanks

Will

 

time left on current bar until a new one on MT4

Is there any indicator showing "time left on current bar until a new one on MT4"?

When I do some searches, nothing comes up do what i wanted.

Anyone has one?

thanks.

 

have you tried to search yet?

i belive you will find it

 

pip indicator

Hi, I am looking for just a simple pip to open indicator, nothing more than that. Like the signal indicator, but I don't need the other info just the pip part.

I tried to write one but just couldn't get it working and can't seem to find just this by itself. I'll take the string if someone has that and do the rest msyelf.

Thanks

Tom

Reason: