Someone scribble a script for 5 wmz. - page 14

 
Profitabl:

This code compiles with four errors, maybe there are brackets missing?


Try it like this:

Well, the NumberOfPositions and ClosePositions functions must be present in the code

extern double TakeProfit = 120;
extern double StopLoss = 120;
extern double Lots = 0.1;
int Magic = 1234567;
int ticket;

//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
if ( DayOfWeek()==4)//если сегодня четверг
   {
    if ( Hour() == 23) //если - 23 часа терминального времени
       {
        if ( NumberOfPositions(NULL,OP_BUY, Magic )==0 ) //если нет открытых бай-позиций
           { 
           //"если цена open 46 периода 30M четверга меньше цены open 46 периода 30M среды,"(с)
           //"а цена опен среды больше цены опен вторника" (с),
           //"да ещё цена опен вторника больше цены опен понедельника" (с),
           if ( Close[1]<= Open[24] && Close[23]>=Open[48] && Close[47]>=Open[72]) 
              {
               ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask+StopLoss*Point,3,0,Ask+TakeProfit*Point,"Name_Expert",16384,0,Green);
               if(ticket!=-1)
                  {Print("Error opening BUY order : ",GetLastError());
                   return(0);}
              }     

           }
           
        }
   }       

if ( DayOfWeek()==5 && Hour() == 23){//если сегодня пятница, 23-00
//закрываем
ClosePositions(NULL,OP_BUY, Magic); }

return(0);
}
// the end.

 

=================

There were not 4 errors. There were 4 unused functions. Cleared it up.

I'll say it again. Check for tf=n1

extern int       Magic=5671;

extern double    lots = 0.1;
extern int       StopLoss=120;
extern int       TakeProfit=120;

extern string _________________ = "=== Прочие Параметры советника  ===";
extern int        Slippage        = 10; // Проскальзывание цены
extern string Name_Expert = "Обезьяна Чи-Чи-Чи продавала кирпичи";
extern bool   UseSound      = True;   // Использовать звуковой сигнал
color  clOpenBuy     = Blue;        // Цвет значка открытия покупки
color  clOpenSell    = Red;         // Цвет значка открытия продажи
 color  clCloseBuy    = Green;     // Цвет закрытия покупки
 color  clCloseSell   = Green;    // Цвет закрытия продажи
extern int    NumberOfTry   = 10;           // Количество попыток
 string SoundSuccess  = "ok.wav";          // Звук успеха
 string SoundError    = "timeout.wav";    // Звук ошибки

//----------------------------------
double SL,TP;
int ticket;
static int prevtime = 0;
int StopLevel;

//-- Подключаемые модули --

#include <stderror.mqh>
#include <stdlib.mqh>

//+------------------------------------------------------------------+

int start()
  {
// задаем работу по ЦЕНАМ ОТКРЫТИЯ 
if (Time[0] == prevtime) return(0); //если появился новый бар
   prevtime = Time[0]; // начинаем работу

StopLevel = MarketInfo(Symbol(),MODE_STOPLEVEL); // вызываем разрешенный 
//минимаьный стоп-Уровень
//======================= открываем позиции =====================================
if ( DayOfWeek()==4){//если сегодня четверг
if ( Hour() == 23)  {//если - 23 часа терминального времени
if ( NumberOfPositions(NULL ,OP_BUY, Magic )==0 ) { //если  нет открытых бай-позиций 
//если цена open 46 периода 30M четверга меньше цены open 46 периода 30M среды,
//а цена опен среды больше цены опен вторника,
//да ещё цена опен вторника больше цены опен понедельника,
if ( Close[1]<= Open[24] && Close[23]>=Open[48] && Close[47]>=Open[72]) {
//покупаем 
      SL=0;TP=0;
      if(StopLoss>0 && StopLoss>StopLevel )    SL=Bid-Point*StopLoss;
      if(TakeProfit>0 && TakeProfit>StopLevel) TP=Bid+Point*TakeProfit;
      if(StopLoss  <StopLevel && StopLoss>0)   SL = Bid-Point*StopLevel; 
      if(TakeProfit<StopLevel && TakeProfit>0) TP = Bid+Point*StopLevel; 
   ticket=OrderSend(Symbol(),OP_BUY,lots,Ask,3,SL,TP,"Name_Expert",Magic,0,clOpenBuy );
   if(ticket < 0) {
            Print("Ошибка открытия ордера BUY #", GetLastError()); 
            Sleep(10000);  prevtime = Time[1];   return (0); 
                  } 
        }}}}
//================== конец блока открытия ==================================
 //================Закрытие позиций=====================================
if ( DayOfWeek()==5  && Hour() == 23){//если сегодня пятница, 23-00
//закрываем
 ClosePositions(NULL,OP_BUY, Magic); }            
                  
//================== Конец блока закрытия  =============================
  return(0);
  }
//ЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖ Конец функции int start() ЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖ 
 
 //ЖЖЖЖЖЖЖЖЖЖЖ ПОЛЬЗОВАТЕЛЬСКИК ФУНКЦИИ ЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖ

