Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1824

 
Порт-моне тв #:

I can do it in principle, the hardest thing for me is to write the price to a file and calculate the time

Why write it to a file, you can do it like this?


It's not hard either, the moment you start counting

int iStart  = 0;
int iSeconds=20;
//---
   if(наступило событие)
      iStart=TimeCurrent(); // запомнили время в секундах
//---
   if((iStart+iSeconds)<=TimeCurrent()) // если время пришло
     {
      выполняем действие
     }


 
Tretyakov Rostyslav #:

We will deal with issues as they arise...

First you have to make a table and define what should be there and where, and then write functions

int ticket;
double pricefix;
// if an object was clicked
   if(id==CHARTEVENT_OBJECT_CLICK)
     {
      // if buy button was pressed
      if(sparam=="BuyButton")
        {
         //price fixing
         pricefix = Ask; 
        
        }
     }  
    if(Ask < pricefix - 4*_Point)
    { 
   ticket = OrderSend(_Symbol,OP_BUY,0.01,Ask,3,0,Ask+300*_Point,NULL,0,0,Green);  
    }  
}

I tried to fix the price by pressing the button through a variable, hoping that when the price reaches this variable, the order will be opened, but no miracle happened. Help.

Although the function is theoretically correct, if I put

if(Ask == pricefix)
then the order opens immediately, but I need it to be 4 points lower after remembering
 
Порт-моне тв #:

I was sort of trying to do a price fix via a variable, hoping that when the price equals that variable, an order will open, but no miracle happened. Help.

Although the function is correct in theory, if I set

The order opens immediately but I need it to be 4 pips lower after remembering




//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- 
   ObjectCreate(0,"Button_1",OBJ_BUTTON,0,0,0);
   ObjectSetInteger(0,"Button_1",OBJPROP_XDISTANCE,20);
   ObjectSetInteger(0,"Button_1",OBJPROP_YDISTANCE,20);
   ObjectSetInteger(0,"Button_1",OBJPROP_XSIZE,100);
   ObjectSetInteger(0,"Button_1",OBJPROP_YSIZE,20);
   ObjectCreate(0,"Label_1",OBJ_LABEL,0,0,0);
   ObjectSetInteger(0,"Label_1",OBJPROP_XDISTANCE,20);
   ObjectSetInteger(0,"Label_1",OBJPROP_YDISTANCE,40);
   ObjectSetInteger(0,"Label_1",OBJPROP_CORNER,CORNER_LEFT_UPPER);
   ObjectSetString(0,"Label_1",OBJPROP_TEXT,"Price");
   ObjectSetInteger(0,"Label_1",OBJPROP_COLOR,clrBlack);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
   if(sparam=="Button_1")
     {
      ObjectSetString(0,"Label_1",OBJPROP_TEXT,DoubleToString(Ask-4*_Point,Digits));
     }
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   int ticket;
   double price=StringToDouble(ObjectGetString(0,"Label_1",OBJPROP_TEXT));
   if(Ask<=price) ticket = OrderSend(_Symbol,OP_BUY,0.01,Ask,3,0,Ask+300*_Point,NULL,0,0,clrGreen);  
  }
 

Hi!

I have a question.

Is there any way to remember the maximum drawdown?

I.e. today's drawdown is 16% and 20 days ago it was 5%, so the maximum drawdown is 16% and if tomorrow it is 24% then the maximum drawdown is 24%.

Or it is difficult to remember.

 
Alexander Avksentyev #:

Hi!

I have a question.

Is there any way to remember the maximum drawdown?

I.e. today's drawdown is 16% and 20 days ago it was 5%, so the maximum drawdown is 16% and if tomorrow it is 24% then the maximum drawdown is 24%.

Or it is complicated.

CodeBase has indicators that display the Balance, Equty history from the trading history. There is more than one such tool.

Take the data and calculate it like a normal indicator

 
Maxim Kuznetsov #:

CodeBase has indicators that display Balance, Equty history from the trading history. And there is more than one, such tools.

Take the data and calculate it as for a standard indicator

Well of course you can output to an indicator and do comparisons.

Thank you!!!

 
Tretyakov Rostyslav #:



tried it, it starts opening orders non-stop

 
Порт-моне тв #:

tried it, it starts opening orders non-stop

Right, there is no check for open orders.
 
Tretyakov Rostyslav #:
Right, no check for open orders.

No button release function :)

 
Tretyakov Rostyslav #:
Right, no check for open orders.

I'll try to add it and report back.

Reason: