Discussion on the implementation of councillors. - page 7

 
Hello colleagues, who is able to create an EA based on 2 indicators that would open and close transactions at crossings, see photo, I tried it myself but it did not work(((((
 
katrina87:
Hi collegues, i have a very big request for someone who can create an advisor based on 2 indicators that would open and close trades at crossings, see the picture, i tried it myself but nothing came out(((((

I haven't used it myself. I've just seen it in a kodobase. Check it out, maybe it'll work for you. And by the way there are more advisors like this in kodobase. You can google the site you are looking at. https://www.mql5.com/ru/code/12375

Советник на основе отскока от границы канала МА
Советник на основе отскока от границы канала МА
  • www.mql5.com
Для торговли используются показания индикатора Moving Average. Если цена отклонилась от линии Moving Average на определенное количество пунктов, то выставляется ордер в сторону линии Moving Average. Советник может приносить прибыль, но она получается маленькой. Также для него требуется большой депозит. На рисунке сплошная красная линия —...
 
Hello I would like to write a trading robot, the idea is simple and ingenious. For starters I need a resistance support levels indicator to output the strength of these very levels for example: high middle low. any suggestions? thank you all in advance.
 
paradisehell1:
Hello, I want to write a trading robot, the idea is simple and ingenious. For the beginning I need a resistance support levels indicator to display the strength of these very levels, for example: high middle low. any suggestions? thank you all in advance.

Freelancing will save the Giant of Thought and Father of Russian Democracy.

 
paradisehell1:
Hello, I want to write a trading robot, the idea is simple and ingenious. For example, if I wanted to use a forex robot, I would have to look for a support level indicator that would show the strength of the support and resistance levels, like high, mid, low.

It's not obvious to me that this idea is brilliant. That is why there is no motivation. I can't speak for anyone else, but something tells me it's the same with them. You can make it look like that. They may not be able to trade manually on the demo or real, for a couple of months at least. How much % did you earn in a month, what was the margin level and drawdown. If the indicators are interesting, you can easily find someone who will write them for free. But you can look for something in kodobe. And by the way, the work of the programmers is very cheap on this site.

 
Hello! I am almost 100% sure that my question has been raised many times before. So I would be very grateful if someone could tell me where to look. My question is - how to implement in my Expert Advisor the possibility to stop trading when a certain profit is reached? Suppose the profit was $200 - that's it, we do not trade today.
 
altec3:
Hello! I am almost 100% sure that my question has already been raised many times. So I would be very grateful if somebody could tell me where to look for it. Question - how to implement in an EA the ability to stop trading when a certain profit is reached? Suppose the profit was $200 - that's it, we do not trade today.

Is this for mt4, or should it be for mt5 ?

Immediately before opening a position put a check, if the profit is more than for the period - exit.

void OnTick()
 {
 ...
 if(GetProfitHistoryInCurrency(_Symbol, 0, Magic) > 200) // 0 - сегодня, 1 - вчера, 2 -позавчера
  return;
 
 OrderSend(...);


Please read the whole thread, you will find the code you need:

Forum on trading, automated trading systems and strategy testing

How to calculate the number of closed orders in EA

Vitaly Muzichenko, 2016.04.12 10:36

//===============================================================================================
//---------------------- Возвращает профит за выбранный период с истории -----------------------+
//===============================================================================================
double GetProfitHistoryInCurrency(string symb="0", int index=-1, int mg=-1) {
 if(symb=="0") { symb=Symbol();}
 datetime DailyStartTime=iTime(symb,PERIOD_D1,index);
 double DailyProfit=0;
  for(int i=OrdersHistoryTotal()-1; i>=0; i--) {
   if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)) {
    if((OrderSymbol()==symb || symb=="") && (mg<0 || OrderMagicNumber()==mg)) {
     if((OrderCloseTime()>=DailyStartTime && OrderCloseTime()<DailyStartTime+86400) || index<0)
      DailyProfit+=(OrderProfit()+OrderCommission()+OrderSwap());
 }}}
  return(DailyProfit);
 }
Использование:  GetProfitHistoryInCurrency(_Symbol, 0, Magic); // 0 - сегодня, 1 - вчера, 2 -позавчера

 
Vitaly Muzichenko:

Is this for mt4, or should it be for mt5 ?

Immediately before opening a position put a check, if the profit is more than for the period - exit.


Read the whole thread, the code you need is there:


Thanks, I'll definitely have a look! Yes, and the code is needed for MT5.
 

Good afternoon!

I'm trying to write a function that determines the profit for the current day:

//+------------------------------------------------------------------+
//|Функция возвращает прибыль за текущие сутки                       |
//+------------------------------------------------------------------+
double Day_Profit()
  {
//--Запрашиваем историю сделок за последнии сутки
   HistorySelect(TimeCurrent()-PeriodSeconds(PERIOD_D1),TimeCurrent());
   uint     total       =HistoryDealsTotal();   // количество сделок в истории
   ulong    ticket      =0;                     // тикет сделки в истории
   long     type        =0;                     // тип сделки
   double   profit      =0.0;                   // финансовый результат сделки
   double   commission  =0.0;                   // коммиссия по сделке
   double   DayProfit   =0.0;                   // прибыль за текущие сутки
//--- for all deals
   for(uint i=0; i<total; i++)
     {
      if((ticket=HistoryDealGetTicket(i))>0)       //--- если имеются сделки, то...
        {
         profit      =HistoryDealGetDouble(ticket,DEAL_PROFIT);
         commission  =HistoryDealGetDouble(ticket,DEAL_COMMISSION);
         if(HistoryDealGetInteger(ticket,DEAL_TYPE)!=DEAL_TYPE_BALANCE)
           {
            DayProfit+=(profit+commission);
           }
        }
     }
   return (DayProfit);
  }
//+------------------------------------------------------------------+

Can you tell me how to use the function

HistorySelect (datetime from_date,datetime to_date)
to specify period starting with current day. It is clear that end of period to_date=TimeCurrent(), how to correctly specify start of period from_date, so that it starts from 00h:00m:00c of current day?
 
altec3:
Good afternoon, could you please tell me how to specify the period starting from the current day in the function. It is clear that end of period to_date=TimeCurrent(), how to specify start of period from_date correctly, so it will start from 00h:00m:00 from current day?

Assuming that there was at least one tick today, the algorithm is as follows: the current time is sent to theMqlDateTime structure. Then set the hours, minutes and seconds to zero in this structure. It remains to convert the edited structure into a time:

//+------------------------------------------------------------------+
//|                                                            1.mq5 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   MqlDateTime STimeCurrent;
   TimeToStruct(TimeCurrent(),STimeCurrent);
   STimeCurrent.hour=0;
   STimeCurrent.min=0;
   STimeCurrent.sec=0;
   datetime start_day=StructToTime(STimeCurrent);
   Print(start_day);
  }
//+------------------------------------------------------------------+


Result:

2020.09.03 00:00:00
Files:
1.mq5  3 kb
Reason: