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
ican use lwma so if i want the period to be 30 in hull what mv should i put in the chart two ma or just one with howmuch period iam not good at math and thanks very very very much man on your effort
zoroxzyad
You can not use just moving average. You must use the formula from the post before
Any manual for new metatrader 4 yet?
Or will they ever make one?
Any manual for new metatrader 4 yet? Or will they ever make one?
Not that I know of. I suppose there will be some (at some point of development)
Mladen, attached is an indicator you modified to display crossover signals on the main chart.
This code is from the new version--
arrDn[CB] = EMPTY_VALUE;
state[CB] = state[CB+1];
if (TrendBuffer[CB]>LoBuffer[CB]) state[CB] = 1;
if (TrendBuffer[CB]<LoBuffer[CB]) state[CB] = -1;
if (state[CB]!=state[CB+1])
{
if (state[CB]== 1) arrUp[CB] = Low[CB] -iATR(NULL,0,10,CB)/2.0;
if (state[CB]==-1) arrDn[CB] = High[CB]+iATR(NULL,0,10,CB)/2.0;
}Is there an easy way to explain how this code inserts the signals?
Thank you.
Mladen, attached is an indicator you modified to display crossover signals on the main chart.
This code is from the new version--
arrDn[CB] = EMPTY_VALUE;
state[CB] = state[CB+1];
if (TrendBuffer[CB]>LoBuffer[CB]) state[CB] = 1;
if (TrendBuffer[CB]<LoBuffer[CB]) state[CB] = -1;
if (state[CB]!=state[CB+1])
{
if (state[CB]== 1) arrUp[CB] = Low[CB] -iATR(NULL,0,10,CB)/2.0;
if (state[CB]==-1) arrDn[CB] = High[CB]+iATR(NULL,0,10,CB)/2.0;
}Is there an easy way to explain how this code inserts the signals?
Thank you.Michael
It is looking for a crosses of values in two buffers : TrendBuffer and LoBuffer. It marks what is the current state of the two : if TrendBuffer > LoBuffer it sets the state to 1 and if TrendBuffer < LoBuffer it sets the state to -1.
Now, when the state of the current bar is different then the state of the previous bar, it means that there is a cross. And then it draws and arrow on chart
Also troublesome teacher again, please put this indicator converted into MT4 indicators, thank you!
colorbars_hlc.mq5
Michael
It is looking for a crosses of values in two buffers : TrendBuffer and LoBuffer. It marks what is the current state of the two : if TrendBuffer > LoBuffer it sets the state to 1 and if TrendBuffer < LoBuffer it sets the state to -1.
Now, when the state of the current bar is different then the state of the previous bar, it means that there is a cross. And then it draws and arrow on chartOK, that explains TrendBuffer and LoBuffer.
But how do arrUp and arrDn work?
Why do the signals appear on certain candles, and not every candle.
Thanks again.
OK, that explains TrendBuffer and LoBuffer.
But how do arrUp and arrDn work?
Why do the signals appear on certain candles, and not every candle.
Thanks again.michael
imagine a sequence like this (1 when TrendBuffer > LoBuffer, -1 when TrendBuffer < LoBuffer)
11111111-1-1-1-1-1-1-1-111111111
Arrows have to be drawn only when 1 becomes -1 or when -1 becomes 1 (when the "state" changes). That is why there is a line that is checking that (this line : if (state[CB] !=state[CB+1]) ). So, when the state changes, the arrow is draw otherwise the arrow does not need to be drawn at all
Hey mladen,
hope you have time so near the end of the year.
The code below has relation to the last asked question of me. It trails 0.8 pips for one order after the aim of 2 pips in plus.
But how can I change it so it checks all orders and trails for them individually?
Thank you very much! Great work you do here.
int start()
{
//----
if (OrdersTotal() == 0) {
isStopLoss = false;
}
for(int i=0; i<=OrdersTotal(); i++) {
if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) {
continue;
}
if(OrdersTotal() == 0) {
continue;
}
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(isStopLoss == true) {
if(OrderType() == OP_BUY) {
if(iClose(Symbol(), 0, 0) >= (OrderOpenPrice()+inProfitStopLoss*Point)) { // Zieht bei 2.0 Pips nach! - 200 = 2.0 Pips
if(isTrailing == true) {
if(iClose(Symbol(), 0, 0) >= (lastStopLoss+trailingStop)) {
OrderModify(OrderTicket(), OrderOpenPrice(), (lastStopLoss+trailingStop), 0,0,0);
lastStopLoss = OrderStopLoss();
//isTrailing = true;
continue;
}
}
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+inProfitStopLoss*Point,0,0,0);
if(OrderStopLoss() >= OrderOpenPrice()) {
isTrailing = true;
}
lastStopLoss = OrderStopLoss();
}
} else if(OrderType() == OP_SELL) {
if(iClose(Symbol(), 0, 0) <= (OrderOpenPrice()-inProfitStopLoss*Point)) {
if(isTrailing == true) {
if(iClose(Symbol(), 0, 0) <= (lastStopLoss-trailingStop)) {
OrderModify(OrderTicket(), OrderOpenPrice(), (lastStopLoss-trailingStop), 0,0,0);
lastStopLoss = OrderStopLoss();
//isTrailing = true;
continue;
}
}
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-inProfitStopLoss*Point,0,0,0); // 200 ursprünglich
if(OrderStopLoss() <= OrderOpenPrice()) {
isTrailing = true;
}
lastStopLoss = OrderStopLoss();
}
}
lastStopLoss = OrderStopLoss();
continue;
}
if(OrderType() == OP_BUY) {
isStopLoss = true;
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-initialStopLoss*Point,0,0,0);
} else if(OrderType() == OP_SELL) {
isStopLoss = true;
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+initialStopLoss*Point,0,0,0);
}
lastStopLoss = OrderStopLoss();
}
//----
return(0);
}Hey mladen,
hope you have time so near the end of the year.
The code below has relation to the last asked question of me. It trails 0.8 pips for one order after the aim of 2 pips in plus.
But how can I change it so it checks all orders and trails for them individually?
Thank you very much! Great work you do here.
int start()
{
//----
if (OrdersTotal() == 0) {
isStopLoss = false;
}
for(int i=0; i<=OrdersTotal(); i++) {
if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) {
continue;
}
if(OrdersTotal() == 0) {
continue;
}
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(isStopLoss == true) {
if(OrderType() == OP_BUY) {
if(iClose(Symbol(), 0, 0) >= (OrderOpenPrice()+inProfitStopLoss*Point)) { // Zieht bei 2.0 Pips nach! - 200 = 2.0 Pips
if(isTrailing == true) {
if(iClose(Symbol(), 0, 0) >= (lastStopLoss+trailingStop)) {
OrderModify(OrderTicket(), OrderOpenPrice(), (lastStopLoss+trailingStop), 0,0,0);
lastStopLoss = OrderStopLoss();
//isTrailing = true;
continue;
}
}
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+inProfitStopLoss*Point,0,0,0);
if(OrderStopLoss() >= OrderOpenPrice()) {
isTrailing = true;
}
lastStopLoss = OrderStopLoss();
}
} else if(OrderType() == OP_SELL) {
if(iClose(Symbol(), 0, 0) <= (OrderOpenPrice()-inProfitStopLoss*Point)) {
if(isTrailing == true) {
if(iClose(Symbol(), 0, 0) <= (lastStopLoss-trailingStop)) {
OrderModify(OrderTicket(), OrderOpenPrice(), (lastStopLoss-trailingStop), 0,0,0);
lastStopLoss = OrderStopLoss();
//isTrailing = true;
continue;
}
}
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-inProfitStopLoss*Point,0,0,0); // 200 ursprünglich
if(OrderStopLoss() <= OrderOpenPrice()) {
isTrailing = true;
}
lastStopLoss = OrderStopLoss();
}
}
lastStopLoss = OrderStopLoss();
continue;
}
if(OrderType() == OP_BUY) {
isStopLoss = true;
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-initialStopLoss*Point,0,0,0);
} else if(OrderType() == OP_SELL) {
isStopLoss = true;
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+initialStopLoss*Point,0,0,0);
}
lastStopLoss = OrderStopLoss();
}
//----
return(0);
}arroganzmaschine
Check the way how trailing stops are managed in the EA from this post : https://www.mql5.com/en/forum/181334 . I think it can help you since it has all the elements (including error checking) that are needed to handle trailing stop loss