//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 01.09.2005                                                     |
//|  Описание : Возвращает наименование торговой операции                      |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    op - идентификатор торговой операции                                    |
//+----------------------------------------------------------------------------+
string GetNameOP(int op) {
  switch (op) {
    case OP_BUY      : return("Buy");
    case OP_SELL     : return("Sell");
    case OP_BUYLIMIT : return("BuyLimit");
    case OP_SELLLIMIT: return("SellLimit");
    case OP_BUYSTOP  : return("BuyStop");
    case OP_SELLSTOP : return("SellStop");
    default          : return("Unknown Operation");
  }
}
//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия  : 19.02.2008                                                      |
//|  Описание: Закрытие одной предварительно выбранной позиции                 |
//+----------------------------------------------------------------------------+
void ClosePosBySelect() {
  bool   fc;
  color  clClose;
  double ll, pa, pb, pp;
  int    err, it;

  if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
    for (it=1; it<=NumberOfTry; it++) {
      if (!IsTesting() && (!IsExpertEnabled() || IsStopped())) break;
      while (!IsTradeAllowed()) Sleep(5000);
      RefreshRates();
      pa=MarketInfo(OrderSymbol(), MODE_ASK);
      pb=MarketInfo(OrderSymbol(), MODE_BID);
      if (OrderType()==OP_BUY) {
        pp=pb; clClose=clCloseBuy;
      } else {
        pp=pa; clClose=clCloseSell;
      }
      ll=OrderLots();
      fc=OrderClose(OrderTicket(), ll, pp, Slippage, clClose);
      if (fc) {
        if (UseSound) PlaySound(SoundSuccess); break;
      } else {
        err=GetLastError();
        if (UseSound) PlaySound(SoundError);
        if (err==146) while (IsTradeContextBusy()) Sleep(1000*11);
        Print("Error(",err,") Close ",GetNameOP(OrderType())," ",
              ErrorDescription(err),", try ",it);
        Print(OrderTicket(),"  Ask=",pa,"  Bid=",pb,"  pp=",pp);
        Print("sy=",OrderSymbol(),"  ll=",ll,"  sl=",OrderStopLoss(),
              "  tp=",OrderTakeProfit(),"  mn=",OrderMagicNumber());
        Sleep(1000*5);
      }
    }
  } else Print("Некорректная торговая операция. Close ",GetNameOP(OrderType()));
}
//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru/                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 19.02.2008                                                     |
//|  Описание : Закрытие позиций по рыночной цене                              |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   (""   - любой символ,                   |
//|                                     NULL - текущий символ)                 |
//|    op - операция                   (-1   - любая позиция)                  |
//|    mn - MagicNumber                (-1   - любой магик)                    |
//+----------------------------------------------------------------------------+
void ClosePositions(string sy="", int op=-1, int mn=-1) {
  int i, k=OrdersTotal();

  if (sy=="0") sy=Symbol();
  for (i=k-1; i>=0; i--) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if ((OrderSymbol()==sy || sy=="") && (op<0 || OrderType()==op)) {
        if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
          if (mn<0 || OrderMagicNumber()==mn) ClosePosBySelect();
        } } } } }

//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 19.02.2008                                                     |
//|  Описание : Возвращает количество позиций.                                 |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   (""   - любой символ,                   |
//|                                     NULL - текущий символ)                 |
//|    op - операция                   (-1   - любая позиция)                  |
//|    mn - MagicNumber                (-1   - любой магик)                    |
//+----------------------------------------------------------------------------+
int NumberOfPositions(string sy="", int op=-1, int mn=-1) {
  int i, k=OrdersTotal(), kp=0;

  if (sy=="0") sy=Symbol();
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==sy || sy=="") {
        if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
          if (op<0 || OrderType()==op) {
            if (mn<0 || OrderMagicNumber()==mn) kp++;
          }}}}}  return(kp);}

 
leonid553:

=================

There were not 4 errors. There were 4 unused functions. Cleared it up.

I'll say it again. Check on tf=n1.


You have actually given an example, you may send WMR where you can transfer 160 rubles to, at least to a charity organisation.

The only thing I cannot do is to close SELL positions on Fridays at 23:00, otherwise only BUY are closed, while SELL are modified for three or four days and of course s\l are closed.

Here these euro and pound data can be taken into account as additional conditions ?, just when the forecasts are not asymmetric B=BB or H=HH one should buy in the opposite direction, it improves the result much more.

But if the same data for the pound and the euro at the same time
EUR EUR is "falling on Tuesday, falling on Wed, falling on Thu
GBP "rising, Wed rising, Tues falling"
then open not "SELL" but "BUY".

Speaking of profitability, if you remove inaccurate forecasts, just 70 trades of six Friday forecasts give about 1500 pips. This can be multiplied by five times the rest of the days, and increasing the lots in proportion to the dept by another two times - no matter how many, it is break-even. I give Leonid a table of 160 EUR GBP CHF JPY forecasts for free for the participation in the problem, send WMR ale2715@yandex.ru and in the return letter will receive forecasts, write an EA, you will earn, but do not participate in the championship with it, I will hook him up to the championship too.

 
lasso:

