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

 

Friends, please help, tell me how to find the first fractal of the day on the hourly chart? And that at the beginning of the next day it will "reset" and look for a new first fractal?

Thanks in advance!

 
granit77:
The terminal itself cannot do this, but there are scripts that can do it. For example, this one. And there are several similar scripts in the database.


They're very crude, where can I get one that's easier?
 
https://www.mql5.com/ru/code/10633 is power!
 
Big_Bo:

Friends, please help, tell me how to find the first fractal of the day on the hourly chart? And that at the beginning of the next day it will "reset" and look for a new first fractal?

Thanks in advance!


Help:https://www.mql5.com/ru/forum/131859
 
abeiks:

Did something, but for some reason it doesn't work - one order openinglater is not displayed . where is the error there?

what if it is?

double profits_buy_2pos()
{
    int ordercount = 0, OpenOrders = OrdersTotal();;
    double pr_buy = 0;
    for (int cnt = OpenOrders - 1; cnt >= 0; cnt--)   // scan all orders and positions. ..
    {
        if (!OrderSelect (cnt, SELECT_BY_POS)) return (0.0);
        if (OrderSymbol() != Symbol()) continue;
        if (OrderMagicNumber() != magic) continue;
        if (OrderType() != OP_BUY) continue;
        pr_buy += OrderProfit();
        ordercount++;
        if (ordercount == 2) break;
    } 
    Print ("::::::::::::::::::::::::: pr_buy2 = ", pr_buy);   
    Print ("::::::::::::::::::::::::: ordercount = ", ordercount);    
    return (pr_buy);   
}
 
Good afternoon! I put the script on the chart and nothing happens. What is it?
 

More details. I haven't actually used the scripts yet. The log says 2012.11.30 13:05:56 Script Buy EURUSD,Weekly: loaded successfully and 2012.11.30 13:06:47 Script Buy EURUSD,Weekly: removed.

And nothing else... What does he want?

Dog!!! It's the third day it's not working...

 
Dimka-novitsek:

More details. I haven't actually used the scripts yet. The log says 2012.11.30 13:05:56 Script Buy EURUSD,Weekly: loaded successfully and 2012.11.30 13:06:47 Script Buy EURUSD,Weekly: removed.

And nothing else... What does he want?

Dog!!! It's the third day it's not working...


Give me the code. I'll take a look. I'll post the right one.

 
//+------------------------------------------------------------------+
//|                                                      Покупка.mq4 |
//|                        Copyright 2012, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
//----
for(int i=0;i<=OrdersTotal();i++){
   if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == true)
 { if(OrderSymbol() != Symbol()) continue; 
   if(OrderType()==OP_SELL) 
  OrderClose(OrderTicket(),OrderLots(),Ask,6,Red); 
   if(OrderType()==OP_BUY)
  OrderClose(OrderTicket(),OrderLots(),Bid,6,Red);  
   if(OrderType()>=2)
  OrderDelete(OrderTicket());  }} 
//----
   for(i=0;i<23;i++){
   Sleep(2000);RefreshRates(); if(!IsTradeAllowed())continue;
   int tiket=OrderSend(Symbol(),OP_BUY,0.1,Ask,6,0,0,"Skript",98600,0,Blue);
   if( tiket!=-1)break;}
     
          
//----
   return(0);
  }
//+------------------------------------------------------------------+
Sure, right away! The code seems fine... I don't know what... But of course I'll put it out there!
 
Dimka-novitsek:
Sure, right away! The code seems fine... I don't know what... But of course I'll put it out there!

Maybe this will work:

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
#include     <stderror.mqh>                        // Библиотека кодов ошибок
int start()
{
    double ld_Price;
//----
    for (int i = OrdersTotal() - 1; i >= 0; i--)
    {
        if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
        if (OrderSymbol() != Symbol()) continue; 
        if (OrderType() >= 2)
        {OrderDelete (OrderTicket());  continue;}
        if (OrderType() == OP_SELL) ld_Price = Ask;
        else if (OrderType() == OP_BUY) ld_Price = Bid;
        OrderClose (OrderTicket(), OrderLots(), NormalizeDouble (ld_Price, Digits), 6, Red);
    }
//----
    for (i = 0; i < 23; i++)
    {
        Sleep (2000);
        if (!IsTradeAllowed()) continue;
        RefreshRates();
        if (OrderSend (Symbol(), OP_BUY, 0.1, NormalizeDouble (Ask, Digits), 6, 0.0, 0.0, "Skript", 98600, 0, Blue) > 0) break;
        else Print ("Error: ", ErrorDescription (GetLastError()));
    }
//----
    return (0);
}
//+------------------------------------------------------------------+