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

 
Shniperson:

Hello! Can you tell me how to "loop" the up/down bar check? That is, how can I describe this condition "shorter"?

Close[0]>Open[0]&& Close[1]>Open[1]&& Close[2]>Open[2]&& Close[3]>Open[3]&&& Close[4]>Open[4]&& Close[5]>Open[5]&& Close[6]>Open[6]&& Close[7]>Open[7]

bool Res=true;
for(int i=0;i<8;i++) Res = Res && Close[i]>Open[i];

Thanks in advance.


You could do that, but it's not likely to be quicker. The conditions need to be broadened a little
 

I don't know how to turn this into a life, can I do that?

My strategy is ideally manually opened at 8:00 on the terminal, if profit, then until the next day. If profit goes not in my direction, then at loss I reverse position + - no matter what, I don't open more positions this day and wait till 8 o'clock in the morning. I.e. there should be a maximum of two orders and no more. If we didn't reach profit, but the Trawl moved to Breakeven, we also rollover. Of course, we can handle everything, but our work does not allow us to monitor positions. It would be better to place an order and let the EA follow the position. I attached RSI just to test it in the Strategy Tester.

This is all I needed.

extern int Hour_To_Open = 08; //час открытия (-1 - не задано), терминальное время
extern int Minute_To_Open = 00; //минута открытия (-1 - не задано), терминальное время
extern double TakeProfit = 50;
extern double StopLoss = 30;
extern double Lot = 0.1;
extern int MagicNumber = 655433;


//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
if((Hour()==Hour_To_Open) && (Minute()==Minute_To_Open)) 
{ //если настало время открытия сделок
int total = OrdersTotal();
for (int i = 0; i < total; i++) 
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
{
return(0);
}
} 
int ticket=1;
if(iRSI(NULL,0,14,PRICE_CLOSE,0)>iRSI(NULL,0,14,PR ICE_CLOSE,1))
{
ticket=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,Bid - StopLoss * Point,Bid + TakeProfit * Point,"My order #",MagicNumber,0,Blue);
if(ticket<0)
{
Sleep(30000);
}
}
else
{
ticket=OrderSend(Symbol(),OP_SELL,Lot,Bid,3,Ask + StopLoss * Point,Ask - TakeProfit * Point,"My order #",MagicNumber,0,Red);
if(ticket<0)
{
Sleep(30000);
}
}
} //end if((Hour()==Hour_To_Open) && (Minute()==Minute_To_Open))
//----
return(0);
}
//+------------------------------------------------------------------+

I have this trailing stop, I took it from another EA but it does not work for me

extern bool UseTrailing = true; //включение/выключение T-SL
extern int TrailingStop = 50; // Фиксированный размер трала
extern int TrailingStep = 1; // Шаг трала

//+-------------------------------------------------------------------------------------------------------------------+
//| трейлинг стоп лосс |
void T_SL() {
int i=0;
for(i=0; i<OrdersTotal(); i++) {
if(!(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))) continue;
if(OrderSymbol() != Symbol()) continue; 

if(OrderType()==OP_BUY) {
if(NormalizeDouble(Bid-OrderOpenPrice(),Digits)>NormalizeDouble(TrailingS top*Point,Digits)) {
if(NormalizeDouble(OrderStopLoss(),Digits)<Normali zeDouble(Bid-(TrailingStop+TrailingStep-1)*Point,Digits))
OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Bid-TrailingStop*Point,Digits), OrderTakeProfit(), 0, CLR_NONE);
} //end if(NormalizeDouble(Bid-OrderOpenPrice(),Digits)>NormalizeDouble(TrailingS top*Point,Digits))
} //end if(OrderType()==OP_BUY)

if(OrderType()==OP_SELL) {
if(NormalizeDouble(OrderOpenPrice()-Ask,Digits)>NormalizeDouble(TrailingStop*Point,Dig its)) {
if(NormalizeDouble(OrderStopLoss(),Digits)>Normali zeDouble(Ask+(TrailingStop+TrailingStep-1)*Point,Digits))
OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Ask+TrailingStop*Point,Digits), OrderTakeProfit(), 0, CLR_NONE);
} //end if(NormalizeDouble(OrderOpenPrice()-Ask,Digits)>NormalizeDouble(TrailingStop*Point,Dig its))
} //end if(OrderType()==OP_SELL)
} //end for(i=0; i<OrdersTotal(); i++)
} //end void T_SL()
//| трейлинг стоп лосс |
//+-------------------------------------------------------------------------------------------------------------------+

How do I attach it? And reversal, it should work only once after the position is opened

 

Reverse must be looking for somewhere around here, I take it or not?

bool OrderCloseBy(int ticket, int opposite, color Color=CLR_NONE)
Closing one open position with another position opened on the same instrument, but in opposite direction. Returns TRUE on successful completion of the function. Returns FALSE when the function fails. To get information about the error, call the GetLastError() function.
Parameters:
ticket - Unique serial number of the order to be closed.
opposite - The unique sequence number of the opposite order.
Color - Colour of the closing arrow on the chart. If the parameter is missing or its value is CLR_NONE, the arrow is not shown on the chart.
Example:
 if(iRSI(NULL,0,14,PRICE_CLOSE,0)>75) { OrderCloseBy(order_id,opposite_id); return(0); }

 
Mr. Professionals, could you tell me if it's possible to run a script from the toolbar? At the moment, the written script has to be run either from the navigator, or with a preset combination of keys (which for some reason works only once in a while). Question - can I, for example, assign a new function to the icon in the "graphical tools" panel and run the script from the toolbar? Maybe there are other options?
 

Good afternoon.

Can you tell me where I can see the original code for the OrderSend() function ?

Thanks in advance.

 
kon12:
Mr. Expert, advise, is it possible to run the script from the toolbar? At the moment, the script has to be run either from the navigator, or using a preset combination of keys (which somehow works only once). Question - is it possible, for example, to assign a new function to the icon on the "graphical tools" panel and run the script from the toolbar? Are there any other options?

No, but you can use drag and drop of Label object as an example ...

Download , extract to terminal with replacement, allow import of dll in terminal setup, attached Expert Advisor to Experts, enter name of script to be launched restart terminal or compile.

The Expert Advisor implements - loads the script on the specified chart by its name when dragging the object on the chart.

      ServiceLoadScript(WindowHandle(Symbol(), Period()), "ZZ_All_Quotings 4.10425", /*<---- Имя загружаемого скрипта.*/  false);
Files:
trade_1.mq4  2 kb
 

Good afternoon!!!

Please advise. I am writing an EA that works on channel break, putting two pending ones behind the channel. When one of them triggers, the other should be deleted. How to implement it in the code?

 
Parn25:

Good afternoon!!!

Please advise. I am writing an EA that works on channel break, putting two pending ones behind the channel. When one of them triggers, the other should be deleted. How to implement it in the code?


Perhaps this would be a good idea - I haven't done that myself - if your EA allows only one market order (out of 2 pending ones that were previously placed), then monitor (track) the availability of your (by magician) order (market) in the market and as soon as it shows up, delete the pending one. That is all. If you want to delete a pending order, google something like "delete orders site:mql4.com".
 

Hello!

Running the EA on the tester. The server is four digits. When placing buy or sell order in the log says

2011.10.23 15:27:26 2010.12.16 06:16 test_sovetnik GBPUSD,H1: open #1 buy 0.10 GBPUSD at 1.5551 sl: 1.4551 tp: 1.5586 ok

But opens at 1.55512 ! At the five digits. Then the pending orders are placed at four digits and triggered at four digits as well. But OP_SELL and OP_BUY open only by five digits!

I do NormalizeDouble(Ask,Digits);

Nothing works! Please advise how to solve this issue?

You can, of course, ignore the last digit. The error doesn't occur, but for the sake of purity of the experiment, I need all my trades to be made in four digits.

 
ZZZEROXXX:
Please advise how to fix an EA, e.g. standard Moving Averages, to turn it into a script in order to run it on a non-standard timeframe.


UP. i would appreciate it if you could tell me how to turn an EA into a script in a nutshell