Price Data Components
Orders Execution
0
Views
0
Downloads
0
Favorites
Pending Orders Master
//+------------------------------------------------------------------+
//| Pending Orders Master.mq4 |
//| MaksimNeimeryk |
//| deilyplanet@ukr.net |
//+------------------------------------------------------------------+
#property copyright "MaksimNeimeryk"
#property link "deilyplanet@ukr.net"
#property version "1.01"
#property strict
#property show_inputs
enum Type
{
BUYLIMIT=OP_BUYLIMIT,
BUYSTOP=OP_BUYSTOP,
SELLLIMIT=OP_SELLLIMIT,
SELLSTOP=OP_SELLSTOP
};
extern Type Order=BUYLIMIT;//Order Type
extern double lot=0.01;//Lot
extern int NumberOrder=5;//Number of Orders
extern int magic=2508;//Magic
extern int Slippage=2;//Slippage
extern double mnog=2;//Multiplier
extern int step=20;//Distance between orders
extern int firstshift=5;//Distance to the first order
extern bool UseShiftPrice=true;//Use price for first order
extern double PriceShift=1.1245;//Price for first order
//double Lot=;
double Price=0.0,ST=0,FS=0,StopLevel=0;
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
Comment("");
StopLevel=NormalizeDouble(MarketInfo(Symbol(),MODE_STOPLEVEL)*Point,Digits);
ST=NormalizeDouble(step*Point,Digits());
FS=NormalizeDouble(firstshift*Point,Digits());
if(Order==OP_BUYLIMIT)
{
if(!UseShiftPrice)
{
Price=Ask-FS;
if((Ask-Price)<StopLevel)
{
Comment("Too close to the market. Use Distance to the first order = ",StopLevel);
return;
}
}
else
{
if(Ask-PriceShift<StopLevel)
{
Comment("Wrong Price!!! Minimum Price for first order = ",DoubleToString(Ask-StopLevel,Digits()));
return;
}
}
}
if(Order==OP_SELLLIMIT)
{
if(!UseShiftPrice)
{
Price=Bid+FS;
if((Price-Bid)<StopLevel)
{
Comment("Too close to the market. Use Distance to the first order = ",StopLevel);
return;
}
}
else
{
if(PriceShift-Bid<StopLevel)
{
Comment("Wrong Price!!! Minimum Price for first order = ",DoubleToString(Bid+StopLevel,Digits()));
return;
}
}
}
if(Order==OP_BUYSTOP)
{
if(!UseShiftPrice)
{
Price=Ask+FS;
if((Price-Ask)<StopLevel)
{
Comment("Too close to the market. Use Distance to the first order = ",StopLevel);
return;
}
}
else
{
if(PriceShift-Ask<StopLevel)
{
Comment("Wrong Price!!! Minimum Price for first order = ",DoubleToString(Ask+StopLevel,Digits()));
return;
}
}
}
if(Order==OP_SELLLIMIT)
{
if(!UseShiftPrice)
{
Price=Bid-FS;
if((Bid-Price)<StopLevel)
{
Comment("Too close to the market. Use Distance to the first order = ",StopLevel);
return;
}
}
else
{
if(Bid-PriceShift<StopLevel)
{
Comment("Wrong Price!!! Minimum Price for first order = ",DoubleToString(Bid-StopLevel,Digits()));
return;
}
}
}
double priceStep=0;
if(!UseShiftPrice)
{
priceStep=Price;
}
else
{
priceStep=PriceShift;
}
for(int count=0; count<NumberOrder; count++)
{
if(!OrderSend(Symbol(),Order,lot,priceStep,Slippage,0,0,"",magic,0))
{
Print("Error = ",GetLastError()," Order Type = ",Order," Lot = ",lot," Price = ",Price);
}
lot=NormalizeDouble(lot*mnog,2);
if(Order==OP_BUYLIMIT||Order==OP_SELLSTOP)
{
priceStep=priceStep-ST;
}
if(Order==OP_SELLLIMIT||Order==OP_BUYSTOP)
{
priceStep=priceStep+ST;
}
}
}
//---2017-08-18---------------------Maksim Neimerik-------------
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---