Orders Execution
Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
Profitability Reports
AUD/USD
Oct 2024 - Jan 2025
73.00 %
Total Trades
80
Won Trades
0
Lost trades
0
Win Rate
0.00 %
Expected payoff
-0.24
Gross Profit
52.24
Gross Loss
-71.42
Total Net Profit
-19.18
-100%
-50%
0%
50%
100%
GBP/USD
Oct 2024 - Jan 2025
108.00 %
Total Trades
81
Won Trades
33
Lost trades
48
Win Rate
0.41 %
Expected payoff
0.10
Gross Profit
116.14
Gross Loss
-107.80
Total Net Profit
8.34
-100%
-50%
0%
50%
100%
Sappie Ma CrossV1.1
//+------------------------------------------------------------------+
//| This MQL is generated by DocChiro |
//+------------------- DO NOT REMOVE THIS HEADER --------------------+
//----------------------- INCLUDES
#property copyright "DocChiro"
#property link "DocChiro"
#include <stdlib.mqh>
#define SIGNAL_NONE 0
#define SIGNAL_BUY 1
#define SIGNAL_SELL 2
#define SIGNAL_CLOSEBUY 3
#define SIGNAL_CLOSESELL 4
//----------------------- EA PARAMETER
extern string FirstMA_Setting = "---------- First MA Setting";
extern int MA1Period = 12; // SmoMa is for the midline MA, use it to have a midline with two MA/s to cross
extern int MA1Type = 1; //0:SMA 1:EMA 2:SMMA 3:LWMA df 80
extern int MA1Price = 0; //0:Close 1:Open 2:High 3:Low 4:Median 5:Typical 6:Weighted
extern int MA1shift = 0;
extern string SecontMA_Setting = "---------- Second MA Setting";
extern int MA2Period = 21; // SmoMa is for the midline MA, use it to have a midline with two MA/s to cross
extern int MA2Type = 1; //0:SMA 1:EMA 2:SMMA 3:LWMA df 80
extern int MA2Price = 0; //0:Close 1:Open 2:High 3:Low 4:Median 5:Typical 6:Weighted
extern int MA2shift = 0;
extern string ThirdMA_Setting = "---------- Third MA Setting";
extern int MA3Period = 20; // SmoMa is for the midline MA, use it to have a midline with two MA/s to cross
extern int MA3Type = 0; //0:SMA 1:EMA 2:SMMA 3:LWMA df 80
extern int MA3Price = 0; //0:Close 1:Open 2:High 3:Low 4:Median 5:Typical 6:Weighted
extern int MA3shift = 0;
static int TimeFrame = 0;
extern int LimitShift = 10; // check if MA2 cross MA3 this number of bars back
extern int MAspread = 8; // spread of ma's to take out noise
extern bool Show_Settings = true;
extern int MagicNumber = 12345;
extern bool SignalMail = False;
extern bool EachTickMode = True;
extern double Lots = 0.01;
extern int Slippage = 3;
extern bool UseStopLoss = False;
extern int StopLoss = 30;
extern bool UseTakeProfit = False;
extern int TakeProfit = 20;
extern bool UseTrailingStop = False;
extern int TrailingStop = 30;
extern string LastTrade ="";
int BarCount;
int Current;
bool TickCheck = False;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init() {
BarCount = Bars;
if(Show_Settings==true) subPrintDetails();
else Comment("");
if (EachTickMode) Current = 0; else Current = 1;
return(0);
//----------------------- GENERATE MAGIC NUMBER AND TICKET COMMENT
//----------------------- SOURCE : PENGIE
//MagicNumber = subGenerateMagicNumber(MagicNumber, Symbol(), Period());
// TicketComment = StringConcatenate(TicketComment, "-", Symbol(), "-", Period());
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit() {
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start() {
int Order = SIGNAL_NONE;
int Total, Ticket;
double StopLossLevel, TakeProfitLevel;
double MA1Current;
double MA2Current;
double MA3Current;
double MA1Currentc;
double MA2Currentc;
double MA3Currentc;
bool BSsignal;
int c=0;
/// assigns each MA variables to a definate variable
MA1Current = iMA(NULL,TimeFrame,MA1Period,MA1shift,MA1Type,MA1Price,0);
MA2Current = iMA(NULL,TimeFrame,MA2Period,MA2shift,MA2Type,MA2Price,0);
MA3Current = iMA(NULL,TimeFrame,MA3Period,MA3shift,MA3Type,MA3Price,0);
if (EachTickMode && Bars != BarCount) TickCheck = False;
Total = OrdersTotal();
Order = SIGNAL_NONE;
// check if MA2 Crossed MA3 within i number of Bars back
RefreshRates();
BSsignal = false;
LastTrade="";
for(c=0,BSsignal=false ; ((c<LimitShift)); c++)
{
// check that the ma2 / ma3 cross ocurs at lasttrade value ago at least
RefreshRates();
MA2Currentc = iMA(NULL,TimeFrame,MA2Period,MA2shift,MA2Type,MA2Price,Current + c);
MA3Currentc = iMA(NULL,TimeFrame,MA3Period,MA3shift,MA3Type,MA3Price,Current + c);
if ((((LastTrade=="Buy")||(LastTrade=="")) && (MA2Currentc<MA3Currentc) && (MA1Current<MA2Current)
&& ((MA2Current-MA1Current)>MAspread*Point)&& ((MA3Current-MA2Current)>MAspread*Point))
|| (((LastTrade=="Sell")||(LastTrade=="")) && (MA2Currentc>MA3Currentc) && (MA1Current>MA2Current)
&& ((MA1Current-MA2Current)>MAspread*Point)&& ((MA2Current-MA3Current)>MAspread*Point))) {
BSsignal = true;
}
}
RefreshRates();
//+------------------------------------------------------------------+
//| Variable Begin |
//+------------------------------------------------------------------+
//double Var1 = iMA(NULL, 0, 12, 0, MODE_EMA, PRICE_CLOSE, Current + 1);
//double Var2 = iMA(NULL, 0, 12, 0, MODE_EMA, PRICE_CLOSE, Current + 0);
//double Var3 = iMA(NULL, 0, 21, 0, MODE_EMA, PRICE_CLOSE, Current + 1);
//double Var4 = iMA(NULL, 0, 21, 0, MODE_EMA, PRICE_CLOSE, Current + 0);
//double Var5 = iOpen(NULL, 0, Current + 1);
//double Var6 = iOpen(NULL, 0, Current + 0);
//double Var7 = iClose(NULL, 0, Current + 1);
//double Var8 = iClose(NULL, 0, Current + 0);
//double Var9 = iHigh(NULL, 0, Current + 1);
//double Var10 = iHigh(NULL, 0, Current + 0);
//double Var11 = iLow(NULL, 0, Current + 1);
//double Var12 = iLow(NULL, 0, Current + 0);
//double Var13 = iBands(NULL, 0, 20, 3, 0, PRICE_CLOSE, MODE_UPPER, Current + 1);
//double Var14 = iBands(NULL, 0, 20, 3, 0, PRICE_CLOSE, MODE_UPPER, Current + 0);
//double Var15 = iBands(NULL, 0, 20, 3, 0, PRICE_CLOSE, MODE_LOWER, Current + 1);
//double Var16 = iBands(NULL, 0, 20, 3, 0, PRICE_CLOSE, MODE_LOWER, Current + 0);
//double Var17 = ( Var12 > Var4 ) && (Var2 > Var4) && ( ( Var13 - Var15) >80) && ( Var1 >(( Var13 + Var15 )/2);
//open buy signal
double OBuy = ((MA2Current>MA3Current) && (MA1Current>MA3Current)&& (BSsignal==true)) ;
double OSell = ((MA2Current<MA3Current) && (MA1Current<MA3Current)&& (BSsignal==true));
double ClBuy = ((MA2Current<MA3Current));
double ClSell = ((MA2Current>MA3Current));
//double Var18 = ( Var10 < Var4 ) && (Var2 < Var4) && ( ( Var13 - Var15) >80) && ( Var1 >(( Var13 + Var15 )/2);
//double Var19 = ( Var12 < Var4 ) || ( ( Var13 - Var15) <80);
//double Var20 = ( Var10 > Var4 ) || ( ( Var13 - Var15) <80);
double Buy1_1 = OBuy ;
double Buy1_2 = True ;
double Sell1_1 = OSell ;
double Sell1_2 = True ;
double CloseBuy1_1 = ClBuy ;
double CloseBuy1_2 = True ;
double CloseSell1_1 = ClSell ;
double CloseSell1_2 = True ;
//+------------------------------------------------------------------+
//| Variable End |
//+------------------------------------------------------------------+
//Check position
bool IsTrade = False;
for (int i = 0; i < Total; i ++) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
RefreshRates();
if(OrderType() <= OP_SELL && OrderSymbol() == Symbol()) {
IsTrade = True;
if(OrderType() == OP_BUY) {
//Close
//+------------------------------------------------------------------+
//| Signal Begin(Exit Buy) |
//+------------------------------------------------------------------+
if (CloseBuy1_1 == CloseBuy1_2) Order = SIGNAL_CLOSEBUY;
//+------------------------------------------------------------------+
//| Signal End(Exit Buy) |
//+------------------------------------------------------------------+
if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Bid,4), Slippage, MediumSeaGreen);
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(NormalizeDouble(Bid,4), Digits) + " Close Buy");
if (!EachTickMode) BarCount = Bars;
IsTrade = False;
continue;
}
//Trailing stop
RefreshRates();
if(UseTrailingStop && TrailingStop > 0) {
if(NormalizeDouble(Bid,4) - OrderOpenPrice() > Point * TrailingStop) {
if(OrderStopLoss() < NormalizeDouble(Bid,4) - Point * TrailingStop) {
OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Bid,4) - Point * TrailingStop, OrderTakeProfit(), 0, MediumSeaGreen);
if (!EachTickMode) BarCount = Bars;
continue;
}
}
}
} else {
//Close
//+------------------------------------------------------------------+
//| Signal Begin(Exit Sell) |
//+------------------------------------------------------------------+
if (CloseSell1_1 == CloseSell1_2) Order = SIGNAL_CLOSESELL;
//+------------------------------------------------------------------+
//| Signal End(Exit Sell) |
//+------------------------------------------------------------------+
RefreshRates();
if (Order == SIGNAL_CLOSESELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Ask, 4), Slippage, DarkOrange);
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(NormalizeDouble(Ask, 4), Digits) + " Close Sell");
if (!EachTickMode) BarCount = Bars;
IsTrade = False;
continue;
}
RefreshRates();
//Trailing stop
if(UseTrailingStop && TrailingStop > 0) {
if((OrderOpenPrice() - NormalizeDouble(Ask, 4)) > (Point * TrailingStop)) {
if((OrderStopLoss() > (NormalizeDouble(Ask, 4) + Point * TrailingStop)) || (OrderStopLoss() == 0)) {
OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Ask, 4) + Point * TrailingStop, OrderTakeProfit(), 0, DarkOrange);
if (!EachTickMode) BarCount = Bars;
continue;
}
}
}
}
}
}
//+------------------------------------------------------------------+
//| Signal Begin(Entry) |
//+------------------------------------------------------------------+
if (Buy1_1 == Buy1_2) Order = SIGNAL_BUY;
if (Sell1_1 == Sell1_2) Order = SIGNAL_SELL;
//+------------------------------------------------------------------+
//| Signal End |
//+------------------------------------------------------------------+
//Buy
RefreshRates();
if (Order == SIGNAL_BUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
LastTrade="Buy";
if(!IsTrade) {
//Check free margin
if (AccountFreeMargin() < (1000 * Lots)) {
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}
if (UseStopLoss) StopLossLevel = NormalizeDouble(Ask, 4) - StopLoss * Point; else StopLossLevel = 0.0;
if (UseTakeProfit) TakeProfitLevel = NormalizeDouble(Ask, 4) + TakeProfit * Point; else TakeProfitLevel = 0.0;
Ticket = OrderSend(Symbol(), OP_BUY, Lots, NormalizeDouble(Ask, 4), Slippage, StopLossLevel, TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue);
if(Ticket > 0) {
if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {
Print("BUY order opened : ", OrderOpenPrice());
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(NormalizeDouble(Ask, 4), Digits) + " Open Buy");
} else {
Print("Error opening BUY order : ", GetLastError());
}
}
if (EachTickMode) TickCheck = True;
if (!EachTickMode) BarCount = Bars;
return(0);
}
}
//Sell
if (Order == SIGNAL_SELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
RefreshRates();
LastTrade="Sell";
if(!IsTrade) {
//Check free margin
if (AccountFreeMargin() < (1000 * Lots)) {
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}
if (UseStopLoss) StopLossLevel = NormalizeDouble(Bid,4) + StopLoss * Point; else StopLossLevel = 0.0;
if (UseTakeProfit) TakeProfitLevel = NormalizeDouble(Bid,4) - TakeProfit * Point; else TakeProfitLevel = 0.0;
Ticket = OrderSend(Symbol(), OP_SELL, Lots, NormalizeDouble(Bid,4), Slippage, StopLossLevel, TakeProfitLevel, "Sell(#" + MagicNumber + ")", MagicNumber, 0, DeepPink);
if(Ticket > 0) {
if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {
Print("SELL order opened : ", OrderOpenPrice());
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(NormalizeDouble(Bid,4), Digits) + " Open Sell");
} else {
Print("Error opening SELL order : ", GetLastError());
}
}
if (EachTickMode) TickCheck = True;
if (!EachTickMode) BarCount = Bars;
return(0);
}
}
if (!EachTickMode) BarCount = Bars;
return(0);
}
void subPrintDetails()
{
string sComment = "";
string sp = "----------------------------------------\n";
string NL = "\n";
sComment = sp;
sComment = sComment + "MA1 Time Frame..." + DoubleToStr(MA1Period,0) + " "+ DoubleToStr(MA1Type,0) +" 0=SMA,1=EMA,2=SSMA,3=WMA" + NL;
sComment = sComment + "MA2 Time Frame..." + DoubleToStr(MA2Period,0) + " "+ DoubleToStr(MA2Type,0) +" 0=SMA,1=EMA,2=SSMA,3=WMA" + NL;
sComment = sComment + "MA3 Time Frame..." + DoubleToStr(MA3Period,0) + " "+ DoubleToStr(MA3Type,0) +" 0=SMA,1=EMA,2=SSMA,3=WMA" + NL;
sComment = sComment + sp;
sComment = sComment + "Lots=" + DoubleToStr(Lots,2) + NL;
sComment = sComment + sp;
Comment(sComment);
}
//+------------------------------------------------------------------+
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
---