Writing free EAs - page 10

 
Konstantin Bystrov:
Hi all. who can write an indicator in mt4, so that the active trading sessions (can be set from 10-18) were displayed in the form of Japanese candles

ok

 

Good afternoon!

Are there any craftsmen here who could write an EA based on an informational indicator of currency strength. The algorithm is as follows. We are waiting for the strong and weak currency to appear. In the example on the screenshot, it is EUR and USD. If the difference is significant (to be set in the EA parameters), then we open a position. In the example on the screenshot, you need to enter into a sell, which I will do on Monday. In the EA, we have to set the timeframe parameter, from which the EA should take the signal (difference in strength of different currencies). The currency strength difference is the signal. Stop Loss is not needed. Take Profit is needed. If the price goes against us, let's average. In your Expert Advisor, prescribe the averaging step, the number of orders, magic number, initial lot size, and lot increment factor. I have been trading using this method recently; I am very satisfied. For my perception it is a grail.

 
Konstantin Bystrov:
Hi all. can you write an indicator in mt4, to display active trading sessions (you can set the time from 10-18) in the form of Japanese candles
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""

#property indicator_chart_window

extern int    NumberOfDays = 50;
extern string AsiaBegin    = "10:00";
extern string AsiaEnd      = "18:00";
extern color  AsiaColor    = Goldenrod;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void init()
  {
   DeleteObjects();
   for(int i=0; i<NumberOfDays; i++)
      CreateObjects("AS"+i, AsiaColor);
   Comment("");
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
void deinit()
  {
   DeleteObjects();
   Comment("");
  }
//+------------------------------------------------------------------+
bool CreateObjects(
   const string          name="Rectangle",  // имя прямоугольника
   const color           clr=clrRed,        // цвет прямоугольника
   const long            chart_ID=0,        // ID графика
   const int             sub_window=0,      // номер подокна
   datetime              time1=0,           // время первой точки
   double                price1=0,          // цена первой точки
   datetime              time2=0,           // время второй точки
   double                price2=0,          // цена второй точки
   const ENUM_LINE_STYLE style=STYLE_SOLID, // стиль линий прямоугольника
   const int             width=2,           // толщина линий прямоугольника
   const bool            fill=false,        // заливка прямоугольника цветом
   const bool            back=false,        // на заднем плане
   const bool            selection=false,    // выделить для перемещений
   const bool            hidden=true,       // скрыт в списке объектов
   const long            z_order=0)         // приоритет на нажатие мышью
  {
//--- сбросим значение ошибки
   ResetLastError();
//--- создадим прямоугольник по заданным координатам
   if(!ObjectCreate(chart_ID,name,OBJ_RECTANGLE,sub_window,time1,price1,time2,price2))
     {
      Print(__FUNCTION__,
            ": не удалось создать прямоугольник! Код ошибки = ",GetLastError());
      return(false);
     }
//--- установим цвет прямоугольника
   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
//--- установим стиль линий прямоугольника
   ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style);
//--- установим толщину линий прямоугольника
   ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width);
//--- включим (true) или отключим (false) режим заливки прямоугольника
   ObjectSetInteger(chart_ID,name,OBJPROP_FILL,fill);
//--- отобразим на переднем (false) или заднем (true) плане
   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
//--- включим (true) или отключим (false) режим выделения прямоугольника для перемещений
//--- при создании графического объекта функцией ObjectCreate, по умолчанию объект
//--- нельзя выделить и перемещать. Внутри же этого метода параметр selection
//--- по умолчанию равен true, что позволяет выделять и перемещать этот объект
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);
//--- скроем (true) или отобразим (false) имя графического объекта в списке объектов
   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);
//--- установим приоритет на получение события нажатия мыши на графике
   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);
//--- успешное выполнение
   return(true);
  }
//+------------------------------------------------------------------+
void DeleteObjects()
  {
   for(int i=0; i<NumberOfDays; i++)
      ObjectDelete("AS"+i);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
void start()
  {
   datetime dt=CurTime();

   for(int i=0; i<NumberOfDays; i++)
     {
      DrawObjects(dt, "AS"+i, AsiaBegin, AsiaEnd);
      dt=decDateTradeDay(dt);
      while(TimeDayOfWeek(dt)>5)
         dt=decDateTradeDay(dt);
     }
  }
//+------------------------------------------------------------------+
void DrawObjects(datetime dt, string no, string tb, string te)
  {
   datetime t1, t2;
   double   p1, p2;
   int      b1, b2;

   t1=StrToTime(TimeToStr(dt, TIME_DATE)+" "+tb);
   t2=StrToTime(TimeToStr(dt, TIME_DATE)+" "+te);

   if(!TimeDayOfWeek(t1))
      return;

   b1=iBarShift(NULL, 0, t1);
   b2=iBarShift(NULL, 0, t2);
   p1=High[Highest(NULL, 0, MODE_HIGH, b1-b2, b2)];
   p2=Low [Lowest(NULL, 0, MODE_LOW, b1-b2, b2)];
   ObjectSet(no, OBJPROP_TIME1, t1);
   ObjectSet(no, OBJPROP_PRICE1, p1);
   ObjectSet(no, OBJPROP_TIME2, t2);
   ObjectSet(no, OBJPROP_PRICE2, p2);
  }
//+------------------------------------------------------------------+
datetime decDateTradeDay(datetime dt)
  {
   int ty=TimeYear(dt);
   int tm=TimeMonth(dt);
   int td=TimeDay(dt);
   int th=TimeHour(dt);
   int ti=TimeMinute(dt);

   td--;
   if(td==0)
     {
      tm--;
      if(tm==0)
        {
         ty--;
         tm=12;
        }
      if(tm==1 || tm==3 || tm==5 || tm==7 || tm==8 || tm==10 || tm==12)
         td=31;
      if(tm==2)
         if(MathMod(ty, 4)==0)
            td=29;
         else
            td=28;
      if(tm==4 || tm==6 || tm==9 || tm==11)
         td=30;
     }
   return(StrToTime(ty+"."+tm+"."+td+" "+th+":"+ti));
  }
//+------------------------------------------------------------------+


 

Hello Dear programming gurus, I'm asking for your help in finishing this robot.

I'm not a programmer myself, this robot is assembled by myself from various parts found on the Internet, but I can not attach the remaining two functions that I would like to see. Please help me. I think that for you it will not be as difficult as me. If you would like to help, please make a function which closes pending order after one of two pending orders has triggered. And the second function should automatically increase a lot of the order ("say" for every $50 of balance 0.01 lot, when you reach $100 the robot will automatically increase a lot by 0.02). Thanks in advance for your help.

extern int    TakeProfit     = 100.0;
extern bool   AllPositions   = True; // Управлять всеми позициями
extern bool   ProfitTrailing = True;  // Тралить только профит
extern int    TrailingStop   = 50;    // Фиксированный размер трала
extern int    TrailingStep   = 0;     // Шаг трала
extern bool   UseSound       = False;  // Использовать звуковой сигнал
extern string NameFileSound  = "expert.wav";  // Наименование звукового файла


void start() 
{
double TakeProfitLevelB;
double TakeProfitLevelS;
double BuyStart = Ask + 400*_Point;
double SellStart = Bid - 400*_Point;

TakeProfitLevelB = BuyStart + TakeProfit*Point;
TakeProfitLevelS = SellStart - TakeProfit*Point;

if (Open[1]==Close[1]&& OrdersTotal()==0)
{
int BuyTicket = OrderSend(Symbol(),OP_BUYSTOP,0.10,BuyStart,3,0,TakeProfitLevelB,NULL,0,0,Green);
int SellTicket = OrderSend(Symbol(),OP_SELLSTOP,0.10,SellStart,3,0,TakeProfitLevelS,NULL,0,0,Blue);
}
  for (int i=0; i<OrdersTotal(); i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (AllPositions || OrderSymbol()==Symbol()) {
        TrailingPositions();
      }
    }
  }
}

void TrailingPositions() 
{
  double pBid, pAsk, pp;

  pp = MarketInfo(OrderSymbol(), MODE_POINT);
  if (OrderType()==OP_BUY) {
    pBid = MarketInfo(OrderSymbol(), MODE_BID);
    if (!ProfitTrailing || (pBid-OrderOpenPrice())>TrailingStop*pp) {
      if (OrderStopLoss()<pBid-(TrailingStop+TrailingStep-1)*pp) {
        ModifyStopLoss(pBid-TrailingStop*pp);
        return;
      }
    }
  }
  if (OrderType()==OP_SELL) {
    pAsk = MarketInfo(OrderSymbol(), MODE_ASK);
    if (!ProfitTrailing || OrderOpenPrice()-pAsk>TrailingStop*pp) {
      if (OrderStopLoss()>pAsk+(TrailingStop+TrailingStep-1)*pp || OrderStopLoss()==0) {
        ModifyStopLoss(pAsk+TrailingStop*pp);
        return;
      }
    }
  }
}

void ModifyStopLoss(double ldStopLoss) 
{
  bool fm;

  fm=OrderModify(OrderTicket(),OrderOpenPrice(),ldStopLoss,OrderTakeProfit(),0,CLR_NONE);
  if (fm && UseSound) PlaySound(NameFileSound);
}
 
Фиксированно-пропорциональный метод выбора размера позиции (Р. Джонс)
Фиксированно-пропорциональный метод выбора размера позиции (Р. Джонс)
  • 2011.07.24
  • www.mql5.com
Когда-то давно читал книгу Р. Джонса, посвященную различным стратегиям управления капиталом (Биржевая игра. Сделай миллионы, играя числами...
 
 Iurii Tokman:


Thanks for the indicator, I recommend Iurii Tokman's services to everyone:
 
Thank you dear gss for your interest in my request. This is the reason why I decided to address the MQL4 guru. The code I have posted works. I have collected it from various Expert Advisors, or rather one of them, I took only Trailing Stop function. The rest I have made up myself (concerning pending orders). I would like to ask you and other gurus to take a look at my code and add two more functions to this robot, if you would not mind.
1) To delete a pending order when one of them triggers.
2) Automatic lot increase (for each 50$ 0.01 i.e. for 100$ it will be 0.02)
Thank you in advance.

 

Hi all, check out my idea for an indicator, so as not to spam all posts, here is the link

https://www.mql5.com/ru/forum/35071/page144#comment_22289427

Напишу советник бесплатно
Напишу советник бесплатно
  • 2021.05.08
  • www.mql5.com
если у вас есть хороая стратегия, и вы готовы ей поделиться,могу написать советника. приглашаю обсудить публично...
 
Guys who can write a simple EA?
Placing both buy and sell orders as soon as one of them closes opens the same orders with the same lot buy and sell, etc.
 
i.e. if there is a difference in settlements or bays there should always be a pending order for a difference of say 13 pips.

i. e.if the deal is in profit i.e. the order advances --- i.e. in case of reverse movement the lock will be positive.

2.In the case of opening any part of the lock, an order for the difference should be placed.

seems to be all. Once again --- the Expert Advisor should not close by itselfwithout any additional buttons on the chart.