[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 289

 
artmedia70:

Have you tried making it a separate function to search for the presence/absence of items?

For example:

Magic - magic number of EA (set in settings, or generated by EA automatically). Then to check the absence of position Buy by current symbol should be written:

Note - not just a command to open a Buy order, but a full function with handling all order opening parameters and errors returned by the server.

However, the tester may do without checking the entered parameters for valid values...



Could you please show this function in full as ready-to-use working code with start function and all descriptions? And better yet, Magic is generated by the EA automatically, i.e. as I understand it, this is the case at the very bottom.

bool ExistPositions(string sy="", int op=-1, int mn=-1) {
   if (sy=="") sy=Symbol();
   for (int i=0; i<OrdersTotal(); i++) {
      if (OrderSelect(i, SELECT_BY_POS)) {
         if (OrderMagicNumber()!=mn)   continue;
         if (OrderSymbol()!=sy)        continue;
         if (OrderType()>1)            continue;
         if (op<0 || OrderType()==op)  
            return(True);
         }
      }
   return(False);
}

if (!ExistPositions(Symbol(), OP_BUY, Magic)) {
   // ... Тут код для вызова функции открытия позиций ... 
   }
 
kolyango:


Could you please show this function in full as ready-to-use working code with start function and all descriptions? And better yet, Magic is generated by the EA automatically, i.e. as I understand it, this is the case at the very bottom.


Magic cannot be generated, if your computer hangs up (power failure, cat steps on the keyboard, ...), at a new start the EA will lose order control (if it does not write magiks to a file).
 
icas:

You cannot generate a magik, if your computer hangs up (loses power, cat steps on the keyboard, ...) when you restart, the EA will lose order control (if it does not write magiks to a file).
It depends on how to generate. My EA is generated using symbol, tf and it's not going anywhere but normally picking up at restart. Picked it up once somewhere and have been using it ever since.
 
snail09:
It depends on how you generate. Mine are generated using a symbol, tf, and they don't go anywhere but pick up normally on restart. Picked it up once somewhere and have been using it ever since.

Can I see an example of how it...
 
snail09:
It depends on how you generate. Mine are generated using a symbol, tf, and they don't go anywhere but pick up normally on restart. Picked it up once somewhere and have been using it ever since.

Interesting, cite the code please.
 

Hi all, again...)

How do I make objects (any objects) show up on the chart in the foreground and NOT behind the candlesticks...? is there a function for this?

 
OvA:

Hi all, again...)

How do I make objects (any objects) show up on the chart in the foreground and NOT behind the candlesticks...? is there a function for this?


There are no layers on the chart (imho), I switch to show bars but not candlesticks, you can get used to it with time.
 
icas:

There are no layers on the chart (imho), I switch to showing bars but not candlesticks, you can get used to it with time.

I see, thanks...

 
Also, how do I remove the script from the chart?
 

Well, here's a rough one. Took it from ikatsko's advisor. Maybe he's the author, maybe not, the style looks like KimIV... I don't know, but I like it, I'm using it now.

MagicNumber=1000+func_Symbol2Val(Symbol())*100+func_TimeFrame_Const2Val(Period());

//+------------------------------------------------------------------+
//| Numeric value for symbol name
//+------------------------------------------------------------------+
int func_Symbol2Val(string symbol) {
     if(symbol=="AUDCAD") {
        return(1);
     } else if(symbol=="AUDJPY") {
        return(2);
     } else if(symbol=="AUDNZD") {
        return(3);
     } else if(symbol=="AUDUSD") {
        return(4);
     } else if(symbol=="CHFJPY") {
        return(5);
     } else if(symbol=="EURAUD") {
        return(6);
     } else if(symbol=="EURCAD") {
        return(7);
     } else if(symbol=="EURCHF") {
        return(8);
     } else if(symbol=="EURGBP") {
        return(9);
     } else if(symbol=="EURJPY") {
        return(10);
     } else if(symbol=="EURUSD") {
        return(11);
     } else if(symbol=="GBPCHF") {
        return(12);
     } else if(symbol=="GBPJPY") {
        return(13);
     } else if(symbol=="GBPUSD") {
        return(14);
     } else if(symbol=="NZDUSD") {
        return(15);
     } else if(symbol=="USDCAD") {
        return(16);
     } else if(symbol=="USDCHF") {
        return(17);
     } else if(symbol=="USDJPY") {
        return(18);
     } else if(symbol=="XAUUSD") {
        return(19);
     } else if(symbol=="XAGUSD") {
        return(20);
     } else if(symbol=="XAUEUR") {
        return(21);
     } else if(symbol=="XAGEUR") {
        return(22);
     } else {
        Comment("unexpected Symbol");
        return(0);
     }
}

//+------------------------------------------------------------------+
//| Time frame interval appropriation function                      |
//+------------------------------------------------------------------+
int func_TimeFrame_Const2Val(int Constant) {
     switch(Constant) {
         case     1: return(1);
         case     5: return(2);
         case    15: return(3);
         case    30: return(4);
         case    60: return(5);
         case   240: return(6);
         case  1440: return(7);
         case 10080: return(8);
         case 43200: return(9);
     }
}