Try it this way:

Well, and the NumberOfPositions and ClosePositions functions should be present in the code


Thank you, we'll leave it that way for now
 
Profitabl:

The only thing that does not work is that SELL positions are also closed on Fridays at 23:00, otherwise only BUY are closed, while SELL are modified for three or four days and of course s\l are closed.

Indeed... )))

It should be like this

 //================Закрытие позиций=====================================
if ( DayOfWeek()==5  && Hour() == 23){//если сегодня пятница, 23-00
//закрываем
 ClosePositions(NULL,-1, Magic); }            
                  
//================== Конец блока закрытия  =============================
  return(0);
  }
//ЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖ Конец функции int start() ЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖ 
 

The opening of a Sell position was not part of the code at all. Because in the original job it was a question of opening a buy position on the franc.

//------------

Yes, I need to change the close a bit - ClosePositions(NULL,-1, Magic)

 
leonid553:

There were not four errors. There were four unused functions. I cleaned it up.

I'll say it again. Check on tf=n1

A closer look revealed the following nuances:

1) Conditions contradict each other

//если цена open 46 периода 30M четверга меньше цены open 46 периода 30M среды,
//а цена опен среды больше цены опен вторника,
//да ещё цена опен вторника больше цены опен понедельника,
if ( Close[1]<= Open[24] && Close[23]>=Open[48] && Close[47]>=Open[72]) {
//покупаем 


2) calling time-series (of Open[48] type) is not quite correct when testing on the history since there may well be gaps in the history and thus the price is obtained not from the bar the starter wrote about


3) Closing condition.

 //================Закрытие позиций=====================================
if ( DayOfWeek()==5  && Hour() == 23){//если сегодня пятница, 23-00
//закрываем

It is not universal since for example the brokerage company has Al...and there is no bar on Friday with the hour value equal to 23


4) And some more minor nuances, but their influence on the resulting balance curve is not at all minor.... ))



Please bear with me correctly. This post is not a complaint against leonid553, by no means. (Kudos to leonid!!!)


My point is: "Chirk, chirk script, in five minutes" is of course possible. But practice shows that simple TOR does not happen.

Everywhere you need to check for boundary values of all parameters, debugging, setting "error traps", etc.

And in order to finally get a decent little product, rather than some "script" - a lot of time is required, no matter how you look at it... Unfortunately.

 

The advisor is already trading on the real, today opened the first two trades at 23, now I wonder how it will close tomorrow. Thank you all for your participation.

And in this table EA's results for Tuesday's predictions, marked "I", these are the brightest signals, trade only on them - this is method B, its totals in the right-most column, all the totals in pips.

For example, in my Expert Advisor for Tuesday CHF I left only BBB, BHN and BHN and added possibility to increase lots proportional to deposit. The total in the test for 10% deposit is 180% with 55 losing trades and profitable, but for 20% buying it is 450% profit. You clean the grain from the red chaff, teach the Expert Advisor to change signals marked "c" in case of contradictory forecasts of asymmetrical pairs, not to decrease added lots, to trade simultaneously all four currencies and you are "familiar with the forex director". Just solve these three problems and you will get this EA, just don't take part in the championship with it, my analytics glorifies my name.

Check yourself 450% from 27.01.08 from only three predictions out of 160, CHF on 1H. It was even 830%, would have remained so, and even would have been more, if the Expert Advisor had only increased the lots.

Files:
450_2.rar  20 kb
 

No words... It's like a grail. Why didn't you notice it before?

 
lasso:

A closer look reveals the following nuances:

......

Please understand me correctly. This post is not a complaint about .......

I don't pretend to write the code correctly at all. I specifically pointed out there that the code I wrote is just a blueprint.

I haven't got into all subtleties of tactics yet, except in general terms. But I already think that the tactic deserves very serious attention. I deal mainly with seasonal commodity trading, and that's why I think there are prospects here. Because this is essentially the same "quasi-seasonal trading", but short-term, on the clock:

"Trend check :
Let's take silver as an example. The one-hour candlestick from 6 p.m. to 7 p.m. coincided in more than 70% of cases with the price movement in the next 23 hours, which by the way is typical for some other metals. And this has happened in the last 50, 40, 30, 20, and 10 days. So, after 19 o'clock we place an order in the direction of this candle....
"(from - BR forum).

Moreover, quite by chance, I - as recently as yesterday (see above quote) - found out - that exactly with such (well, almost "one-to-one") tactics was won the last month demo contest in a well-known DC BR. With a prize of $ 5000.

And the participant, who traded futures in this September contest, obtained more than 1000 profit points with this tactics from the beginning of the month. (Demo-competition rules are very strict there - participants must describe on the forum each of their transaction at the moment of entry and the risk (stop-loss) of each transaction must not exceed -200 dollars, otherwise it will be a disqualification).

So, NorthAlec, - you are probably sneering in vain.