[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 43

 
r772ra:
Alternatively, you can set any time after the signal arrives
My variant implies a limit (after the signal arrives) to perform some actions (in this case to open an order) of 1 minute. And then: if you are late, you are late. Suppose that the connection with the server was interrupted right after the signal was received and then resumed, say, an hour later. Why would you open an order an hour later? ;)
 
TarasBY:

In a global variable, write the time value at the time of the signal:

and then count down your minute (you can do that):

This is one of the solutions to track time after an event occurs.


Unfortunately it doesn't work, after one minute the support line and resistance line should be drawn as an action, but for some reason they are not on the chart. Please take a look at the code, where is the error?


bool  Fact_1 = false;                    // Глобальная перемен для бай.    
bool  Fact_2 = false;                    // Глобальная перемен для бай
bool  Fact_3 = false;                    // Глобальная перемен для бай

double support;
double resist;

 int timeFrame = 5;
 int numBars = 15;
 datetime gdt_TimeSignal;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----

  ObjectsDeleteAll();  
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----


   //---------------------------------------------------------------------------
if (Fact_3==true)                            //Если событие уже..
          
                                              //..было, то выходим
     return(0);
 
//----

  //---- БЛОК ОТКРЫТИЯ  BUY--------------------------------------------------------------
 
 if (iMA(NULL,PERIOD_M5,50,0,MODE_EMA,PRICE_CLOSE,2)<iMA(NULL,PERIOD_M5,200,0,MODE_EMA,PRICE_CLOSE,0)&&
iMA(NULL,PERIOD_M5,50,0,MODE_EMA,PRICE_CLOSE,1)>=iMA(NULL,PERIOD_M5,200,0,MODE_EMA,PRICE_CLOSE,0))//если МА50 пересекает МА200 снизу вверх по M5
Fact_1 = true;       // Произошло событие 1  
//-
if (Fact_1 == true &&  Low[0]<= iMA(NULL,PERIOD_M5,50,0,MODE_EMA,PRICE_CLOSE,0))//если цена опустилась до МА50
 Fact_2 = true; // Произошло событие 2  


//if (Signal) gdt_TimeSignal = TimeCurrent();
if (Fact_2) gdt_TimeSignal = TimeCurrent();


  if (gdt_TimeSignal != 0) if (iBarShift (NULL, 1, gdt_TimeSignal) == 1)
    {
        //---- Открываете ордер
       // OrderSend ();
  //---------------------------------------------------------------------------------    
{
// Определяем линии поддержки\сопротивления
  support = 10000;
  resist = 0;
 
  for(int u = 1;u<=numBars;u++)
  {
   if(support>iLow(Symbol(),timeFrame,u))
     support = iLow(Symbol(),timeFrame,u);
   if(resist<iHigh(Symbol(),timeFrame,u))
     resist = iHigh(Symbol(),timeFrame,u);
  }   
   ObjectSet("lineSupport",OBJPROP_PRICE1,support);
  ObjectSet("lineResist",OBJPROP_PRICE1,resist);
 
 }


 //----
  {
    ObjectCreate("lineSupport",OBJ_HLINE,0,0,0);
    ObjectSet("lineSupport",OBJPROP_COLOR,Blue);
    
    ObjectCreate("lineResist",OBJ_HLINE,0,0,0);
    ObjectSet("lineResist",OBJPROP_COLOR,Red);
    }
//-------------------------------------------------------------
 
        gdt_TimeSignal = 0;
    }



//что сюда добавить что бы линии появившись, оставались на месте?




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

 
TarasBY:

There is nonsense written here:

Read about iCustom().


Thank you. I've read it. Maybe I should look for an example. I don't understand shit.
 
Andrey-F:

Please help me, tell me how to implement EA code in two or three lines:

When a signal comes in (e.g. crossing of two MAs)

1.Expert Advisor determines the time of the signal (in hours, minutes), stores it;

2. counts down one minute.

Then the Expert Advisor is ready to perform an action (e.g. open an order).

All, THANK YOU, everything is working as it should, I just did not insert the signal in the right way.
 

I can't understand the publication of the indicator in Codabase. Like a status is ready for publication ie logically have to wait until the moderator will place in the general access this turkey, but it's been a few days and no result. What can be the problem ?

ps. this is my first publication of the code here

 
madzx:

Yes, I think so ! I've really got the hang of it, I can easily do without writing to disk !
I'm just tying the reins from a standard terminal to another one
I'm just tying up the reins of a standard terminal for another one.)

Forgive me, but we're going to have to do it anyway.
because as sir Freddie Mercury said.
Show must go on!

So let's get the specs straight.
As I understand it:

1. On one account I have a shitload of windows open (10 pieces) with any set of charts of currency pairs

2. On each chart sits a work horse - an Expert Advisor, which does something.

3. The account must meet the following conditions:

3.1 The total number of open market orders in the account must not exceed 5.
Orders of the horse type (pending) should not be counted as such (I believe so, but you did not specify it)
3.2 Based on a set of charts on the account, a certain list of symbols is formed,

The type of financial instruments traded and each of the instruments can have no more than one order open at any one time.

at any one time may have no more than one open order.

---------------------------------------------------------

Something like this! See if everything is correct!
Then please tell us in what language it should be done (like mq4 or mq5)
and list of instances for which you trade - is it fixed or different each time

I think it should be a short paste in the text of each EA

(which you can then file as a procedure if you wish) will allow it

decide about the currently existing permissions for any actions ...

I would like to take my leave now as it is 5 am :))

madzx




Thank you for your participation. But I don't think there's any need.

The problem was solved as follows, as r772ra suggested:

Or maybe like this :

if(NumberOfPositions("EURUSD")==0 && NumberOfPositions()<5)
And here 's a function
 
Roman.:

Don't wander off into the middle of nowhere. You can make exp transactions for unique magic symbols (assign your magic order to YOUR exp on the selected symbols). Then, using the conditional if - else operator, you connect the filter by symbols and magic symbols, using this function from Kim I.V. with different input values:

NumberOfOrders() function.

. That's it.




Thanks, found a simpler solution.
 
Kobalerro:

Thank you, a simpler solution has been found.

OK! Thank you for posting the solution.
 
Kobalerro:

Thank you for your participation. But I don't think there's any more to it.

The problem was solved as follows, as r772ra suggested:

Or maybe like this :

And here is the function

OK! Go with the trend and have a good hunt !!!

madzx
 
Kobalerro:

Thank you for your participation. But I don't think there's any more to it.

The problem was solved as follows, as r772ra suggested:

Or maybe like this :

And here the function

If you are satisfied with this solution, you can simplify the code even further:

if(NumberOfPositions("EURUSD")==0 && OrdersTotal()<5)

But it's probably better to write it like this:

if(NumberOfPositions(Symbol())==0 && OrdersTotal()<5)

If it is not "childish", then Magik should be used (sooner or later, you will want to open a manual order or put another EA near it, too):

if(NumberOfPositions(Symbol(), Magic)==0 && NumberOfPositions("", Magic)<5)

In this case, all EAs should have the same Magik and don't forget to use filters on the Magik and the chart symbol during other operations with the list of orders:

    for (int li_pos = OrderTotal() - 1; li_pos >= 0; li_pos--)
    {
        if (!OrderSelect (li_pos, SELECT_BY_POS, MODE_TRADES)) continue;
        if (OrderMagicNumber() != Magic) continue;
        if (Symbol() != OrderSymbol()) continue;
        //---- дальнейшие опреации (модификация, удаление и т.д.)
    }

I hope you have declared the magik in external variables, or as a constant:

#define Magic  555