Orders Execution
Miscellaneous
0
Views
0
Downloads
0
Favorites
Profitability Reports
GBP/USD
Oct 2024 - Jan 2025
0.00 %
Total Trades
0
Won Trades
0
Lost trades
0
Win Rate
0.0 %
Expected payoff
0.00
Gross Profit
0.00
Gross Loss
0.00
Total Net Profit
0.00
-100%
-50%
0%
50%
100%
NZD/USD
Oct 2024 - Jan 2025
0.00 %
Total Trades
0
Won Trades
0
Lost trades
0
Win Rate
0.0 %
Expected payoff
0.00
Gross Profit
0.00
Gross Loss
0.00
Total Net Profit
0.00
-100%
-50%
0%
50%
100%
Brainwashing _25231c
//+------------------------------------------------------------------+
//| Brainwashing #1c.mq4 |
//| code by Alex.Piech.FinGeR |
//| http://www.forex-tsd.com |
//| buletproofing open/close/modify orders |
//| and code cleanup by Nick Bilak |
//| |
//| 01.11.2005 #1c - i_Trend add-on by Nick Bilak |
//| 20.10.2005 Brainwashing #1a by Alex.Piech.FinGeR |
//| BIG Thanks newdigital by forex-tsd.com |
//| look please last Line !!!! |
//+------------------------------------------------------------------+
#include <stdlib.mqh>
#property copyright "Alex.Piech.FinGeR"
#property link "http://www.forex-tsd.com"
extern int MAGIC=20051021;
extern string PARAMETERS_TRADE = "PARAMETERS TRADE";
extern int SLIPPAGE = 3;
extern double Lots = 0.1;
extern int StopLoss = 10;
extern int TakeProfit = 80;
extern bool OnlyEnterOnFullBars = true;
extern bool OnlyExitOnFullBars = true;
extern bool UseHourTrade = True;
extern int FromHourTrade = 9;
extern int ToHourTrade = 21;
extern bool useCloseTradeRules = False;
extern bool useProfitTrailing = True;
extern int TrailingStop = 20;
extern int TrailingStep = 3;
extern string PARAMETERS_INDICATOR_ONE = "PriceChannel_Stop_v1";
extern int ChannelPeriod = 9;
extern double Risk = 0.3;
extern int Nbars = 200;
extern string PARAMETERS_INDICATOR_TWO = "Price Channel";
extern int ChannelPeriod2=14;
extern int Shift=0;
extern string PARAMETERS_INDICATOR_3 = "i_Trend";
extern int Bands_Period=20;
extern int Bands_Deviation=2;
extern int Power_Period=13;
extern int CountBars=300;
extern bool ItrendFilter=true;
extern double ItrendLevel=0.0; //iTrend line must be above this level
extern string PARAMETERS_EXPERT = "PARAMETERS EXPERT";
extern bool UseOneAccount = False;
extern int NumberAccount = 0815;
extern string Name_Expert = "Brainwashing #1c";
extern bool UseSound = False;
extern string NameFileSound = "expert.wav";
extern color clOpenBuy = LightBlue;
extern color clOpenSell = LightCoral;
extern color clModifyBuy = Aqua;
extern color clModifySell = Tomato;
extern color clCloseBuy = Blue;
extern color clCloseSell = Red;
int prevBar,ttime;
bool bx=False;
bool sx=False;
void SetArrow(datetime t, double p, int k, color c) {
ObjectSet("Arrow", OBJPROP_TIME1 , t);
ObjectSet("Arrow", OBJPROP_PRICE1 , p);
ObjectSet("Arrow", OBJPROP_ARROWCODE, k);
ObjectSet("Arrow", OBJPROP_COLOR , c);
}
void deinit() {
//Comment("");
}
void start() {
//---- check for history and trading
if(Bars<100 || IsTradeAllowed()==false) return;
SetArrow(Time[0],Low[0]-5*Point,241,Gold);
bx=False;
sx=False;
CheckForOpen();
if (useCloseTradeRules) CheckForClose2();
if (useProfitTrailing) TrailingPositions();
}
void CheckForOpen() {
bx=False;
sx=False;
double ldStop=0, ldTake=0;
if (OnlyEnterOnFullBars) {
if (Volume[0]>1)
return(0);
else
int lookupidx= 1; // look at the values of the previous bar (recently completed bar)
}
else {
lookupidx= 0;
}
if (OnlyExitOnFullBars) {
if (Volume[0]>1)
return(0);
else
int lookupidx2= 1; // look at the values of the previous bar (recently completed bar)
}
else {
lookupidx2= 0;
}
double Buy=iCustom(NULL, 0, "PriceChannel_Stop_v1",ChannelPeriod,Risk,1,1,Nbars,0,lookupidx);
double Buy1=iCustom(NULL, 0, "PriceChannel_Stop_v1",ChannelPeriod,Risk,1,1,Nbars,3,lookupidx);
double Sell=iCustom(NULL, 0, "PriceChannel_Stop_v1",ChannelPeriod,Risk,1,1,Nbars,1,lookupidx);
double Sell1=iCustom(NULL, 0, "PriceChannel_Stop_v1",ChannelPeriod,Risk,1,1,Nbars,2,lookupidx);
double xBuy=iCustom(NULL, 0, "PriceChannel_Stop_v1",ChannelPeriod,Risk,1,1,Nbars,0,lookupidx2);
double xBuy1=iCustom(NULL, 0, "PriceChannel_Stop_v1",ChannelPeriod,Risk,1,1,Nbars,3,lookupidx2);
double xSell=iCustom(NULL, 0, "PriceChannel_Stop_v1",ChannelPeriod,Risk,1,1,Nbars,1,lookupidx2);
double xSell1=iCustom(NULL, 0, "PriceChannel_Stop_v1",ChannelPeriod,Risk,1,1,Nbars,2,lookupidx2);
double iTredn1=iCustom(NULL,0,"i_Trend",0,0,0,Bands_Period,Bands_Deviation,Power_Period,300,0,lookupidx); //green
double iTredn2=iCustom(NULL,0,"i_Trend",0,0,0,Bands_Period,Bands_Deviation,Power_Period,300,1,lookupidx); //red
if (xSell==-1 && xSell1>-1
&& ((ItrendFilter && iTredn2>ItrendLevel && iTredn2>iTredn1) ||!ItrendFilter) //iTrend filter
) {
Print("dgdfgdgsdgsdgsdgdgdfhgdfhgdfhgdfghdfhdfhdfghdfhdfhgs");
sx=True;
CheckForClose();
}
if (xBuy==-1 && xBuy1>-1
&& ((ItrendFilter && iTredn1>ItrendLevel && iTredn1>iTredn2) ||!ItrendFilter) //iTrend filter
) {
Print("dgdfgdgsdgsdgsdgdgsghfhdfghdfhgdfhdfhdfhdfhdfhd");
bx=True;
CheckForClose();
}
if (!ExistPosition() && ttime!=Time[0]) {
if (Sell==-1 && Sell1>-1
&& ((ItrendFilter && iTredn1>ItrendLevel && iTredn1>iTredn2) ||!ItrendFilter) //iTrend filter
) {
if (StopLoss!=0) ldStop=Sell1-StopLoss*Point;
if (TakeProfit!=0) ldTake=Ask+TakeProfit*Point;
SetOrder(OP_BUY, Ask, ldStop, ldTake);
ttime=Time[0];
}
if (Buy==-1 && Buy1>-1
&& ((ItrendFilter && iTredn2>ItrendLevel && iTredn2>iTredn1) ||!ItrendFilter) //iTrend filter
) {
if (StopLoss!=0) ldStop=Buy1+StopLoss*Point;
if (TakeProfit!=0) ldTake=Bid-TakeProfit*Point;
SetOrder(OP_SELL, Bid, ldStop, ldTake);
ttime=Time[0];
}
}
}
void CheckForClose() {
bool bres;
int total=OrdersTotal();
for (int i=0; i<total; i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) {
if (OrderType()==OP_BUY && bx ) {
bres=false;
while (!bres) {
RefreshRates();
bres=OrderClose(OrderTicket(), Lots, Bid, SLIPPAGE, Aqua);
Sleep(6000);
if (!bres) Print("Error closing order : ",ErrorDescription(GetLastError()));
}
return;
}
if (OrderType()==OP_SELL && sx) {
bres=false;
while (!bres) {
RefreshRates();
bres=OrderClose(OrderTicket(), Lots, Ask, SLIPPAGE, Violet);
Sleep(6000);
if (!bres) Print("Error closing order : ",ErrorDescription(GetLastError()));
}
return;
}
}
}
}
}
//+------------------------------------------------------------------+
//| is MAGIC trade open ? |
//+------------------------------------------------------------------+
bool ExistPosition() {
bool Exist=False;
for (int i=0; i<OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) Exist=True;
}
}
return(Exist);
}
void SetOrder(int op, double pp, double ldStop, double ldTake) {
if ( UseHourTrade && (Hour()<FromHourTrade || Hour()>ToHourTrade) ) return;
int res; double prc;
color clOpen;
string lsComm=GetCommentForOrder();
if (op==OP_BUY) clOpen=clOpenBuy; else clOpen=clOpenSell;
res=0;
while (res<=0) {
RefreshRates();
if (op==OP_BUY) prc=Ask;
if (op==OP_SELL) prc=Bid;
res=OrderSend(Symbol(),op,Lots,prc,SLIPPAGE,ldStop,ldTake,lsComm,MAGIC,0,clOpen);
Sleep(6000);
if (res<0) Print("Error opening order : "+op+" - ",ErrorDescription(GetLastError()));
}
if (UseSound) PlaySound(NameFileSound);
}
string GetCommentForOrder() {
return(Name_Expert);
}
void TrailingPositions() {
int total=OrdersTotal();
for (int i=0; i<total; i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC ) {
if (OrderType()==OP_BUY) {
if ((Bid-OrderOpenPrice())>TrailingStop*Point) {
if (OrderStopLoss()<Bid-(TrailingStop+TrailingStep-1)*Point) {
RefreshRates();
ModifyStopLoss(Bid-TrailingStop*Point, clModifyBuy);
}
}
}
if (OrderType()==OP_SELL) {
if (OrderOpenPrice()-Ask>TrailingStop*Point) {
if (OrderStopLoss()>Ask+(TrailingStop+TrailingStep-1)*Point || OrderStopLoss()==0) {
RefreshRates();
ModifyStopLoss(Ask+TrailingStop*Point, clModifySell);
}
}
}
}
}
}
}
void CheckForClose2() {
bool fs=False;
bool fs1=False;
bool bres;
double high=iCustom(NULL, 0, "Price Channel",ChannelPeriod2,Shift,0,0);
double low=iCustom(NULL, 0, "Price Channel",ChannelPeriod2,Shift,1,0);
if (Close[0]==low) fs1 = True;
if (Close[0]==high) fs = True;
int total=OrdersTotal();
for (int i=0; i<total; i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) {
if (OrderType()==OP_BUY && fs) {
bres=false;
while (!bres) {
RefreshRates();
bres=OrderClose(OrderTicket(), Lots, Bid, SLIPPAGE, Aqua);
Sleep(6000);
if (!bres) Print("Error closing order : ",ErrorDescription(GetLastError()));
}
return;
}
if (OrderType()==OP_SELL && fs1) {
bres=false;
while (!bres) {
RefreshRates();
bres=OrderClose(OrderTicket(), Lots, Ask, SLIPPAGE, Violet);
Sleep(6000);
if (!bres) Print("Error closing order : ",ErrorDescription(GetLastError()));
}
return;
}
}
}
}
}
void ModifyStopLoss(double ldStop, color clModify) {
bool bres;
double ldOpen=OrderOpenPrice();
double ldTake=OrderTakeProfit();
bres=OrderModify(OrderTicket(), ldOpen, ldStop, ldTake, 0, clModify);
if (!bres) Print("Error closing order : ",ErrorDescription(GetLastError()));
if (bres && UseSound) PlaySound(NameFileSound);
}
// BIG Thanks KimIV by russia alpari - code Stencil :)
// BIG Thanks newdigital by forex-tsd.com Idea :)
// BIG Thanks MFX by forex-tsd.com Idea :)
// BIG Thanks all russia FX Community's :)
// Regards
// Alex.Piech.FinGeR :)
// look please last Line !!!!
// BIG Thanks all for PAYPAL Donation - regnif@gmx.net - :)
// The Money only use for FX Project's
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
---