Author: emsjoflo
Orders Execution
Checks for the total of open ordersIt Closes Orders by itself It automatically opens orders when conditions are reached
Indicators Used
Moving average indicator
0 Views
0 Downloads
0 Favorites

Profitability Reports

GBP/USD Oct 2024 - Jan 2025
85.00 %
Total Trades 99
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -2.00
Gross Profit 1160.90
Gross Loss -1358.50
Total Net Profit -197.60
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
55.00 %
Total Trades 98
Won Trades 28
Lost trades 70
Win Rate 0.29 %
Expected payoff -4.45
Gross Profit 522.80
Gross Loss -958.70
Total Net Profit -435.90
-100%
-50%
0%
50%
100%
3sma
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                         3sma.mq4 |
//|                                                         emsjoflo |
//|                                  automaticforex.invisionzone.com |
//+------------------------------------------------------------------+
#property copyright "emsjoflo"
#property link      "automaticforex.invisionzone.com"

//---- input parameters
extern int       SMA1=9;
extern int       SMA2=14;
extern int       SMA3=29;
extern double    lots=0.1;
extern int       SMAspread=0;
extern int       StopLoss=0;
extern int       Slippage=4;
double   ma1,ma2,ma3;
int      i, buys, sells;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
//get moving average info
ma1 = iMA(Symbol(),0,SMA1,1,MODE_SMA,PRICE_CLOSE,0);
ma2=iMA(NULL,0,SMA2,1,MODE_SMA,PRICE_CLOSE,0);
ma3=iMA(NULL,0,SMA3,1,MODE_SMA,PRICE_CLOSE,0);

//check for open orders first 
if (OrdersTotal()>0)
   {
   buys=0;
   sells=0;
   for (i=0;i<OrdersTotal();i++)
      {
      OrderSelect(i,SELECT_BY_POS);
      if (OrderSymbol()==Symbol())
         {
         if (OrderType()== OP_BUY)
            {
            if (ma1 < ma2) OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Orange);
            else buys++;
            }
         if (OrderType()== OP_SELL) 
            {
            if (ma1 > ma2) OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,Yellow);
            else sells++;
            }
         }
      }
   }
if (ma1>(ma2+SMAspread*Point) && ma2 > (ma3+SMAspread*Point) && buys == 0)
   {
   Print("Buy condition");
   OrderSend(Symbol(),OP_BUY,lots,Ask,Slippage,0/*(Ask-StopLoss*Point)*/,0,"3SMA",123,0,Green);
   }
if (ma1<(ma2-SMAspread*Point) && ma2 < (ma3-SMAspread*Point) && sells ==0)
   {
   Print ("Sell condition");
   OrderSend(Symbol(),OP_SELL,lots,Bid,Slippage,0/*(Bid+StopLoss*Point)*/,0,"3SMA",123,0,Red);
   }   
   
   
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---