Orders Execution
0
Views
0
Downloads
0
Favorites
TL_v3
//+------------------------------------------------------------------+
//| Ñèòíèêîâ Âàëåðèé ßêîâëåâè÷ valerasva@mail.ru |
//+------------------------------------------------------------------+
extern double Lot_min = 0.01;
extern double Lot_max = 1;
extern double TrSt = 300;
extern double ÓðÑòîïîâ = 100;
extern double Risk = 0.1;
extern int ExtDepth = 5;
extern int ExtDeviation = 5;
extern int ExtBackstep = 5;
extern double MAGICMA = 55555;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
double Lots=(NormalizeDouble(AccountFreeMargin()*Risk/1000.0,2));
if(Lots<Lot_min) Lots=Lot_min;
if(Lots>Lot_max) Lots=Lot_max;
//+-----------------------------------------------------------------
double l1=iCustom(NULL,0, "ZZtl",ExtDepth,ExtDeviation,ExtBackstep,"Fib0",0);
double l2=iCustom(NULL,0, "ZZtl",ExtDepth,ExtDeviation,ExtBackstep,"Fib1",0);
double line1=ObjectGetValueByShift("Fib0", 0);
double line2=ObjectGetValueByShift("Fib1", 0);
double line11=ObjectGetValueByShift("Fib0", 5);
double line22=ObjectGetValueByShift("Fib1", 5);
if (MathAbs(line1-line2)<MathAbs(line11-line22))bool Tr=true;
//+-----------------------------------------------------------------
for(int i = 0; i <= OrdersTotal(); i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderMagicNumber() == MAGICMA) bool BuyOp=true;
}
//+-----------------------------------------------------------------
if(BuyOp==false)
{
if((line1>line2 && Tr==true && Bid>line1 && Bid<line1+ÓðÑòîïîâ*Point)||(line1<line2 && Tr==true && Bid>line2 && Bid<line2+ÓðÑòîïîâ*Point)
||(line1>line2 && Tr==false && Bid>line2 && Bid<line2+ÓðÑòîïîâ*Point)||(line1<line2 && Tr==false && Bid>line1 && Bid<line1+ÓðÑòîïîâ*Point))
{
OrderSend(Symbol(),OP_BUY,Lots,Ask,5,Bid-ÓðÑòîïîâ*Point,0,"",MAGICMA);
}
if((line1>line2 && Tr==true && Bid<line2 && Bid>line2-ÓðÑòîïîâ*Point)||(line1<line2 && Tr==true && Bid<line1 && Bid>line1-ÓðÑòîïîâ*Point)
||(line1>line2 && Tr==false && Bid<line1 && Bid>line1-ÓðÑòîïîâ*Point)||(line1<line2 && Tr==false && Bid<line2 && Bid>line2-ÓðÑòîïîâ*Point))
{
OrderSend(Symbol(),OP_SELL,Lots,Bid,5,Ask+ÓðÑòîïîâ*Point,0,"",MAGICMA);
}
}
//+-----------------------------------------------------------------
for(int cnt=0;cnt<OrdersTotal();cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGICMA)
{
if(OrderType()==OP_BUY)
{
if((Ask<line1-ÓðÑòîïîâ*Point/2 && Ask>line1-ÓðÑòîïîâ*Point )||(Ask<line2-ÓðÑòîïîâ*Point/2 && Ask>line2-ÓðÑòîïîâ*Point ))
{
OrderClose(OrderTicket(),OrderLots(),Bid,5);
}
if(OrderStopLoss()<(Bid-Point*TrSt) && (Bid-OrderOpenPrice())>Point*TrSt)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrSt,OrderTakeProfit(),0);
}
}
if(OrderType()==OP_SELL)
{
if((Bid>line1+ÓðÑòîïîâ*Point/2 && Bid<line1+ÓðÑòîïîâ*Point)||(Bid>line2+ÓðÑòîïîâ*Point/2 && Bid<line2+ÓðÑòîïîâ*Point))
{
OrderClose(OrderTicket(),OrderLots(),Ask,5);
}
if(OrderStopLoss()>(Ask+Point*TrSt) && (OrderOpenPrice()-Ask)>Point*TrSt)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrSt,OrderTakeProfit(),0);
}
}
}
}
}
return(0);
}
//
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
---