[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 191

 
solnce600:

Thank you very much for your help.

But opens trades in the tester on every minute candle. Info. in this link http://clip2net.com/s/2T98Y

I want it to open one order on 5 min. candle, but not on every candle.

And only if the current five-minute candlestick is > or = 30 points (from the opening price to its maximum)

I.e., open one market order at the thirtieth pip from the opening price of the zero=current five-minute period.

If the current five-minute candlestick is less than 30 pips from the open price to its maximum, then do not open a market order.

Just drop the EA on the five-minute chart, it will be as you wrote.

Or substitute everywhere in the code Open[0] for iOpen(Symbol (), PERIOD_M5, 0), then it will work from any chart.

The second condition in your code is that the closing price of the current five-minute period >= opening price of the order.

No, Close[0] is the current closing price of bar 0, i.e. just the current price. You could have just written Bid, the result is the same.


I.e., there won't be a lot of orders, I have calculated in Excel, since 1999 - a little more than 3000 orders for euro in both directions.

We go to the next five-minute and if it, i.e. the current five-minute > or = 30 pips, we open at the thirtieth pips, if less, we go to the next five-minute ... and so on to the end of the chart.

But the thing is, by a rough estimate, most of the five-minute plans that > or = 30 pips are much more likely to fly past 15 pips than to close at the 30 pips stop.

You have a condition - if there are no open orders

But in my system, two five-minute periods with the parameters described above may be formed in a row and if the order from the previous Five-Minute period is not closed, then no order will be opened at the second Five-Minute period.

I need one order to be opened at every five-minute period with the parameters described above, irrespective of whether there are any orders in the trade or not.

Okay, then let us change the condition. So it comes out:

int start()

{

 double Price=iOpen (Symbol (),PERIOD_M5,0)+300*Point;        
 double SL=NormalizeDouble (Price-300*Point, Digits);         
 double TP=NormalizeDouble (Price+150*Point, Digits);    
 
 int last_order_bar = 0;
 int ot = OrdersTotal();

 if (ot>0) //если есть ордера в рынке
 {
   if (OrderSelect (ot-1,SELECT_BY_POS)) //выбрали последний ордер
      if (OrderType ()==OP_BUY || OrderType ()==OP_SELL) //проверили тип
         last_order_bar = iBarShift (Symbol (),PERIOD_M5,OrderOpenTime ()); //запомнили, на каком 5-минутном баре открыт последний ордер (если он есть)
 }
 
 if (OrdesTotal()==0 || last_order_bar>0) //если ордеров нет либо последний открыт не на текущем баре
    if (Bid>=Price)                       //если текущая цена доползла до цены открытия
       int Ticket=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,SL,TP );

}
 
beginner:
I'm interested in the advisor, the objects - do I draw the candle myself?

You can understand the principle:

//IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII+
//|  Автор : TarasBY, taras_bulba@tut.by                                              |
//+-----------------------------------------------------------------------------------+
//|        Рисуем на чарте бары                                                       |
//IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII+
void fDraw_Bars (string fs_Pref,          // Префикс имени объекта
                 int fi_NUMPeriod,        // Индекс (номер) периода, на котором будет виден объект
                 bool fb_IsNullBar,       // флаг рисования 0-го бара
                 double ar_Price[][][4])  // Массив с ценами
{
    int      li_widht = 6;
    string   ls_Name;
    color    lc_color = Aqua;
    datetime ldt_Time;
//----
    //---- Определяем время текущей свечи (её место в истории)
    if (fb_IsNullBar) {ldt_Time = Time[0];}
    else {ldt_Time = Time[1];}
    //---- Рисуем свечу
    ls_Name = StringConcatenate (fs_Pref, "_Candle_", TimeToStr (ldt_Time));
    if (ar_Price[0][1][3] < ar_Price[0][1][0]) {lc_color = Red;} else {if (ar_Price[0][1][3] == ar_Price[0][1][0]) {li_widht = 8;} else {lc_color = Blue;}}
    fDraw_OBJ (ls_Name, OBJ_TREND, ldt_Time, ar_Price[0][1][3], ar_Price[0][1][0], lc_color, li_widht, fi_NUMPeriod, "", 0, 10, "Arial", 0);
    //---- Рисуем тени свечи
    ls_Name = StringConcatenate (fs_Pref, "_Shadow_", TimeToStr (ldt_Time));
    if (ar_Price[0][1][3] <= ar_Price[0][1][0]) {lc_color = Gold;} else {lc_color = DeepSkyBlue;}
    fDraw_OBJ (ls_Name, OBJ_TREND, ldt_Time, ar_Price[0][1][1], ar_Price[0][1][2], lc_color, 1, fi_NUMPeriod, "", 0, 10, "Arial", 0);
//---- 
}
//IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII+
 
Diubakin:
Have you looked at the test EA for the function in the tester? It closes exactly the max. loss with max. profit no matter how many orders there are - two or twenty.
For now the question about the function is left open because I will paste some more functions into your test EA tomorrow to make a pure experiment. I have watched it in visual mode and almost all double closes are the last, the earlier one closes at SL and TP, i.e. I have nothing to choose from. I have removed Stops and Takes in order to have something to choose from. Tomorrow I will show your Expert Advisor with all additional functions and comments! You will be able to see for yourself how the function works. I really want it to show that I was wrong! If I am right, I will try to do my best! See you tomorrow!
 
alsu:

Just leave your EA on a five-minute chart, it will be like you wrote.

Or replace Open[0] with iOpen(Symbol (), PERIOD_M5, 0) everywhere in the code, then it will work from any chart.

No, Close[0] is the current close price of bar 0, i.e. just the current price. You could just write Bid, the result is the same.


OK, then let's change the condition. It comes out:




Thank you very much for your help. It's OK. But......

1. On some five minutes, more than 1 order opens.

2. Some orders are closed on stop orders whose price is different from the one prescribed in the code.

I have marked order data in the attached file.

 
alsu:

Just throw the Expert Advisor on the five-minute chart, it will be as you wrote.

Or replace Open[0] with iOpen(Symbol (), PERIOD_M5, 0) everywhere in the code, then it will work from any chart.

No, Close[0] is the current close price of bar 0, i.e. just the current price. You could just write Bid, the result is the same.


OK, then let's change the condition. It comes out:




Thank you very much for your help. It's OK. But......

1. On some five minutes, more than 1 order opens.

2. some orders are closed by stop orders whose price is different from the one prescribed in the code.

Information aboutthe above orders can be found in this link

http://clip2net.com/s/2Tfym

 

I'm sorry . please help. i'm copying a program with some changes. the compiler gives me an error: '(' - function definition unexpected F:\forex\MetaTrader NordFX\experts\ia.mq4 (305, 16) .

what does it mean?

- I tried to remove this piece of the program - it also says the following.

- tried to leave this part unchanged - the result is the same (same error)

on the native program compiled successfully.

 
TarasBY:

The principle can be understood:



Thank you!
 
lopuh:

I'm sorry. please help. i'm copying a program with some changes. the compiler gives me an error: '(' - function definition unexpected F:\forex\MetaTrader NordFX\experts\ia.mq4 (305, 16) .

what does it mean?

- I tried to remove this piece of the program - it also says the following.

- tried to leave this part unchanged - the result is the same (same error)

on the native program compiled successfully.

Over here

The error suggests that you are defining a function inside another function. All functions must be defined globally

 

Need some help.

Looking for any function or script that knows how to take a screenshot at some point, such as when opening/closing a pose.

When I don't have to, have come across one every now and then, but now I can't find it.

HELP!
 
DhP:

Need some help.

Looking for any function or script that knows how to take a screenshot at some point, such as when opening/closing a pose.

When I don't have to, I've come across one every now and then, but now I can't find it.

HELP!
There is an Expert Advisor by Igor Kim that makes a screenshot at a given interval
Reason: