[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 232

 

Dmido писал(а) >>

Good day)


I am coming back to you with a question. I avoided it for a long time due to my lack of understanding of pending orders in EAs, but finally I got stuck. I do not understand how to set price in pending order. What should I add instead of BID and ASK? Can I use any variable calculated before that? Then, how should I set this price so that it would pass later, when placing an order? I get a lot of errors saying that there is no such a price and so on.....


If you do not mind, you may explain your answer in code... All I searched so much, but it says so sideways...(((

In the quality of values Ask and Bid on idea should act the current values of Ask and Bid, or variables calculated earlier.

There is one peculiarity here: you can take these values as real ones only for Buy and Sell orders.


The best thing is to make the opening of all orders in the form of at least 6 procedures, i.e: OrderSendBuy, OrderSendSell, OrderSendLimitBuy, OrderSendLimitSell, OrderSendStopBuy and OrderSendStopSell.


PS

It should be noted that limit orders are opened at the best price (with an indent from the current price by a certain number of points), and stop orders are placed in the opposite direction above or below the current price.


Example of an opening code from the market:

//Procedure OrderSendBuy
void OrderSendBuy(string WorkSymbol, double LotsSize=0, int Slippage=3,int SizeSL=0, int SizeTP=100,
string Text=NULL, int MN=0, datetime Expiration=0, color OrdrtColor=CLR_NONE)
{
//----------------------------------------------------------------------------//
// Служебные переменные
double RealAsk, RealBid; //Текущие Ask и Bid инструмента
double SymbolPoint; //Размер пункта текущего инструмента
double SL, TP; // StopLoss и TakeProfit будущей позиции

int TicketNew; //Тикер новой позиции (в случае удачи, иначе -1)
//----------------------------------------------------------------------------//
//Зашита от дурака
  if( LotsSize<MarketInfo( WorkSymbol,MODE_MINLOT)){ LotsSize = MarketInfo( WorkSymbol,MODE_MINLOT);}

//Расчет параметров для новой позиции
SymbolPoint = MarketInfo( WorkSymbol,MODE_POINT); //Определяем размер пункта
RealAsk = MarketInfo( WorkSymbol,MODE_ASK); //Определяем Ask
RealBid = MarketInfo( WorkSymbol,MODE_BID); //Определяем Bid

if( SizeTP>0){ TP = RealAsk+ SizeTP* SymbolPoint;}else{ TP = RealAsk+100* SymbolPoint;}
if( SizeSL>0){ SL = RealBid- SizeSL* SymbolPoint;}else{ SL = 0;}
//Попытка открыть позицию с рынка
TicketNew = OrderSend( WorkSymbol,OP_BUY, LotsSize, RealAsk, Slippage, SL, TP, Text, MN, Expiration, OrdrtColor);
//Проверка ошибок возникших при открытии новой позиции
if( TicketNew==-1)
//При открытии произошла ошибка
{
Print("Попытка открыть Market-Buy позицию по паре ", WorkSymbol," окончилась неудачно. Код ошибки #",GetLastError())
;}
else
//Позиция успешно установлена
{
Print("Успешно создана позиция Market-Buy по паре ", WorkSymbol," Тикер новой позиции #", TicketNow);
Alert("Open market-Buy, ticket ", TicketNew," Open price ", RealAsk," Profit ", TP," SL ", SL);
}
//----------------------------------------------------------------------------//
}


 

Example code for setting a pending order:

//Procedure OrderSendLimitBuy
void OrderSendLimitBuy(string WorkSymbol, double LotsSize=0, int Slippage=3,int LimitStep=50,int SizeSL=0, int SizeTP=100,
string Text=NULL, int MN=0, datetime Expiration=0, color OrdrtColor=CLR_NONE)
{
//----------------------------------------------------------------------------//
// Служебные переменные
double RealAsk, RealBid; //Текущие Ask и Bid инструмента
double OpenPrice; //Цена на которую будет установлен отложник

double SymbolPoint; //Размер пункта текущего инструмента
double SL, TP; // StopLoss и TakeProfit будущей позиции

int TicketNew; //Тикер новой позиции (в случае удачи, иначе -1)
//----------------------------------------------------------------------------//
//Зашита от дурака
  if( LotsSize<MarketInfo( WorkSymbol,MODE_MINLOT)){ LotsSize = MarketInfo( WorkSymbol,MODE_MINLOT);}

//Расчет параметров для новой позиции
SymbolPoint = MarketInfo( WorkSymbol,MODE_POINT); //Определяем размер пункта
RealAsk = MarketInfo( WorkSymbol,MODE_ASK); //Определяем Ask
RealBid = MarketInfo( WorkSymbol,MODE_BID); //Определяем Bid

OpenPrice = RealAsk- LimitStep* SymbolPoint; //Цена на которую будет установлен отложник

if( SizeTP>0){ TP = OpenPrice+ SizeTP* SymbolPoint;}else{ TP = OpenPrice+100* SymbolPoint;}
if( SizeSL>0){ SL = RealBid-( SizeSL+ LimitStep)* SymbolPoint;}else{ SL = 0;}
//Попытка открыть позицию с рынка
TicketNew = OrderSend( WorkSymbol,OP_BUYLIMIT, LotsSize, OpenPrice, Slippage, SL, TP, Text, MN, Expiration, OrdrtColor);
//Проверка ошибок возникших при открытии новой позиции
if( TicketNew==-1)
//При открытии произошла ошибка
{
Print("Попытка создать Limit-Buy по паре ", WorkSymbol," окончилась неудачно. Код ошибки #",GetLastError())
;}
else
//Позиция успешно установлена
{
Print("Успешно создан ордер Limit-Buy по паре ", WorkSymbol," Тикер ордера #", TicketNow);
Alert("Create Limit-Buy, ticket ", TicketNew," Open price ", OpenPrice," Profit ", TP," SL ", SL);
}
//----------------------------------------------------------------------------//
}
 

Hello.

I am testing an EA.

Period Day (D1) 2008.09.01 00:00 - 2009.08.31 00:00 (2008.09.01 - 2009.09.01)
Model All ticks (the most accurate method based on all smallest available timeframes)
Bars in history 1259 Modelled ticks 8769661 Modeling quality n/a
Chart mismatch errors 225

I am getting mismatch errors. Is there any way to avoid them? I don't understand if this is a large or small number of errors. The scale is predominantly green and dark green, but only about 20% full. And the simulation quality is n/a - is that a problem?

Maybe I shouldn't even pay attention, I just don't understand ...

Thanks in advance.

 
RedFish >> :

Hello.

I am testing an EA.

Period Day (D1) 2008.09.01 00:00 - 2009.08.31 00:00 (2008.09.01 - 2009.09.01)
Model All ticks (the most accurate method based on all smallest available timeframes)
Bars in history 1259 Modelled ticks 8769661 Modeling quality n/a
Chart mismatch errors 225

I am getting mismatch errors. Is there any way to avoid them? I don't understand if this is a large or small number of errors. The scale is predominantly green and dark green, but only about 20% full. And the simulation quality is n/a - is that a problem?

Maybe I shouldn't even pay attention, I just don't understand ...

Thanks in advance.

I don't know I personally never bother with such things (as I almost always test strategies without visualization).


Here is what I got on Jew D1 with a similar testing period

Attempt #1: bars in history - 1302 ticks simulated - 4313293 Quality of simulation - 50.00%

Attempt #2: Bars in history - 1303 Modelled ticks - 4323442 Modelling quality - 50.00%
Chart mismatch errors - 0.

 
Interesting писал(а) >>

Don't know I personally never bother with such things (as I almost always test strategies without visualisation).

Here is what I got on Jew D1 with a similar testing period

Attempt #1: bars in history - 1302 ticks simulated - 4313293 Quality of simulation - 50.00%

Try #2: History: 1303 bars - 1303 ticks simulated - 4323442 Modeling quality - 50.00%
Error of chart mismatch - 0.

Thank you.

I am thinking now that MT automatically fills the last 512 bars and fills the rest .... I don't know how to say it exactly. My Expert Advisor is a trend one and the distance is important to me. 512 bars is not too much.

As for the other symbols, it can be downloaded from a separate site and downloaded later?

I thank you.

 

Good afternoon, dear friends.

I've been dumb lately, maybe it's the weather.

Can you please tell me how to declare a one-dimensional array (in an indicator), if the number of elements of the array is set by an external variable.

Thank you.

 
RedFish >> :

Hello.

I am testing an EA.

PeriodDay (D1) 2008.09.01 00:00 - 2009.08.31 00:00 (2008.09.01 - 2009.09.01)
ModelAll ticks (the most accurate method based on all smallest available timeframes)
Bars in history1259Modelled ticks8769661Modeling qualityn/a
Chart mismatch errors225

I am getting mismatch errors. Is there any way to avoid them? I don't understand if this is a large or small number of errors. The scale is predominantly green and dark green, but only about 20% full. And the simulation quality is n/a - is that a problem?

Maybe I shouldn't even pay attention, I just don't understand ...

Thanks in advance.

My below IMHO, but being quotes- please correct me if I'm wrong:

The point is that Close 59th minute, Close 45th minute on M15, Close 30th minute on M30 and Close on H1 may NOT coincide.

To coincide, you need to kill your own history, by downloading the history from the server of quotes for a smaller period

and recalculate all timeframes using the downloaded history.

In this case, the real Close on different timeframes may also not coincide.

In other words, you should take the smaller timeframe and read the values of the larger timeframe with your HAND.

 
alderru >> :

Good afternoon, dear friends.

I've been dumb lately, maybe it's the weather.

Can you please tell me how to declare a one-dimensional array (in an indicator), if the number of elements of the array is set by an external variable.

Thank you.

int y[];

extern int blah-blah = 100;

init() {

ArrayResize(y, blah-blah);

}

 
jartmailru писал(а) >>

My below IMHO, but being quotes, please correct me if I'm wrong:

The fact is that Close 59th minute, Close 45th on M15, Close 30th on M30 and Close on H1 may NOT match.

To coincide, you need to kill your own history, by downloading history from the server of quotes for a smaller period

and recalculate all timeframes using the downloaded history.

In this case, the real Close on different timeframes may also not coincide.

That is, in a good way, you should take the smaller timeframe and read the values of the larger timeframe.

О! Hands!!!

Thanks for the answer. But judging from the first part, I understand that the errors are not critical for me. Thanks a lot for explaining the mechanism of these errors.

 
Gentlemen the problem in the code can help!
for ( shift = CountBars; shift>=0; shift--) 
{ 
         cci1 = iCCI(NULL, 0, kCCI, PRICE_TYPICAL, shift-1);
         cci2 = iCCI(NULL, 0, kCCI, PRICE_TYPICAL, shift);  

         if ( cci1>100) // (b4plusdi>b4minusdi && nowplusdi<nowminusdi)
         {
         val1[ shift]=Low[ shift]-5*Point;
         if ( flagval2==0) { Alert("не забудь отправить письмо о БАЙ"); flagval2=1; flagval1=0;}
         }
         if ( cci1<-100) //(b4plusdi<b4minusdi && nowplusdi>nowminusdi) 
         {
         val2[ shift]=High[ shift]+5*Point;
         if ( flagval1==0) { Alert("не забудь отправить письмо о СЕЛЛ"); flagval2=0; flagval1=1;}
         }
   }
   return(0);
}

at the very top:

int flagval1=0;
int flagval2=0;

I'm struggling specifically with these flags, can anyone take a fresh look?

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

and there's also a problem with the EA code:

//---------------------------------------------------------------- 5.1 
   cci1 = iCCI(NULL, 0, kCCI, PRICE_TYPICAL, 1);

   if ( New_Bar==true && cci1>100 && flagval2==1)                // && MA_3_t==0   && wayDOWN==true
     {                                            
         Opn_B=true; New_Bar=false; Cls_S=true;                                  
         flagval1=1;
         flagval2=0;
     }
     
   if ( New_Bar==true && cci1<-100 && flagval1==1)                 // && MA_4_t==0  && wayUP==true
     {                                                   
         Opn_S=true; New_Bar=false; Cls_B=true;
         flagval2=1;
         flagval1=0;
     }
//--------------------------------------------------------------- 6 --

it's not trading! Maybe someone will have a fresh look at it.

decided to stupid as soon as the 100 (-100) goes to trade!

I attach EA!

Files:
stoch_cros.mq4  17 kb
Reason: