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

 

In the simplest case, the test allows you to check if the Expert Advisor can give profit with the set parameters (Stop Loss, Take Profit, Trailing Stop, etc.).

See the article - Testing and Optimizing of Expert Advisors

 
Please advise an EA that places orders only in one direction (set) with a set TP immediately after the previous order is closed.
 
yosuf:
Can you suggest an EA that places orders only in one direction (set) with a set TP immediately after the previous order is closed?

approximately like this:

extern string  S0             = "cmd >=0 - ордера BUY";
extern string  S1             = "cmd < 0 - ордера SELL";
extern int     cmd            = 1;
extern int     StopLoss       = 500;       // уровень Stop Loss для выставляемого ордера
extern int     TakeProfit     = 500;       // уровень Take Profit для выставляемого ордера
extern double  Lot            = 0.1;       // обьем / лот ордера
extern int     Magic          = 20122012;  // магическое число ордера

int init(){
return(0);
}
int deinit(){
return(0);
}
int start(){
   int ord_cmd;
   if(Myorders()<1){
      if(cmd<0) ord_cmd = OP_SELL; else ord_cmd = OP_BUY;
      OpenOrder(ord_cmd,TakeProfit,StopLoss,Lot);
   }
return(0);
}
//_______________________________________________________________________
int OpenOrder(int cmd=-1,int TP=0,int SL=0,double lot=0.1) {
   int ticket=-1;
   double sl, tp, pr;
   color col;
   RefreshRates();
   if(cmd >=0){
      switch(cmd){
         case OP_BUY :
                        pr=Ask;
                        if(SL==0) sl=0; else sl=pr-SL*Point;
                        if(TP==0) tp=0; else tp=pr+TP*Point;
                        col = Blue;
                  break;
         case OP_SELL:
                        pr=Bid;
                        if(SL==0.0) sl=0.0; else sl=pr+SL*Point;
                        if(TP==0.0) tp=0.0; else tp=pr-TP*Point;
                        col = Red;
                  break;
      }
      tp=NormalizeDouble(tp,Digits);
      sl=NormalizeDouble(sl,Digits);
      ticket = OrderSend(Symbol(), cmd, lot, pr, 5, sl, tp, "", Magic, 0, col);
 } 
 if (ticket < 0) Print("Ошибка № ",  GetLastError(), " cmd= ",cmd);
return(ticket);
} 
//_______________________________________________________________________
int Myorders(){
      int cnt,total_order,my_total_order;
      total_order = OrdersTotal()-1;
      my_total_order = 0;
      for(cnt = total_order; cnt >= 0; cnt--) {
         OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) {
            if (OrderType() == OP_BUY)  my_total_order++;
            if (OrderType() == OP_SELL) my_total_order++;
         }
      }
return(my_total_order);
}
//_______________________________________________________________________
 
IgorM:

like this:

Thank you, could you please make it out as a ready-to-use advisor, as I am not familiar with the subject. Thank you in advance, you can send it to me privately or here.
 

Guys, my question is, is the market not open today?

 

Now let's rephrase it a bit:

Can you suggest an EA that places a pending order in one direction only (set) with a set TP immediately after the previous order is closed with its former price level and TP.

 
Armagedon_kresh:

Guys, my question is, is the market not open today?

I've got c*****d working, spreads are big.
 

How do I write a number with a mantissa to a variable in MKL4? I couldn't find it by searching the forum.

double eps=2.2204460492503131e-016;

It generates an error...

 
-Aleksey-:

How do I write a number with a mantissa to a variable in MKL4? I couldn't find it by searching the forum.

double eps=2.2204460492503131e-016;

It gives an error...


No way

Although I was doing it for myself

 
yosuf:
I've got C*****d working, spreads are big.
Mine didn't work by 11:00!!! Sorry I have a question!!! I heard there are unreliable brokerage companies that do not let you access the market, and it turns out the trader trades on a computer! As if it turns out cheating! I opened an account with "N***X" have you heard of it??? What are the reviews on it? Is it reliable?
Reason: