:)))) Even more burning question. This script opens market orders but does not place pending orders. I messed up again. Could you please tell me what is wrong?
:)))) Even more pressing question. This script opens market orders but does not place pending orders. I messed up again. Can you tell me what is wrong?
I have an EA which ignores manually set orders. The script I am trying to modify is designed to turn a "manual" order into an order with a magic parameter. That's the idea).
nemo811: I have an EA that ignores open orders set "manually". The script that I am trying to modify is designed for turning a "manual" order into an order with a magic parameter. That's the idea).
Good night!
I couldn't figure it out - so I put it off.
But you, too - take your time - study the math!
The language and objects of manipulation are simple...
No, it's just the opposite, than what you've written. Of course, thanks for your attention. I thought hard, figured it out this way and that way, and you're wrong.
Actually, I see that the problem is not with the axes and bits, and I have not solved it yet.
That's a very strange assertion on your part. An apple won't fly upward from the strength of your thoughts, but it will fall on your head...
Or do you live in a particular country, where everything is strictly the other way round: profit - value with a minus? Think about it: buy at 1.0100, sell at 1.0200 (take at this level, i.e. higher than the buy price). We have a 100 points profit. There is no other way. If you try to set the take at the level of 1.0000, you will get error 130 - wrong stops. Take Buy (OP_BUY) cannot be lower than the opening price. And stop - just the opposite - must be lower than the opening price of the Buy position. For Sell it is vice versa - Take is lower than the open price, Stop is higher.
Looks like you not only need to learn maths, but also first grade maths... No offense.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I added lines to the script (added BUYSTOP and SELLSTOP), but it won't compile, it generates errors. Can you please tell me what's wrong?
#property copyright "Copyright © 2010, Khlystov Vladimir".
#property link "cmillion@narod.ru"
#property show_inputs
//--------------------------------------------------------------------
extern int stoploss = 0, //level of SL, if 0, SL is not exhibited
extern int takeprofit = 0, //t TP level, if 0, TP is not exhibited
extern int Magic = 123456; //number of an order
extern bool BUY = false; //open BUY order
extern bool SELL = false; //open SELL order
extern bool BUYSTOP = false, //open BUYSTOP order
extern bool SELLSTOP = false, //open SELLSTOP order
extern double Lot = 0.1; // order volume
extern int slippage = 3; //maximal allowed price deviation for market orders
//--------------------------------------------------------------------
double SL,TP;
//--------------------------------------------------------------------
int start()
{
if (BUY)
{
if (takeprofit!=0) TP = NormalizeDouble(Ask + takeprofit*Point,Digits); else TP=0;
if (stoploss!=0) SL = NormalizeDouble(Ask - stoploss*Point,Digits); else SL=0;
OPENORDER ("Buy");
}
if (SELL)
{
if (takeprofit!=0) TP = NormalizeDouble(Bid - takeprofit*Point,Digits); else TP=0;
if (stoploss!=0) SL = NormalizeDouble(Bid + stoploss*Point,Digits); else SL=0;
OPENORDER ("Sell");
}
if (BUYSTOP)
{
if (takeprofit!=0) TP = NormalizeDouble(Ask + takeprofit*Point,Digits); else TP=0;
if (stoploss!=0) SL = NormalizeDouble(Ask - stoploss*Point,Digits); else SL=0;
OPENORDER ("Buy Stop");
}
if (SELLSTOP)
{
if (takeprofit!=0) TP = NormalizeDouble(Bid - takeprofit*Point,Digits); else TP=0;
if (stoploss!=0) SL = NormalizeDouble(Bid + stoploss*Point,Digits); else SL=0;
OPENORDER ("Sell Stop");
}
return(0);
}
//--------------------------------------------------------------------
void OPENORDER(string ord)
{
int error,err;
while (true)
{ error=true;
if (ord=="Buy" ) error=OrderSend(Symbol(),OP_BUY, Lot,NormalizeDouble(Ask,Digits),slippage,SL,TP, "BUY",Magic,0,Blue);
if (ord=="Sell") error=OrderSend(Symbol(),OP_SELL,Lot,NormalizeDouble(Bid,Digits),slippage,SL,TP, "SELL",Magic,0,Red);
if (ord=="BuyStop" ) error=OrderSend(Symbol(),OP_BUYSTOP, Lot,NormalizeDouble(Ask,Digits),SL,TP, "BUYSTOP",Magic,0,Blue);
if (ord=="SellStop") error=OrderSend(Symbol(),OP_SELLSTOP,Lot,NormalizeDouble(Bid,Digits),SL,TP, "SELLSTOP",Magic,0,Red);
if (error==-1) //failure to buy OK
{
ShowERROR();
err++;Sleep(2000);RefreshRates();
}
if (error || err >10) return;
}
return;
}
//--------------------------------------------------------------------
void ShowERROR()
{
int err=GetLastError();
switch ( err )
{
case 1: return;
case 2: Alert("No connection to the trade server ",Symbol());return;
case 3: Alert("Error incorrect parameters ",Symbol());return;
case 130: Alert("Error close Ticket stops ",Symbol());return;
case 134: Alert("Not enough money ",Symbol());return;
case 146: Alert("Error Trade Subsystem is busy ",Symbol());return;
case 129: Alert("Error Wrong price ",Symbol());return;
case 131: Alert("Error Incorrect volume ",Symbol());return;
case 4200:Alert("Error Object already exists ",Symbol());return;
default: Alert("Error ",err," ",Symbol());return;
}
}
//--------------------------------------------------------------------
Thanks in advance.
can you end the operator with a ";" instead of a ","?
can you end the operator with a ";" instead of a ","?
Thanks, I'm just learning :))) Thanks.
Thank you, I'm just learning :))) Thanks.
Thanks! I'm like that myself... ;)
Thank you! I'm like that myself... ;)
:)))) Even more burning question. This script opens market orders but does not place pending orders. I messed up again. Could you please tell me what is wrong?
:)))) Even more pressing question. This script opens market orders but does not place pending orders. I messed up again. Can you tell me what is wrong?
What is the trading idea behind it?
I have an EA that ignores open orders set "manually". The script that I am trying to modify is designed for turning a "manual" order into an order with a magic parameter. That's the idea).
Good night!
I couldn't figure it out - so I put it off.
But you, too - take your time - study the math!
The language and objects of manipulation are simple...
Execution is sometimes lame?
So there is laxity on both sides.
;)
Corrected the above code. The pendants are not being set. Please help me to find error.
#property copyright "Copyright © 2010, Khlystov Vladimir"
#property link "cmillion@narod.ru"
#property show_inputs
//--------------------------------------------------------------------
extern int stoploss = 0; //level of SL, if 0, SL is not exhibited
extern int int takeprofit = 0; //t TP level, if 0, TP is not exhibited
extern int int Magic = 123456; //number of an order
extern bool BUY = false; //open BUY order
extern bool SELL = false; //open SELL order
extern bool BUYSTOP = false; //open BUYSTOP order
extern bool SELLSTOP = false; //open SELLSTOP order
extern double Lot = 0.1; // order volume
extern int slippage = 3; //maximal allowed price deviation for market orders
extern int DistanceSet = 20; //Market distance
//--------------------------------------------------------------------
double SL,TP;
//--------------------------------------------------------------------
int start()
{
if (BUY)
{
if (takeprofit!=0) TP = NormalizeDouble(Ask + takeprofit*Point,Digits); else TP=0;
if (stoploss!=0) SL = NormalizeDouble(Ask - stoploss*Point,Digits); else SL=0;
OPENORDER ("Buy");
}
if (SELL)
{
if (takeprofit!=0) TP = NormalizeDouble(Bid - takeprofit*Point,Digits); else TP=0;
if (stoploss!=0) SL = NormalizeDouble(Bid + stoploss*Point,Digits); else SL=0;
OPENORDER ("Sell");
}
if (BUYSTOP)
{
if (takeprofit!=0) TP = NormalizeDouble(Ask + takeprofit*Point,Digits); else TP=0;
if (stoploss!=0) SL = NormalizeDouble(Ask - stoploss*Point,Digits); else SL=0;
OPENORDER ("Buy Stop");
}
if (SELLSTOP)
{
if (takeprofit!=0) TP = NormalizeDouble(Bid - takeprofit*Point,Digits); else TP=0;
if (stoploss!=0) SL = NormalizeDouble(Bid + stoploss*Point,Digits); else SL=0;
OPENORDER ("Sell Stop");
}
return(0);
}
//--------------------------------------------------------------------
void OPENORDER(string ord)
{
int error,err;
while (true)
{ error=true;
if (ord=="Buy" ) error=OrderSend(Symbol(),OP_BUY, Lot,NormalizeDouble(Ask,Digits),slippage,SL,TP,"",Magic,0);
if (ord=="Sell") error=OrderSend(Symbol(),OP_SELL,Lot,NormalizeDouble(Bid,Digits),slippage,SL,TP,",Magic,0);
if (ord=="BuyStop" ) error=OrderSend(Symbol(),OP_BUYSTOP, Lot,NormalizeDouble(Ask + DistanceSet*Point,Digits),slippage,SL,TP,"",Magic,0);
if (ord=="SellStop") error=OrderSend(Symbol(),OP_SELLSTOP,Lot,NormalizeDouble(Bid - DistanceSet*Point,Digits),slippage,SL,TP,"",Magic,0);
if (error==-1) //failure to buy OK
{
ShowERROR();
err++;Sleep(2000);RefreshRates();
}
if (error || err >10) return;
}
return;
}
//--------------------------------------------------------------------
void ShowERROR()
{
int err=GetLastError();
switch ( err )
{
case 1: return;
case 2: Alert("No connection to the trade server ",Symbol());return;
case 3: Alert("Error incorrect parameters ",Symbol());return;
case 130: Alert("Error close Ticket stops ",Symbol());return;
case 134: Alert("Not enough money ",Symbol());return;
case 146: Alert("Error Trade Subsystem is busy ",Symbol());return;
case 129: Alert("Error Wrong price ",Symbol());return;
case 131: Alert("Error Incorrect volume ",Symbol());return;
case 4200:Alert("Error Object already exists ",Symbol());return;
default: Alert("Error ",err," ",Symbol());return;
}
}
//--------------------------------------------------------------------
Thanks.
No, it's just the opposite, than what you've written. Of course, thanks for your attention. I thought hard, figured it out this way and that way, and you're wrong.
Actually, I see that the problem is not with the axes and bits, and I have not solved it yet.
That's a very strange assertion on your part. An apple won't fly upward from the strength of your thoughts, but it will fall on your head...
That' s the way it is and nothing else.
Or do you live in a particular country, where everything is strictly the other way round: profit - value with a minus? Think about it: buy at 1.0100, sell at 1.0200 (take at this level, i.e. higher than the buy price). We have a 100 points profit. There is no other way. If you try to set the take at the level of 1.0000, you will get error 130 - wrong stops. Take Buy (OP_BUY) cannot be lower than the opening price. And stop - just the opposite - must be lower than the opening price of the Buy position. For Sell it is vice versa - Take is lower than the open price, Stop is higher.
Looks like you not only need to learn maths, but also first grade maths... No offense.