Fans of GUOs - page 2

 
Excuse me, can I get a detailed description of the guo script?

what does it do in general and how to use it?

thanks in advance
 
<br / translate="no"> Horn 06.02.05 06:45
The idea of using MessageBox for the indicator to slow down its execution is great. I probably never would have guessed it. It opens up many possibilities for interactive order placement. My respect to you komposter!
As for those criticizing the implementation, I don't know why they say it is "crude".
I'm sure it will be very convenient for many traders to work with your script for placing pending orders.


Horn, I said what I think and I didn't scold anyone at all. So please think about it next time.
Good luck :)
 
Flower_of_Life 06.02.05 17:42

you transfer to the chart. attachment point - opening price. stop-loss - - 50 points, take-profit - +50 points.
you move the lines to the required levels(take profit can be deleted), press ok, the order is placed.

If Openprice_line is higher than the market price - order will be either Buy Stop or Sell Limit (depending on Stop Loss), if it is lower - Sell Stop or Buy Limit (the same).


the script is very crude, no checks, everything is at random =)))


will be enthusiastic - we will improve it :))
 
so is it possible to drag stops and profits right over the lines?
 
How an expert writer should proceed:

Thanks for the clarification, we will definitely take it into account and not do while(true) with orders again.

Here is the same order but modified to sell.
(I hope I have changed everything)

//+------------------------------------------------------------------+
//|                                                   order_sell.mq4 |
//|                              Copyright c 2004, Alexander Ivanov. |
//|                                        mailto:alexander@indus.ru |
//+------------------------------------------------------------------+
//| Разрешите импорт функций из библиотек через:                     |
//| "Сервис -> Настройки -> Советники -> Разрешить импорт DLL"       |
//+------------------------------------------------------------------+
#property copyright "Copyright c 2004, Alexander Ivanov."
#property link      "mailto:alexander@indus.ru"

