Orders Execution
Indicators Used
0
Views
0
Downloads
0
Favorites
Profitability Reports
AUD/USD
Oct 2024 - Jan 2025
70.00 %
Total Trades
100
Won Trades
0
Lost trades
0
Win Rate
0.00 %
Expected payoff
-2.26
Gross Profit
538.40
Gross Loss
-764.40
Total Net Profit
-226.00
-100%
-50%
0%
50%
100%
GBP/USD
Oct 2024 - Jan 2025
46.00 %
Total Trades
100
Won Trades
30
Lost trades
70
Win Rate
0.30 %
Expected payoff
-7.36
Gross Profit
631.40
Gross Loss
-1367.30
Total Net Profit
-735.90
-100%
-50%
0%
50%
100%
SMC Trader 2 MAs 5 20 EMA1
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| SMC Autotrader Momentum.mq4 |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
extern double TakeProfit = 50;
extern double Lots = 0.1;
extern double InitialStop = 30;
extern double TrailingStop = 20;
datetime BarTime;
//#####################################################################
int init()
{
//----
//----
return(0);
}
//#####################################################################
int start()
{
int cnt,total,ticket,MinDist,tmp;
double Spread;
//############################################################################
if(Bars<100){
Print("bars less than 100");
return(0);
}
//exit if not new bar
if(BarTime == Time[0]) {return(0);}
//new bar, update bartime
BarTime = Time[0];
//#########################################################################################
//~~~~~~~~~~~~~~~~Miscellaneous setup stuff~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MinDist=MarketInfo(Symbol(),MODE_STOPLEVEL);
Spread=(Ask-Bid);
//#########################################################################################
double SMAP1,SMAP2,MMAP1,MMAP2;
SMAP1=iMA(NULL,0,5,0,MODE_EMA,PRICE_CLOSE,1);
SMAP2=iMA(NULL,0,5,0,MODE_EMA,PRICE_CLOSE,2);
MMAP1=iMA(NULL,0,20,0,MODE_EMA,PRICE_CLOSE,1);
MMAP2=iMA(NULL,0,20,0,MODE_EMA,PRICE_CLOSE,2);
//########################################################################################
//################## ORDER CLOSURE ###################################################
// If Orders are in force then check for closure against Technicals LONG & SHORT
//CLOSE LONG Entries
total=OrdersTotal();
if(total>0)
{
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()==OP_BUY && OrderSymbol()==Symbol())
{
if(SMAP2 > MMAP2 && SMAP1 < SMAP2)
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close LONG position
}}
//CLOSE SHORT ENTRIES:
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()==OP_SELL && OrderSymbol()==Symbol()) // check for symbol
{
if(SMAP2 < MMAP2 && SMAP1 > SMAP2)
{
OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close SHORT position
}}
} // for loop return
} // close 1st if
//##############################################################################
//################## ORDER TRAILING STOP Adjustment #######################
//TRAILING STOP: LONG
if(0==1) //This is used to turn the trailing stop on & off
{
total=OrdersTotal();
if(total>0)
{
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()==OP_BUY && OrderSymbol()==Symbol()
&&
Bid-OrderOpenPrice()> (Point*TrailingStop)
&&
OrderStopLoss()<Bid-(Point*TrailingStop)
)
{OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,White);
return(0);}
}}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//TRAILING STOP: SHORT
total=OrdersTotal();
if(total>0)
{
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()==OP_SELL && OrderSymbol()==Symbol()
&&
OrderOpenPrice()-Ask > (Point*TrailingStop)
&&
OrderStopLoss() > Ask+(Point*TrailingStop)
)
{OrderModify(OrderTicket(),OrderOpenPrice(),Ask+(Point*TrailingStop),OrderTakeProfit(),0,Yellow);
return(0);}
}}
} // end bracket for on/off switch
//##########################################################################################
//~~~~~~~~~~~ END OF ORDER Closure routines & Stoploss changes ~~~~~~~~~~~~~~~~~~~~~~~~~~~
//##########################################################################################
//~~~~~~~~~~~~START of NEW ORDERS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//######################### NEW POSITIONS ? ######################################
//Possibly add in timer to stop multiple entries within Period
// Check Margin available
// ONLY ONE ORDER per SYMBOL
// Loop around orders to check symbol doesn't appear more than once
// Check for elapsed time from last entry to stop multiple entries on same bar
if (0==1) // switch to turn ON/OFF history check
{
total=HistoryTotal();
if(total>0)
{
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_HISTORY); //Needs to be next day not as below
if(OrderSymbol()==Symbol()&& CurTime()- OrderCloseTime() < (Period() * 60 )
)
{
return(0);
}}}}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
total=OrdersTotal();
if(total>0)
{
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol()) return(0);
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(AccountFreeMargin()<(1000*Lots))
{Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//#########################################################################################
//ENTRY RULES: LONG
if(SMAP2 < MMAP2 && SMAP1 > MMAP2)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"MaxMin Long",16384,0,Orange); //Bid-(Point*(MinDist+2))
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
return(0);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//ENTRY RULES: SHORT //################################
if(SMAP2 > MMAP2 && SMAP1 < MMAP2)
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,"MaxMin Short",16384,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
}
else Print("Error opening SELL order : ",GetLastError());
return(0);
}
//####################################################################################
//############ End of PROGRAM #########################
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
---