Who can help with the robot, why isn't it working? - page 2

 
Alexey Volchanskiy:

The language rules do not allow parameters with default values to be swallowed. If you have to set the colour of the arrows, write all parameters to the left of the colour. B slippage 3 is not enough, if it is 5 digits, there will be requotes, I wrote 50. And SL and TP should not be set equal to zero,Aleksey Vakhrushev has already written about it.


It is an error:

Return value of 'OrderSend' should be checked
 
GIM:

Error:

Return value of 'OrderSend' should be checked
This is just a warning. The file will compile.
 

Good afternoon please help.EA only opens for sale.


extern double Lots=0.1;
extern int FastMAPeriod=14;
extern int FastMAMethod=0; // 0-SMA, 1-EMA, 2-SMMA, 4-LWMA
extern int FastMAPrice=0; // 0-Close, 1-Open, 2-High, 3-Low, 4-Median, 5-Typical, 6-Weighted
extern int SlowMAPeriod=42;
extern intn SlowMAMethod=0; // 0-SMA, 1-EMA, 2-SMMA, 4-LWMA
extern int SlowMAPrice=0; // 0-Close, 1-Open, 2-High, 3-Low, 4-Median, 5-Typical, 6-Weighted
extern int TP=0; //takeprofit
extern int SL=0; //stop loss

int BuyTicket,SellTicket;



int start(){

double fast_ma1=iMA(NULL,0,FastMAPeriod,0,FastMAMethod,FastMAPrice,1);
double slow_ma1=iMA(NULL,0,SlowMAPeriod,0,SlowMAMethod,SlowMAPrice,1);
double fast_ma2=iMA(NULL,0,FastMAPeriod,0,FastMAMethod,FastMAPrice,2);
double slow_ma2=iMA(NULL,0,SlowMAPeriod,0,SlowMAMethod,SlowMAPrice,2);


if(fast_ma1>slow_ma1 && !(fast_ma2>slow_ma2)){
if(SellTicket!=0){ //True if SellTicket is not 0 ;

SellTicket=0;
}
if(BuyTicket==0){ //// True if BuyTicket is 0;
BuyTicket=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,SL=Ask-SL*Point,Ask+TP*Point,NULL,0,0,CLR_NONE);
}
}
if(fast_ma1<slow_ma1 && !(fast_ma2<slow_ma2)){
if(BuyTicket!=0){ //true if BuyTicket is not 0 ;
BuyTicket=0;
}
if(SellTicket==0){ //True if(SellTicket equals 0
SellTicket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid-SL*Point,Bid+TP*Point,NULL,0,0,CLR_NONE);
}
}

return(0);
}

 
Alexey Kozitsyn:
This is just a warning. The file will compile.
Well it still doesn't open the deal.....
 
GIM:
Still not opening the deal.....
Well, I guess that's not the case... Although it might be worth a look in the logbook to see what it says... Well, that's just an option.
 
Alexey Kozitsyn:
Well, I guess it wasn't meant to be... Although it might be worth a look in the magazine to see what it says... Well, that's an option.
Thank you! (Laughs) I'll keep trying))
 
AdikAmir:

Good afternoon please help. The advisor opens only to sell.


extern double Lots=0.1;
extern int FastMAPeriod=14;
extern int FastMAMethod=0; // 0-SMA, 1-EMA, 2-SMMA, 4-LWMA
extern int FastMAPrice=0; // 0-Close, 1-Open, 2-High, 3-Low, 4-Median, 5-Typical, 6-Weighted
extern int SlowMAPeriod=42;
extern intn SlowMAMethod=0; // 0-SMA, 1-EMA, 2-SMMA, 4-LWMA
extern int SlowMAPrice=0; // 0-Close, 1-Open, 2-High, 3-Low, 4-Median, 5-Typical, 6-Weighted
extern int TP=0; //takeprofit
extern int SL=0; //stop loss

int BuyTicket,SellTicket;



int start(){

double fast_ma1=iMA(NULL,0,FastMAPeriod,0,FastMAMethod,FastMAPrice,1);
double slow_ma1=iMA(NULL,0,SlowMAPeriod,0,SlowMAMethod,SlowMAPrice,1);
double fast_ma2=iMA(NULL,0,FastMAPeriod,0,FastMAMethod,FastMAPrice,2);
double slow_ma2=iMA(NULL,0,SlowMAPeriod,0,SlowMAMethod,SlowMAPrice,2);


if(fast_ma1>slow_ma1 && !(fast_ma2>slow_ma2)){
if(SellTicket!=0){ //True if SellTicket is not 0 ;

SellTicket=0;
}
if(BuyTicket==0){ //// True if BuyTicket is 0;
BuyTicket=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,SL=Ask-SL*Point,Ask+TP*Point,NULL,0,0,CLR_NONE);
}
}
if(fast_ma1<slow_ma1 && !(fast_ma2<slow_ma2)){
if(BuyTicket!=0){ //true if BuyTicket is not 0 ;
BuyTicket=0;
}
if(SellTicket==0){ //True if(SellTicket equals 0
SellTicket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid-SL*Point,Bid+TP*Point,NULL,0,0,CLR_NONE);
}
}

return(0);
}

It's a strange code I haven't seen before.

The BuyTicket and SellTicket variables will be equal to zero or incomprehensible each time a new tick arrives because they are not initialized.

The construct if(fast_ma1>slow_ma1 && !(fast_ma2>slow_ma2)) is not clear at all when translated into human language this condition looks like this

if fast_ma1 is greater than slow_ma1 AND NOT fast_ma2 is greater than slow_ma2. The ! operator means negation this way: if(fast_ma1>slow_ma1 && (fast_ma2<slow_ma2))

Your condition holds when fast_ma1>slow_ma1 = true (true) and fast_ma2>slow_ma2 = false (false)

....
if (OrdersTotal()==0)
{
  if (условие на покупку)
  {
    ticet = OrderSend(Symbol(),OP_BUY,.....);
    if (ticet==0) Print("ERROR");
  }
  if (условие на продажу)
  {
    ticet = OrderSend(Symbol(),OP_SELL,.....);    
    if (ticet==0) Print("ERROR");
  }

}
//Простейший код для примера.
 
Vitalii Ananev:

This is a strange code I haven't seen before.

The BuyTicket and SellTicket variables will be equal to zero or incomprehensible each time a new tick arrives because they are not initialized.

The construct if(fast_ma1>slow_ma1 && !(fast_ma2>slow_ma2)) is not clear at all when translated into human language this condition looks like this

if fast_ma1 is greater than slow_ma1 AND NOT fast_ma2 is greater than slow_ma2. The ! operator means negation this way: if(fast_ma1>slow_ma1 && (fast_ma2<slow_ma2))

Your condition holds when fast_ma1>slow_ma1 = true (true) and fast_ma2>slow_ma2 = false (false)

I put your code anyway Sell position is not opened, its BUY only.
 
AdikAmir:
I put your code still doesn't open Sell position, just BUY.

extern double Lots=0.1;
extern intnal double FastMAPeriod=5;
extern int FastMAMethod=0; // 0-SMA, 1-EMA, 2-SMMA, 4-LWMA
extern int FastMAPrice=0; // 0-Close, 1-Open, 2-High, 3-Low, 4-Median, 5-Typical, 6-Weighted
extern int SlowMAPeriod=75;
extern intn SlowMAMethod=3; // 0-SMA, 1-EMA, 2-SMMA, 4-LWMA
extern int SlowMAPrice=3; // 0-Close, 1-Open, 2-High, 3-Low, 4-Median, 5-Typical, 6-Weighted
extern int TP=500; //takeprofit
extern int SL=250; //stop loss
double ticet;

int start(){

double fast_ma1=iMA(NULL,0,FastMAPeriod,0,FastMAMethod,FastMAPrice,1);
double slow_ma1=iMA(NULL,0,SlowMAPeriod,0,SlowMAMethod,SlowMAPrice,1);
double fast_ma2=iMA(NULL,0,FastMAPeriod,0,FastMAMethod,FastMAPrice,2);
double slow_ma2=iMA(NULL,0,SlowMAPeriod,0,SlowMAMethod,SlowMAPrice,2);

if (OrdersTotal()==0)
{
if (fast_ma1>slow_ma1 && (fast_ma2<slow_ma2))
{ ticet = OrderSend(Symbol(),OP_BUY,0.1,Ask,3,Ask-SL*Point,Ask+TP*Point,NULL,0,0,CLR_NONE);
if (ticet==0) Print("ERROR");
}
if (slow_ma1>fast_ma1 && (slow_ma2<fast_ma2))
{
ticet = OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid-SL*Point,Bid+TP*Point,NULL,0,0,CLR_NONE);
if (ticet==0) Print("ERROR");
}

}

return(0);
}




 
We need to change signs when calculating SL /TP
ticet = OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+SL*Point,Bid-TP*Point,NULL,0,0,CLR_NONE);