And let's make a "cartoon" out of it (multicurrency)

 

I'd really like to test a few pairs at the same time...

I cannot do it myself... If you can help me to make a multicurrency EA) I will understand the essence of working with several pairs...

I wrote it myself, for five digits... ...and took something from the forum...)

description here)

//+------------------------------------------------------------------+
//|                                            20090717_H4_Candy.mq4 |
//|                      Copyright © 2009, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "LITE"
#property link      "http://www.metaquotes.net"

#include <stdlib.mqh>

extern double Profit = 2000;

double Price[2];
int    giSlippage;

int iOrders, i;
double b0, b1, s0, s1, StopLoss, Enter;
bool dwn, up, mod;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   Profit*=Point; 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
   iOrders=OrdersTotal()-1;//количество отложенных ордеров
   
   if(OrdersTotal()==0){
      mod=false;
      SetOrders();}
   
   if((OrdersTotal()>0) && (AccountProfit())&& (! mod)) SetStop();
   
   if(OrdersTotal()>0){
      if( up) UpTrend();
      if( dwn) DownTrend();}

//----
   return(0);
  }
//+------------------------------------------------------------------+

//-------Удаление всех ордеров
void CloseOpenOrdersAndCancelPending()
   {
    for( i= iOrders; i>=0; i--) {
      if(OrderSelect( i, SELECT_BY_POS, MODE_TRADES)) {
        if((OrderType()<=OP_SELL) && GetMarketInfo()) {
          if(!OrderClose(OrderTicket(),OrderLots(), Price[1-OrderType()], giSlippage)) Print( OrderError());
        }
        else if(OrderType()>OP_SELL) {
          if(!OrderDelete(OrderTicket())) Print( OrderError());
        }
      }
    }
  }

//-------Поиск входа для установки ордеров и удаление всех ордеров
bool UpTrend()
  {
     if((iOpen(NULL,PERIOD_H4,1) - iClose(NULL,PERIOD_H4,1) <= 0) &&
        (iOpen(NULL,PERIOD_H4,2) - iClose(NULL,PERIOD_H4,2) > 0)){
         up=false;
         dwn=true;
         //DeleteAllPendingOrders();
         CloseOpenOrdersAndCancelPending();
         return(true);}
     else 
        return(false);
  }
bool DownTrend()
  {
     if((iOpen(NULL,PERIOD_H4,1) - iClose(NULL,PERIOD_H4,1) >= 0) &&
        (iOpen(NULL,PERIOD_H4,2) - iClose(NULL,PERIOD_H4,2) < 0)){
         up=true;
         dwn=false;
         //DeleteAllPendingOrders();
         CloseOpenOrdersAndCancelPending();
         return(true);}
     else 
         return(false);
  }

//-------Установка ордеров  
 void SetOrders()
   {
      if(UpTrend()){
         Enter=iHigh(NULL,PERIOD_H4,1)+(Ask-Bid)+10*Point;
         RefreshRates();
         OrderSend(Symbol(), OP_BUYSTOP, 0.1, Enter, 0, 0, Ask+Profit, 0, 0,0, Green);}
      
      if(DownTrend()){
         Enter=iLow(NULL,PERIOD_H4,1)-10*Point;
         RefreshRates();
         OrderSend(Symbol(), OP_SELLSTOP, 0.1, Enter, 0, 0, Bid-Profit, 0, 0,0, Green);}
   }
   
//-------Вычисление и утановка стопа
void SetStop()
   {
      RefreshRates();
      b0=iLow(NULL,PERIOD_H4,0)-10*Point;
      b1=iLow(NULL,PERIOD_H4,1)-10*Point;
      s0=iHigh(NULL,PERIOD_H4,0)+(Ask-Bid)+10*Point;
      s1=iHigh(NULL,PERIOD_H4,1)+(Ask-Bid)+10*Point;

      
      if(OrderSelect(0, SELECT_BY_POS)){       
         if(OrderType()==OP_BUY){
            if( b0< b1) StopLoss= b1;
            else StopLoss= b0;
            RefreshRates();
            mod=OrderModify(OrderTicket(),OrderOpenPrice(), StopLoss,OrderTakeProfit(),0,Red);
            if( mod) return(true);}
         else{
            if( s0< s1) StopLoss= s0;
            else StopLoss= s1;
            RefreshRates();
            mod=OrderModify(OrderTicket(),OrderOpenPrice(), StopLoss,OrderTakeProfit(),0,Red);
            if( mod) return(true);
         }
      } 
   }
 
//+------------------------------------------------------------------+
//| Function..: OrderError                                           |
//+------------------------------------------------------------------+
string OrderError() {
  int iError=GetLastError();
  return(StringConcatenate("Order:",OrderTicket()," GetLastError()=", iError));
}

//+------------------------------------------------------------------+
//| Function..: GetMarketInfo                                        |
//| Returns...: bool Success.                                        |
//+------------------------------------------------------------------+
bool GetMarketInfo() {
  RefreshRates();
  Price[0]=MarketInfo(OrderSymbol(),MODE_ASK);
  Price[1]=MarketInfo(OrderSymbol(),MODE_BID);
  double dPoint=MarketInfo(OrderSymbol(),MODE_POINT);
  if( dPoint==0) return(false);
  giSlippage=( Price[0]- Price[1])/ dPoint;
  return( Price[0]>0.0 && Price[1]>0.0);
}



 
ALex2008 писал(а) >>

I'd really like to test a few pairs at the same time...

I cannot do it myself... But I would be grateful if you could help me make a multicurrency EA)

I wrote it myself... I wrote it myself ... and took what I needed from the forum ...)

So maybe just put it on a few pairs.

 
Vinin >> :

So maybe just put it on several pairs.

This will not work, because I wrote for one pair... signals are taken from the current pair, and the work with orders is organised for one pair only(

if(OrdersTotal()==0)...
if(OrdersTotal()>0)...

Of course, I can connect the signals with other pairs... ...but I can't manage orders with them... at least not yet)

 
ALex2008 писал(а) >>

It won't work that way, because I wrote for one pair... signals are taken from the current pair, and work with orders is organised for one pair only(

Maybe someone would like to remake it. >> I am too lazy.

 
Vinin >> :

Maybe someone would like to redo it. I'm too lazy.

We'll wait, then. >> maybe somebody can help.)

 
ALex2008 >> :

I'd really like to test a few pairs at the same time...

I cannot do it myself... but I'd appreciate it if you could help me make a multicurrency EA)

If you want to make a multi-currency EA in a tester, you cannot test it in principle (it generates ticks only for one pair under test). For this purpose one and the same EA should distinguish its own orders and orders of other EAs using the same magic number set for example in its parameters ;)

 
ForexTools >> :

...To do this, the same advisor must be able to distinguish between its own and other people's orders by the same magic set for example in its parameters ;)

In principle, it does not matter for me if it will be a real multi or just distinguish other's orders. I want to trade on several pairs, not on one... I want to try it on a demo for a month or two... I'm just interested in the result...)

 
ForexTools >> :

..To do this, the same EA must distinguish between its own and other people's orders by the same magic set for example in its parameters ;)...

..or automatically generated ;))

 
granit77 >> :

...or automatically generated ;))

I'll put in the code with the magik generator... but what's in it for me... I need to understand the algorithm.)

 

Might help.

int Order_Count[6];
//===============================================================================
// Функция возвращаюшая количество ордеров определенного типа исхода из заданных ограничений
//===============================================================================
void Order_Count_Calculate(string _Symbol, int Magic){
   ArrayInitialize( Order_Count,0);
   for (int i = OrdersTotal() - 1;  i >= 0;  i--) {
      if (!OrderSelect( i, SELECT_BY_POS, MODE_TRADES))   continue;
      if (OrderSymbol() != _Symbol)                      continue;
      if (OrderMagicNumber() != Magic)                   continue;
      Order_Count[OrderType()]++;
   }
}
 

And by the way, you have a lot of mistakes in your code!

iLow(PERIOD_H4,0,0) - what is this?