Orders Execution
Miscellaneous
0
Views
0
Downloads
0
Favorites
TrendStuffer-expert-ULTIMATE-ThreePositions
#property copyright "Copyright © 2007, TrendStuffer.com"
#property link "http://www.trendstuffer.com"
extern string introone = "**TrendStuffer.com ThreeP System**";
extern string introtwo = "**Built for independent usage**";
extern bool BUY = false;
extern bool SELL = false;
extern int myMagic = 20070611;
extern int MaxSlippage = 3;
extern int OrderTriesNumber = 5;
extern double Lot1 = 0.3;
extern double Lot2 = 0.2;
extern double Lot3 = 0.1;
extern int TakeProfit1 = 20;
extern int TakeProfit2 = 40;
extern int TakeProfit3 = 60;
extern int InitialSL1 = 20;
extern int InitialSL2 = 40;
extern int InitialSL3 = 50;
int var_160 = 0;
int var_164;
int var_168;
int var_172;
//+------------------------------------------------------------------+
void OpenPositions()
{
string comment = "TrendStuffer ThreeP EA " + Period() + " " + Symbol();
if ((BUY == false) && (SELL == true) && (var_160 != 1))
{
var_164 = OrderSend(Symbol(),OP_SELL,Lot1,Bid,MaxSlippage,Bid + InitialSL1 * Point,Bid - TakeProfit1 * Point,comment,myMagic,0,Red);
var_168 = OrderSend(Symbol(),OP_SELL,Lot2,Bid,MaxSlippage,Bid + InitialSL2 * Point,Bid - TakeProfit2 * Point,comment,myMagic,0,Red);
var_172 = OrderSend(Symbol(),OP_SELL,Lot3,Bid,MaxSlippage,Bid + InitialSL3 * Point,Bid - TakeProfit3 * Point,comment,myMagic,0,Red);
var_160 = 1;
}
else
{
if ((BUY == true) && (SELL == false) && (var_160 != 1))
{
var_164 = OrderSend(Symbol(),OP_BUY,Lot1,Ask,MaxSlippage,Ask - InitialSL1 * Point,Ask + TakeProfit1 * Point,comment,myMagic,0,Blue);
var_168 = OrderSend(Symbol(),OP_BUY,Lot2,Ask,MaxSlippage,Ask - InitialSL2 * Point,Ask + TakeProfit2 * Point,comment,myMagic,0,Blue);
var_172 = OrderSend(Symbol(),OP_BUY,Lot3,Ask,MaxSlippage,Ask - InitialSL3 * Point,Ask + TakeProfit3 * Point,comment,myMagic,0,Blue);
var_160 = 1;
}
}
}
//+------------------------------------------------------------------+
void CheckForClose()
{
int result1;
int result2;
int i;
int attempt1;
int attempt2;
for (i = 0; i < OrdersTotal(); i++)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES) == false) break;
if ((OrderMagicNumber() != myMagic) || (OrderSymbol() != Symbol())) continue;
if (OrderType() == OP_BUY)
{
if ((Bid > OrderOpenPrice() + TakeProfit1 * Point) && (Bid < OrderOpenPrice() + TakeProfit2 * Point) && (OrderStopLoss() != OrderOpenPrice() + 1 * Point))
{
attempt1 = 0;
while ((result1 == 0) && (attempt1 < OrderTriesNumber))
{
result1 = OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice() + 5 * Point,OrderTakeProfit(),0,White);
attempt1++;
}
}
if ((Bid > OrderOpenPrice() + TakeProfit2 * Point) && (Bid < OrderOpenPrice() + TakeProfit3 * Point) && (OrderStopLoss() != OrderOpenPrice() + TakeProfit1 * Point))
{
attempt2 = 0;
while ((result2 == 0) && (attempt2 < OrderTriesNumber))
{
result2 = OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice() + TakeProfit1 * Point,OrderTakeProfit(),0,White);
attempt2++;
}
}
}
if (OrderType() == OP_SELL)
{
if ((Ask < OrderOpenPrice() - TakeProfit1 * Point) && (Ask > OrderOpenPrice() - TakeProfit2 * Point) && (OrderStopLoss() != OrderOpenPrice() - 1 * Point))
{
attempt1 = 0;
while ((result1 == 0) && (attempt1 < OrderTriesNumber))
{
result1 = OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice() - 5 * Point,OrderTakeProfit(),0,White);
attempt1++;
}
}
if ((Ask < OrderOpenPrice() - TakeProfit2 * Point) && (Ask > OrderOpenPrice() - TakeProfit3 * Point) && (OrderStopLoss() != OrderOpenPrice() - TakeProfit1 * Point))
{
attempt2 = 0;
while ((result2 == 0) && (attempt2 < OrderTriesNumber))
{
result2 = OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice() - TakeProfit1 * Point,OrderTakeProfit(),0,White);
attempt2++;
}
}
}
}
}
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
int start()
{
int var_start_0 = 2007;
int var_start_4 = 8;
int var_start_8 = 27;
string var_start_12 = var_start_0 + "." + var_start_4 + "." + var_start_8;
int var_start_20 = StrToTime(var_start_12);
/*
if (TimeCurrent() >= var_start_20)
{
Alert("This version has expired! Please order a new copy from www.TrendStuffer.com!");
return(0);
}
*/
if (var_160 != 1) OpenPositions();
CheckForClose();
}
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
---