[Archive!] I'll write an advisor for FREE - page 19

 

I'm new to programming, even if you could say I'm a complete dummy. But it's interesting to try my hand at it. I am trying to write a simple Expert Advisor that would work one day a week. For example on Monday it opens at 00-00 hours and closes at 24-00 hours. I understand it clearly in separate parts but I can't assemble it all in one program. If you know where to get (download) the Expert Advisor on this subject. I want it as a sample.

 
asd05:

I'm new to programming, even if you could say I'm a complete dummy. But it's interesting to try my hand at it. I am trying to write a simple Expert Advisor that would work one day a week. For example on Monday it opens at 00-00 hours and closes at 24-00 hours. I understand it clearly in separate parts but I can't assemble it all in one program. If you know where to get (download) the Expert Advisor on this subject. I want it as a sample.


Spamming is not advised. You may get banned.
 
asd05:

I'm new to programming, even if you could say I'm a complete dummy. But it's interesting to try my hand at it. I am trying to write a simple Expert Advisor that would work one day a week. For example on Monday it opens at 00-00 hours and closes at 24-00 hours. I understand it clearly in separate parts but I can't assemble it all in one program. If you know where to get (download) the Expert Advisor on this subject. I want it as a sample.

Here is an example of a primitive "night hunter". Works by default from 9pm to 8am every day.
In the simplest version, try it roughly like this:

//+------------------------------------------------------------------+
//|                                                    222222222.mq4 |
//|                      Copyright © 2011, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"


extern int   Magic = 31295;
 extern int     Start=21;//начало работы вечером
extern int      End=8; //конец работы утром
extern int      SL=410;
extern int      TP=280;
extern double  Lot=0.1;

extern string  __________ = "=== Функция Трейлинг Стоп ====";
extern bool      UseTrailing = false;//Выключатель трейлинг стопа
extern int    MinProfit = 200;//порог включения трейлин стопа
extern int    TrailingStop = 150;// величина трейлинг стопа
extern int    TrailingStep = 10; // шаг трейлинг стопа 

bool Trade;
bool  gbNoInit    = False;   // Флаг неудачной инициализации

//----------------------------------------------------
int init()
{
//-----------------------------------------------------------
gbNoInit=False;  
if (!IsTradeAllowed()) {
    Message("Для нормальной работы советника необходимо\n"+
            "Разрешить советнику торговать");
    gbNoInit=True; return;
  }
  if (!IsLibrariesAllowed()) {
    Message("Для нормальной работы советника необходимо\n"+
            "Разрешить импорт из внешних экспертов");
    gbNoInit=True; return;    }
}
//-----------------------------------------------------

//===================================================
int start() {// функция СТАРТ

if (UseTrailing) TrailPositions(); // выключатель трейлинг стопа


if ( Hour()>Start || Hour()<End )//если время - больше  Start или меньше End
    Trade=true;    else Trade=false;//то торговля разрешена
Comment ("Торговля разрешена с ",Start ," до ",End);
//---------------------------------------------------
if (Trade && NumberOfPositions(NULL,OP_BUY,Magic)<1) {
//если тоговля разрешена и нет откр. длинных позиций
   OrderSend(Symbol(),OP_BUY,Lot,Ask,3,Ask-SL*Point,Ask+TP*Point,"хи - хи",Magic,0,SkyBlue);
                                               }
//---------------------------------------------------   
 if (Trade && NumberOfPositions(NULL,OP_SELL,Magic)<1) {
//если тоговля разрешена и нет откр. селл-  позиций 
   OrderSend(Symbol(),OP_SELL,Lot,Bid,3,Bid+SL*Point,Bid-TP*Point,"тра-ля-ля",Magic,0,Green);
                                                   }
 //-----------------------------
 return (0);                                      
}//конец функции СТАРТ 


//жжжжжжжжжжжжжжжжжжжжж Пользовательские функции жжжжжжжжжжжжжжжжжжжжжжжжжжжжжж
//жжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжж+
//|  Автор    : Ким Игорь В. 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); }

//жжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжж
 void TrailPositions() // функция трейлинг стоп
{
  int Orders = OrdersTotal();
  for (int i=0; i<Orders; i++) {
    if (!(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))) continue;
    if (OrderSymbol() != Symbol()) continue;
     if (OrderMagicNumber() == Magic ){    
     if (OrderType() == OP_BUY )  {
      if (Bid-OrderOpenPrice() > MinProfit*Point) {
        if (OrderStopLoss() < Bid-(TrailingStop+TrailingStep-1)*Point) {
          OrderModify(OrderTicket(), OrderOpenPrice(), Bid-TrailingStop*Point,
                                                     OrderTakeProfit(), 0, Blue);
        }      }    }
    if (OrderType() == OP_SELL)  {
      if (OrderOpenPrice()-Ask >MinProfit*Point) {
        if (OrderStopLoss() > Ask+(TrailingStop+TrailingStep-1)*Point 
                                                       || OrderStopLoss() == 0) {
          OrderModify(OrderTicket(), OrderOpenPrice(), Ask+TrailingStop*Point,
                                                      OrderTakeProfit(), 0, Blue);
        }   }   }    }   }  }

//+----------------------------------------------------------------------------+
//|  Вывод сообщения в коммент и в журнал                                      |
//+----------------------------------------------------------------------------+
void Message(string m) {
  Comment(m);
  if (StringLen(m)>0) Print(m);
}
 

hello! is the writing still on? :) so much has been written here already.... I would like to write a little tipster ...a simple one, on two mash and Momentum, and I'll continue if anyone wants to do it.

good luck
 

The simple Enterra_Forex_Star_EA_3.1 Expert Advisor needs a bit of tweaking.

It trades at a set time using one of two RSIs and puts a virtual takeprofit on six timers.

In case of losing price there is a function for opening additional orders in the same direction when number of points exceeds a certain value (something like averaging).

The problem: I have to open additional positions only at specified time of trade and does not recalculate take profit.

I have to do:

When a price goes down from a profitable direction of an open order, to open an order (and then some more - the number should be adjusted) of the same volume in the same direction independently of "working time" on such conditions (only together not "or"):

-the minimum number of points by which the price must go negative (adjustable) has been exceeded

Adjustable I-Reg indicator (attached) should "turn" in the profit direction (the channel width can be neglected)

We should add an averaging mechanism with the first open (and subsequent) order in the form of "x points from the breakeven point" and also a possibility to take the take at all "averaging" orders, like at the first order (taking into account that it changes according to the timer).

All in respect of 4/5 digit quotes

All this is almost as it should be done in Ilan_RSI_mm_extr193 (attached as a donor) I just don't understand this language at all.

Example:

Specified time of trade (opening positions) from 10 to 12

at 11:10 am, the EA opens a Sell 5lot at 1.5000 - the price goes up and as I mentioned in the settings through 20 pips, i.e. 1.5020 at 11:20 am, the second Sell order is opened with the same volume. They are both closed by virtual takeaway of the first one, which is set by 6 timers in the EA (although in fact it is set differently), for example, takeaway is 10 points and the EA closes at 6 points, in short it is not very important. So they close when the price reaches take point of the first one (e.g. 1.4094).

I already have it like that. I should place additional order when price will pass not less than 20 points and only if indicator I-Reg (configured by me) will show trend reversal.

I have to add averaging parameters, as I said.

There is one more thing:

If the order is opened at 11:50, say, sell, and the price goes strongly upwards after 12:00, the EA does not open orders at all - we should correct this to open the averaging.

I wanted to be clearer, but it has become somewhat complicated.

Can someone do it?

Thank you.

Files:
enterra.rar  23 kb
 
leonid553:

Here is an example of a primitive 'night hunter'. It works by default from 9pm to 8am every day.
In the simplest version, try it roughly like this:


Thanks, I'll give it a try.
 
Good afternoon, I have some interesting ideas I would like to implement in an EA. Contact me at mrforex@mail.ru. I would be very grateful.
 

Hello if possible please write an Expert Advisor based on two Muwings for opening deals on crossovers Thank you very much and excuse me for using your precious time example in the picture attached in advance THANK YOU so much in advance chughoy@list.ru


 
Good afternoon. I need an EA that will alert me when certain two of the four muwings are crossed. I am willing to pay. To contact: shurik302(dog)gmail.com
 
molodec8:

The strategy brings in up to 40 per cent a month

Better FROM 5 than BEFORE 40% ))))