Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 322

 
borilunad:
I understand that! But how can we program this variable ("specified spread")? Sure, I can create a variable Spread and change it every time I change the spread in the tester. Say, Spread(TestGenerator) or there's some function, or you can somehow make such a function, it can't be that you can't! А?


There is a set spread, when testing,

but with most DCs it is variable. If you want, take it into account in the tester. In general, test the Expert Advisors at the most unfavourable conditions. I.e. with maximal spread, with possible delays in order opening, etc.

 
Sepulca:


There is a specified spread, when testing,

but with most DCs it is variable. If you want, take it into account in the tester. In general, test the Expert Advisors at the most unfavourable conditions. I.e. with maximal spread, with possible delays in order opening, etc.

I understand and do everything! Just wanted to reflect the spread I set in the prog, because in the tester Ask is often distorted, then find it through Bid+spread! See branch MarketInfo does not work in the tester! Then you'll know what's wrong! Asked there, and no one! Therefore moved here, there responded, for which you and others thank you!
 
Colleagues! Please help me to fit a ready-made function into an EA
 

Here is the function

bool isFlagHistoryPos(int mn=-1) {

datetime t;

int gd = MarketInfo(Symbol(),MODE_DIGITS);

int i, j=-1, k=OrdersHistoryTotal();

for (i=0; i<k; i++) {

if(OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {

if (OrderSymbol()==Symbol()) {

if (OrderType()==OP_BUY || OrderType()==OP_SELL) {

if (mn<0 || OrderMagicNumber()==mn) {

if (t<OrderCloseTime()) {

t=OrderCloseTime();

j=i;

}

}

}

}

}

}

if(OrderSelect(j, SELECT_BY_POS,MODE_HISTORY)) {

double ocp=NormalizeDouble(OrderClosePrice(),gd);

double otp=NormalizeDouble(OrderTakeProfit(),gd);

if(MathAbs(ocp-otp)/Point<=TPpoint) return(true);

}

return(false);

The Expert Advisor itself is attached

/* Decompiled by Vinin */

 
borilunad:
Yes I understand and do everything! Just wanted the spread I'm setting to be reflected in the prog, as Ask is often distorted in the tester, then find it via Bid+spread! See branch MarketInfo does not work in the tester! Then you'll know what's wrong! Asked there, and no one! Therefore moved here, there responded, for which you and others thank you!

Shit, Boris. I've written before. Well, you can imitate a floating spread right in the Expert Advisor. What prevents me from adding a random number in the floating spread's range to the bid, and open it with stop orders. And close by value, not by stop orders. It's more complicated than just setting a larger static spread, but if you really need it, you can do it. At the same time set the minimum spread in the tester.

It's just that... a line of thought.

 
artmedia70:

Shit, Boris. I've written before. Well, make a simulated floating spread right in your EA. What's stopping you from adding a random number in the floating spread range to the bid and opening with stop orders. And close by value, not by stop orders. It's more complicated than just setting a larger static spread, but if you really need it, you can do it. At the same time, in the tester, set the minimum spread.

This is just ... A way of thinking.

Thanks Artem, that's wiser in a good way! I will do so!
 

Help with the problem, please) I wrote an Expert Advisor that works by crossing waving, but when I try to test it, the terminal beeps and does not test anything (compiler code likes it. How to make it at least something to show?

#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"


#property indicator_chart_window
#property indicator_buffers 1
#property  indicator_color1 Red
//---- indicator parameters
extern int RPeriod=13;
extern int RPrice=PRICE_CLOSE;
extern int RMethod=MODE_EMA;
//для желтой
extern int YPeriod=30;
extern int YPrice=PRICE_CLOSE;
extern int YMethod=MODE_EMA;
extern int Magic=17051994;
//профит и лось
extern int TakeProfit=150;
extern int StopLoss=30;
extern double lot=0.1;
double movingred,movingellow,SL,TP,movingred2,movingellow2;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
  
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
int kolpos=0,pos;  
     movingred=iMA(Symbol(),0,RPeriod,0,RMethod,RPrice,1);
     movingellow=iMA(Symbol(),0,RPeriod,0,RMethod,RPrice,1);
     movingred2=iMA(Symbol(),0,RPeriod,0,RMethod,RPrice,2);
     movingellow2=iMA(Symbol(),0,RPeriod,0,RMethod,RPrice,2);
         
        for(pos=0;pos <OrdersTotal();pos++)//считаю ордера чтобы советник не трогал в ручную выставленные ордера
        {
        OrderSelect(pos,SELECT_BY_POS,MODE_TRADES);
            if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic )
            {
            kolpos++;
            }
        }
        if (kolpos==0)
         {
              //условвие для покупок продаж
              if(movingred2>movingellow2 && movingred<movingellow && Volume[0]<5)//продаем 
                  {
                    OrderSend(Symbol(),OP_SELL,lot,Bid,10,Bid+StopLoss*Point,Bid-TakeProfit*Point,NULL,Magic,0,Green);
                  }
              if(movingred2<movingellow2 && movingred>movingellow && Volume[0]<5)//покупаем
                  {
                    OrderSend(Symbol(),OP_BUY,lot,Ask,10,Ask-StopLoss*Point,Ask-TakeProfit*Point,NULL,Magic,0,Red);
                  }
          }
   return(0);
  }
 
LBatters:

Help with the problem, please) I wrote an Expert Advisor that works by crossing waving, but when I try to test it, the terminal beeps and does not test anything (compiler code likes it. How to make it at least something to show?

Do you ever look at what you've written?!

Something tells me that "this is where the problem lies":

     movingred=iMA(Symbol(),0,RPeriod,0,RMethod,RPrice,1);
     movingellow=iMA(Symbol(),0,RPeriod,0,RMethod,RPrice,1);
     movingred2=iMA(Symbol(),0,RPeriod,0,RMethod,RPrice,2);
     movingellow2=iMA(Symbol(),0,RPeriod,0,RMethod,RPrice,2);
 
LBatters:

Help with the problem, please) I wrote an Expert Advisor that works on crossing waving, but when I try to test it, the terminal beeps and does not test anything (compiler code likes. How to make it so that he at least something to show?

//считаю ордера чтобы советник не трогал в ручную выставленные ордера

Where will he touch it? Yes and it is enough to check the magician, manual without magician.


And, as written above, the mashes don't overlap...

 
999666:

Here's the function

The advisor itself is attached


Strange variable names, the decompiler does that)))
Reason: