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

 

Hi all, who can help with the robot, why doesn't it work?

extern double lots = 0.01;
extern double TPforSymbol = 0;
extern double SLforSymbol = 0;

int last_bar= 0;

int start(){
if (last_bar == Bars) return(0);
last_bar = Bars;
if(OrdersTotal() == 0){
OrderSend(Symbol(), OP_BUY, lots ,Ask, 3, Bid - SLforSymbol * Point, Ask + TPforSymbol * Point, 0, Blue);
OrderSend(Symbol(), OP_SELL, lots ,Bid, 3, Ask+ SLforSymbol * Point, Bid - TPforSymbol * Point, 0, Red);
}
return(0);
}

 
Indicates an OrderSend(Symbol() error
 
GIM:
Shows error OrderSend(Symbol()

1. Look up the error code in the logbook.

2. extern double TPforSymbol = 0;

extern double SLforSymbol = 0;

variables equal zero.

 
The fact that the variables are zero is a profit and loss constraint, I don't think it matters here....
 
GIM:
The fact that the variables are zero is a profit and loss constraint, I don't think it matters here....
The error must be 130? It does matter, look, you are trying to open an order with TP and SL values equal to Ask and Bid
 
GIM:

Hi all, who can help with the robot, why doesn't it work?

extern double lots = 0.01;
extern double TPforSymbol = 0;
extern double SLforSymbol = 0;

int last_bar = 0;

int start(){
if (last_bar == Bars) return(0);
last_bar = Bars;
if (OrdersTotal() == 0){
OrderSend(Symbol(), OP_BUY, lots ,Ask, 3, Bid - SLforSymbol * Point, Ask + TPforSymbol * Point, 0, Blue);
OrderSend(Symbol(), OP_SELL, lots ,Bid, 3, Ask + SLforSymbol * Point, Bid - TPforSymbol * Point, 0, Red);
}
return(0);
}

You can't by the rules of the language swallow parameters with default values. If you have to set the colour of the arrows, then write all the 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 be set to values other than zero.Aleksey Vakhrushev has already written about it.

OrderSend(Symbol(), OP_BUY, lots ,Ask, 50, Bid - SLforSymbol * Point, Ask + TPforSymbol * Point,  "", 1, 0, clr Blue);
 

right =)

an order tries to place a stop and a stop at the same place as the price - which is impossible

- either do as below if you want 0

or specifyTPforSymbol, SLforSymbol

OrderSend(Symbol(), OP_BUY, lots ,Ask, 50,0, 0,  "", 1, 0, clrBlue);
 
GIM:

Hi all, who can help with the robot, why isn't it working?


Do you need the opening function correct or do you want to figure out why the errors ?
 
Vladimir Zubov:
Do you want the opening function to be correct or do you want to understand why there are errors?
You want it to open trades.
 
GIM:
It should open deals.

Deal with the variables

extern double TPforSymbol = 0;

extern double SLforSymbol = 0;

With this value of variables you will get an error.

Alexey Volchanskiy wrote that you do not specify all parameters for the OrderSend() function.

 
extern double lots = 0.01;
extern double TPforSymbol = 100;
extern double SLforSymbol = 1000;
extern int stop_loss = 76;
extern int take_profit = 750;

intlast_bar = 0;

int start(){
if (last_bar == Bars) return(0);
last_bar = Bars;
if(OrdersTotal() == 0){
OrderSend(Symbol(), OP_BUY, lots ,Ask, 50, Bid - stop_loss * Point, Ask + take_profit * Point, "", 1, 0, clrBlue);
OrderSend(Symbol(), OP_SELL, lots ,Bid, 50, Ask+ stop_loss * Point, Bid - take_profit * Point, "", 1, 0, clrRed);
}
return(0);

}


Fixed it this way, but it's still wrong.....

Reason: