[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 160

 
wolf05632:

How to stop the execution of the indicator ...if proc_zahlest>100


int start()
{if(proc_zahlest>100)return(0);
...
return(0);}
 
wolf05632:

... And another question: what should the OBJ_TEXT time coordinate look like, so that the text is RIGHT of the zero candle?

datetime t=Time[0]+Shift*Period()*60;//Shift -- положительное целое число.
 
granit77:
Moved:

eurodollar1981 09.09.2011 10:37
Hello! Could you tell me how to prescribe in mt4, to buy an order with preset stoploss and take profit by pressing one key?


Two keys -- is it a lot? If -- no, you write an appropriate script whose execution is set to the "hotkey".

Terminal --> Navigator --> Scripts --> Your script --> Right-click --> Set hotkey.

 

Roger:

Xaoss1990:

Roger:
This is not the part of the code where there could be an error.
Em.... and the rest of the code is the calculation of values ( POINT_BUY_M15, POINT_BUY_H, POINT_BUY_H4, POINT_SELL_M15, POINT_SELL_H, POINT_SELL_H4 ) to make trades, it works correctly... I checked... it's simple there....
If the error was here, the log would say "Stop not set", but it's not.

The error lies exactly in that code. It closes BUY, then it selects an order which does not exist anymore and closes the intended SELL, which never existed in the first place. I think I have shown us the error. It will not be difficult to understand.

I started to study MQL in a textbook. There're enough examples in it and they're all intelligently constructed. Some of the constructions used in those examples I still use in my own developments.

 
MaxZ:

The error lies exactly in that code. It closes BUY, then it selects an order, which does not exist any more, and closes SELL, which never existed at all. I think I have shown the error. It will not be difficult to understand.

I started to study MQL in a textbook. There're enough examples in it and they're all intelligently constructed. I'm still using some of those examples in my developments.


Agreed. Recommended:
datetime OrderCloseTime( )
Returns the closing time for the selected order. Only closed orders have a closing time which is not 0. Open or pending orders have a close time equal to 0.
The order must be pre-selected using OrderSelect().
 
Roll:


Ugh... Thank you!
 

Guys, help me, I'm getting lost. I'm making an indicator that I want to output as text objects the information from various other indicators from different timeframes. For example ADX. I make three iADX:

 f0 = iADX(NULL,PERIOD_M30,14,PRICE_CLOSE,MODE_PLUSDI,0) - iADX(NULL,PERIOD_M30,14,PRICE_CLOSE,MODE_MINUSDI,0);
 f1 = iADX(NULL,PERIOD_H1,14,PRICE_CLOSE,MODE_PLUSDI,0) - iADX(NULL,PERIOD_H1,14,PRICE_CLOSE,MODE_MINUSDI,0); 
 f2 = iADX(NULL,PERIOD_H4,14,PRICE_CLOSE,MODE_PLUSDI,0) - iADX(NULL,PERIOD_H4,14,PRICE_CLOSE,MODE_MINUSDI,0); 

I test on H4, only one ADX, which is on H4, the other two give a constant value. Help please.

 
vitali_yv:

Guys, help me, I'm getting a bit confused. I'm making an indicator that I want to output as text objects the information from various other indicators from different timeframes. For example ADX. I make three iADX:

I test on H4, only one ADX, which is on H4, the other two give a constant value. Help please.


Try on M30 - if explicitly prescribed periods in the code, everything should work.
 
vitali_yv:

Guys, help me, I'm getting confused. I'm making an indicator that I want to output as text objects the information from various other indicators from different timeframes. For example ADX. I make three iADX:

I test on H4, only one ADX, which is on H4, the other two give a constant value. Please help.

I have a feeling I will not change my values.

Or you are outputting incorrectly, which only Misters Telepaths can know for sure...

 
MaxZ:

The error lies exactly in that code. It closes BUY, then it selects an order, which does not exist any more, and closes SELL, which never existed at all. I think I have shown the error. This cannot be difficult to understand.

Before closing an order, the EA checks the magic number of the order and it is different for buy and sell orders. So, one and the same order cannot be closed as both Buy and Sell.

Here is the code:

//+-----------------------------------------------------------------------------+
//+-------------------------СТАВИМ СПОП ЛОСС ДЛЯ BUY-------------+
//+-----------------------------------------------------------------------------+

OrderSelect(0, SELECT_BY_POS, MODE_TRADES);
Magic = OrderMagicNumber();

if (OrdersTotal() == 1 && Magic == 111 && OrderType( ) == 0)
{
if (POINT_BUY_M15 < Strgh_UP_M15 || POINT_BUY_H1 < Strgh_UP_H1 || POINT_BUY_H4 < Strgh_UP_H4)
{
close = 1;
}
}
if (close == 1)
{
OrderClose(OrderTicket(), lots, Bid, 5, Yellow);
}

//+-----------------------------------------------------------------------------+
//+-------------------------СТАВИМ СПОП ЛОСС ДЛЯ SELL-------------+
//+-----------------------------------------------------------------------------+

OrderSelect(0, SELECT_BY_POS, MODE_TRADES);
Magic = OrderMagicNumber();

if (OrdersTotal() == 1 && Magic == 222 && OrderType( ) == 1)
{
if (POINT_SELL_M15 < Strgh_DOWN_M15 || POINT_SELL_H1 < Strgh_DOWN_H1 || POINT_SELL_H4 < Strgh_DOWN_H4)
{
close = 1;
}
}
if (close == 1)
{
OrderClose(OrderTicket(), lots, Ask, 5, Red);
}

Reason: