Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 1105
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
Who has it easy now... There are 5 more such topics about newbies in the archive ))))
To be honest, examples from help and codobase are enough if you already have programming experience, preferably in C++. If you don't have any experience at all, you may study a C++ tutorial first, MQL is very similar in syntax.
No experience = C++ tutorial; )))
Thank you for your help!
Good afternoon, Dear Sirs!
Please help me add an alert to the indicator when an arrowindicating a currency pair appears.
I tried it myself, but as they say, it's hard not to know and forget. Thanks in advance.
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 White
#property indicator_color2 White
#property indicator_color3 LightGreen
#property indicator_color4 Red
extern int CountBars = 300;
extern string FS = " ** Filter sensitivity: High <-[1..3]-> Low ** ";
extern int Sensitivity = 2;
double g_ibuf_92[];
double g_ibuf_96[];
double g_ibuf_100[];
double g_ibuf_104[];
int gi_unused_108 = -1;
int init() {
IndicatorBuffers(4);
SetIndexStyle(2, DRAW_ARROW);
SetIndexArrow(2, 233);
SetIndexBuffer(2, g_ibuf_92);
SetIndexStyle(3, DRAW_ARROW);
SetIndexArrow(3, 234);
SetIndexBuffer(3, g_ibuf_96);
SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 3, White);
SetIndexBuffer(0, g_ibuf_100);
SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, 3, White);
SetIndexBuffer(1, g_ibuf_104);
SetIndexEmptyValue(0, 0);
SetIndexEmptyValue(1, 0);
SetIndexEmptyValue(2, 0);
SetIndexEmptyValue(3, 0);
SetIndexLabel(2, "Buy Signal");
SetIndexLabel(3, "Sell Signal");
SetIndexLabel(0, "High");
SetIndexLabel(1, "Low");
SetIndexEmptyValue(0, EMPTY_VALUE);
SetIndexEmptyValue(1, EMPTY_VALUE);
SetIndexEmptyValue(2, EMPTY_VALUE);
SetIndexEmptyValue(3, EMPTY_VALUE);
string ls_0 = "Scalper Signal";
IndicatorShortName(ls_0);
if (Sensitivity < 1) Sensitivity = 1;
if (Sensitivity > 3) Sensitivity = 3;
return (0);
}
int deinit() {
return (0);
}
double sellSignal(int ai_0) {
bool li_4 = TRUE;
if (Sensitivity > 2)
if (iHigh(Symbol(), Period(), ai_0 + 6) >= iHigh(Symbol(), Period(), ai_0 + 5)) li_4 = FALSE;
if (Sensitivity > 1)
if (iHigh(Symbol(), Period(), ai_0 + 5) >= iHigh(Symbol(), Period(), ai_0 + 4)) li_4 = FALSE;
if (Sensitivity > 0)
if (iHigh(Symbol(), Period(), ai_0 + 4) >= iHigh(Symbol(), Period(), ai_0 + 3)) li_4 = FALSE;
if (li_4) {
if (iClose(Symbol(), Period(), ai_0 + 2) < iHigh(Symbol(), Period(), ai_0 + 3))
if (iClose(Symbol(), Period(), ai_0 + 1) < iLow(Symbol(), Period(), ai_0 + 3)) return (iHigh(Symbol(), Period(), ai_0 + 3) + 10.0 * Point)
}
return (0);
}
double buySignal(int ai_0) {
bool li_4 = TRUE;
if (Sensitivity > 2)
if (iLow(Symbol(), Period(), ai_0 + 6) <= iLow(Symbol(), Period(), ai_0 + 5)) li_4 = FALSE;
if (Sensitivity > 1)
if (iLow(Symbol(), Period(), ai_0 + 5) <= iLow(Symbol(), Period(), ai_0 + 4)) li_4 = FALSE;
if (Sensitivity > 0)
if (iLow(Symbol(), Period(), ai_0 + 4) <= iLow(Symbol(), Period(), ai_0 + 3)) li_4 = FALSE;
if (li_4) {
if (iClose(Symbol(), Period(), ai_0 + 2) > iLow(Symbol(), Period(), ai_0 + 3))
if (iClose(Symbol(), Period(), ai_0 + 1) > iHigh(Symbol(), Period(), ai_0 + 3)) return (iLow(Symbol(), Period(), ai_0 + 3) - 10.0 * Point)
}
return (0);
}
int start() {
int li_0 = IndicatorCounted();
if (li_0 < 0) return (-1);
if (li_0 > 0) li_0--;
int li_4 = Bars - li_0;
for (int l_count_8 = 0; l_count_8 < li_4; l_count_8++) {
g_ibuf_92[l_count_8 + 3] = buySignal(l_count_8);
g_ibuf_96[l_count_8 + 3] = sellSignal(l_count_8);
if (buySignal(l_count_8) > 0.0 || sellSignal(l_count_8) > 0.0) {
g_ibuf_100[l_count_8 + 3] = iHigh(Symbol(), Period(), l_count_8 + 3);
g_ibuf_104[l_count_8 + 3] = iLow(Symbol(), Period(), l_count_8 + 3);
}
}
return (0);
}
Hello diggers.
I'm getting a little crooked with the order history result.
Strategy:
1-Open 2 orders in different direction (lock in fact) with a short stop and a long profit.
If the price moves steadily out of the range, it will knock down the stop of one of the orders, and go for a long profit on the other order.
3 - When the stop of one of the orders is hit, a pending order is placed at the level of its opening, and if the price comes back, the order is opened again
and we return to the position state until the next move to the profit through the knock-out of the short stop.
Objective:
To trace 3 stop knock outs, for on the 4th order, Martin is triggered. The problem is that something goes wrong. I determine the order profitability by OrderProfit() history,
But I still do not understand how OrdersHistoryTotal() works. Does the function check the order number or the order quantity?
In the same way, I do not understand how it interprets deleting a position (either as a loss or as nothing at all). How can I trace 3 consecutive losses in a situation like this when the history shows a lot of other things besides losses?
Hello diggers.
I'm getting a little crooked with the order history result.
Strategy:
1-Open 2 orders in different direction (lock in fact) with a short stop and a long profit.
If the price moves steadily out of the range, it will knock down the stop of one of the orders, and go for a long profit on the other order.
3 - When the stop of one of the orders is hit, a pending order is placed at the level of its opening, and if the price comes back, the order is opened again
and return to the state of a lock before the next move to the profit through the knock-out of a short stop.
Objective:
To trace 3 stop knock outs, for on the 4th order, Martin is triggered. The problem is that something goes wrong. I determine the order profitability by OrderProfit() history,
But I still do not understand how OrdersHistoryTotal() works. Does the function check the order number or the order quantity?
In the same way, I do not understand how it interprets deleting a pending order (either as a loss or as nothing at all). How should I trace 3 consequent losses in a situation like this when the history shows a lot of other information besides losses?
The first thing to remember is that a pending order is not a loss-making one; it has either triggered or has been deleted.
The loss should be seen on market orders (Buy, Sell).
OrdersHistoryTotal() returns the amount of orders in the available trading history (including depositing and withdrawing from the account, if the mode "entire history" is displayed). The number 0 is usually the first deposit, that is, the first order; the number OrdersHistoryTotal()-1 is the last order in the history.
This means that we have to loop through the orders from the last to the first, at the same time counting the pending and losing orders.
But why place pending orders at all if we can always wait until the price reaches the level of the order closed at the stop and open the order at once according to the market? Limit orders are an unnecessary link in this case as they confuse the account.
1-Open 2 orders in different directions (actual lock) with a short stop and a long profit.
2-If the price moves steadily out of the range, it will knock down the stop of one of the orders, and go for a long profit on the other order.
I looked at your strategy through the programmer's eyes. When the price goes up, it reaches the Sell SL, so there is one Buy order with its SL and somewhere up there TP. In this case you have managed to get a small loss on the closed order. Now let's consider the variant with two pending orders. Instead of opening two orders, let's place two pending orders on the very places where you have SL. When the price reaches Buy Stopl, a buy order is opened and we have the same position, but there is no loss. And now the most interesting thing. As the price moves up ...
...And as the price moved up on your principle, your TP got further away. And you have less chance of taking a profit than I do, if you consider our actions in the moment.
And even if I don't trade in parallel with you, your TP is between the pips, and mine is in fact. And it will be always - you give the market a part of directional movement.
If you do not know, then you should consider that even an unfortunate 2 points of spread turns a positive system into a losing one. Judging by the first figure, you have a spread of about 20 pips on a 5-digit spread,
because the difference between simultaneously placed orders "by eye" is 40 pips according to the figure.
That's not the point...you need a code snippet, the correct detection of a series of 3 knocked out stops. Why is everyone trying to correct the system? And the methodology of the aforementioned comrade
won't work either. The market may simply not let you open, or open where you shouldn't. Man, I understand all of you guys, and your desire to share your experiences. But I just need to trace three stops.
Everything's in place, just happened to see that I missed the wrong order with doubling. As it turned out, Histototal gave out whatever it saw fit, and the loop of determining a closed order by loss from history missed the order.
You need to move away from coder qualifications and learn the basics of programming. Here's more details... And here.
Here's the problem. What returns, as the author puts it, Histototal in this script on the same account on Sunday.
Why different?
If there are less and more orders in one account, then 0 228 228 216 98? And if there are fewer orders, the processing is faster!
The client is sweating - it's impossible to work, the terminal is glitchy, Histototal gave out what it wanted, the loop skipped it !
Good afternoon everyone. Help me raise the arrows in the indicator, the lower ones are ok, but the upper ones are on top of candlesticks.
I tried ObjectSet(Arrow_name_jack1, OBJPROP_YDISTANCE,20); it didn't work. The anchor point of the arrow (object) is at the top, how do I move it up?
Good afternoon everyone. Help me raise the arrows in the indicator, the lower ones are ok, but the upper ones are on top of candlesticks.
I tried ObjectSet(Arrow_name_jack1, OBJPROP_YDISTANCE,20); it didn't work. The anchor point of the arrow (object) is at the top, how to move it up?
ObjectSetInteger(0,Arrow_name_jack1,OBJPROP_ANCHOR,ANCHOR_BOTTOM);
I recommend using separate variables to store the names of top and bottom arrows, to avoid confusion.
And yes, drawing arrows in the indicator with objects is a perversion. There are indicator buffers:
SetIndexStyle(0,DRAW_ARROW,0,1,clrRed);
SetIndexArrow(0,242);
ObjectSetInteger(0,Arrow_name_jack1,OBJPROP_ANCHOR,ANCHOR_BOTTOM);
I recommend using separate variables to store the names of upper and lower arrows, to avoid confusion.
And yes, drawing arrows in the indicator with objects is a perversion. There are indicator buffers.
Thanks, it all works.
Willindicator buffers stay if indicator signal conditions are already missing? (old arrows should not disappear when redrawing))