#include <WinUser32.mqh>
#include <stdlib.mqh>
#include <stderror.mqh>
//+------------------------------------------------------------------+
//| Указываем количество последних дней, на которых ищем минимум     |
//| для установки стоплосса                                          |
//+------------------------------------------------------------------+
#define DAYS_TO_CONSIDER 3
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init() { return(0); }
int deinit()
  {  
//---- просто удалим свои линии стопов
   ObjectDelete( "order_sell_Stop_Loss_Line");
   ObjectDelete( "order_sell_Take_Profit_Line");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Основная функция скрипта                                         |
//+------------------------------------------------------------------+
int start()
  {
   double DaysLowArray[];
   double dMyStopLoss = 0;  
   double dMyPrice = 0;
   double dMyTakeProfit = 0;
   double dMyLots = 0;
//---- скопируем массив дневных данных
   if(ArrayCopySeries(DaysLowArray, MODE_HIGH, Symbol(),PERIOD_D1) < DAYS_TO_CONSIDER) 
     {
      return(-1);
     }
//---- расчет цен
   dMyPrice      = Bid;
   dMyStopLoss   = DaysLowArray[Highest(Symbol(),PERIOD_D1,MODE_HIGH,DAYS_TO_CONSIDER,0)];
   dMyTakeProfit = dMyPrice - 2*MathMax((MathAbs(Ask-Bid)/2),MathAbs(dMyPrice-dMyStopLoss));
   dMyStopLoss  += 10*Point;
   dMyLots       = 0.1;
//---- выставим линии для визуального управления стопами
   ObjectCreate( "order_sell_Stop_Loss_Line", OBJ_HLINE, 0, 0, dMyStopLoss, 0, 0, 0, 0 );
   ObjectSet( "order_sell_Stop_Loss_Line", OBJPROP_COLOR, Red );
   ObjectSetText( "order_sell_Stop_Loss_Line", "Stop_Loss_Line", 6, "Arial", Red );

   ObjectCreate( "order_sell_Take_Profit_Line", OBJ_HLINE, 0, 0, dMyTakeProfit, 0, 0, 0, 0 );
   ObjectSet( "order_sell_Take_Profit_Line", OBJPROP_COLOR, Lime );
   ObjectSetText( "order_sell_Take_Profit_Line", "Take_Profit_Line", 6, "Arial", Lime );
//---- запросим подтверждение на отработку
   string quest="Вы хотите продать "+DoubleToStr(dMyLots,2)+" "+Symbol()+" по цене Bid "+
                DoubleToStr(dMyPrice,Digits)+"    \n\n"+
                "Переместите выставленные линии на необходимые уровни и нажмите ОК           \n"+
                "(красная линия - Stop Loss, зеленая - Take Profit)\n\n"+
                "Нажмите Отмена чтобы отказаться от сделки";
   if(MessageBoxA(0,quest,"Визуальная установка ордера на продажу",
                  MB_OKCANCEL | MB_ICONASTERISK | MB_TOPMOST)!=IDOK) return(-2);
//---- трейдер согласился, возьмем новые уровни стопов и обязательно проверим их!
   dMyStopLoss  =NormalizeDouble(ObjectGet( "order_sell_Stop_Loss_Line", OBJPROP_PRICE1),Digits);
   dMyTakeProfit=NormalizeDouble(ObjectGet( "order_sell_Take_Profit_Line",OBJPROP_PRICE1),Digits);
   
   if((dMyStopLoss>0 && dMyStopLoss<Bid) || (dMyTakeProfit>0 && dMyTakeProfit>Bid))
     {
      Print("Неправильно выставлены уровни Stop Loss и Take Profit!");
      MessageBoxA(0,"Неправильно выставлены уровни Stop Loss и Take Profit!         \n"+
                    "Операция отменена\n\n",
                    "Визуальная установка ордера на продажу",MB_OK | MB_ICONSTOP | MB_TOPMOST);
      return(-3);
     }
//---- выведем в лог сообщение об заявке
   Print("sell ",DoubleToStr(dMyLots,2)," ",Symbol()," at ",DoubleToStr(dMyPrice,Digits),
         "sl ",DoubleToStr(dMyStopLoss,Digits)," tp ",DoubleToStr(dMyTakeProfit,Digits));
//---- пробуем послать команду
   int ticket=OrderSend(Symbol(),OP_SELL,dMyLots,dMyPrice,3,dMyStopLoss,dMyTakeProfit,
                        "Ordered by \"order_sell\" script" ,255,0,HotPink);
   if(ticket>0) // все отлично - заявка прошла
     {
      //---- сразу же выведем в лог подтверждение
      Print("#",ticket," sell ",DoubleToStr(dMyLots,2)," ",Symbol()," at ",
            DoubleToStr(dMyPrice,Digits)," is done");
      //---- покажем окно 
      if(MessageBoxA(0,"Ордер успешно исполнен     \nРаспечатать его?",
		     "Визуальная установка ордера на продажу", MB_YESNO | MB_ICONASTERISK | MB_TOPMOST)==IDYES)
		  {
         OrderPrint();
        }
      //---- все ок, выходим
      return(0);
     }
//---- тут все плохо - выведем в лог сообщение
   int err=GetLastError();
   Print("sell ",DoubleToStr(dMyLots,2)," ",Symbol()," at ",
         DoubleToStr(dMyPrice,Digits)," failed [",ErrorDescription(err),"]");
//----покажем окно
   MessageBoxA(0,ErrorDescription(err), 
               "Ошибка визуальной установки ордера", MB_OK | MB_ICONERROR | MB_TOPMOST); 
   return(-4);
  }
//+------------------------------------------------------------------+
 
зы: если кто знает, как сделать месседж "поверх всех окон", скажите, плз.... а то так неудубно.....

я использовал MB_TOPMOST, попробуй, у меня вроде бы получилось.

Where should I write it?

For example here :)
MessageBoxA(0,ErrorDescription(err), "Error", MB_OK | MB_ICONERROR | MB_TOPMOST);
 
Horn, I said what I thought and didn't scold anyone at all. So next time, please think of something to write. <br / translate="no">

I'm sorry, I got angry.
 
so you can drag stops and profits right over the lines?

That's the beauty of it!

to Komposter:
If it's not too difficult, please refine your script to have all sorts of checks, etc.
And then we'll have three great scripts:

1. One for placing pending orders;
2. one for market buy order;
3. one for market sell order.
That's not enough!

And then we will continue to look for other additional features, maybe people will give some hints or ask to do something specific... and what will be even nicer is if someone joins the development ;)
 
It seems that MessageBox should be introduced in standard MQL4 functions, so you don't have to explicitly allow DLL function calls. And it will work faster.
 
Renatu.
When compiling theExpert code, an error warning
'4107'-redefinition with another value
It goes to the "log the request message" line.
What needs to be overridden?
Reason: