Orders Execution
Indicators Used
1
Views
0
Downloads
0
Favorites
Profitability Reports
AUD/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%
Stocheurusd
//+------------------------------------------------------------------+
//| MyStoch.mq4 |
//| Copyright © 2006, MetaQuotes Software Corp. |
//| http://www.alpari-idc.ru/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, MetaQuotes Software Corp."
#property link "http://www.alpari-idc.ru/"
#include <stdlib.mqh>
#include <WinUser32.mqh>
#define MAGICMA 20050610
extern double Lots =0.1;
extern double TakeProfit =10;
extern double StopLoss =1000;
extern double TrailingStop =100;
int res;
double Points;
double iStoch1;
double iStoch2;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
Points=MarketInfo("EURUSD",MODE_POINT);
//----
return(0);
}
//+-------------------------------------+
//ïðîâåðÿåì íàëè÷èå îòêðûòûõ îðäåðîâ
//+-------------------------------------+
int CalculateCurrentOrders(string symbol)
{
int buys=0,sells=0;
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)break;
if(OrderSymbol()=="EURUSD"&&OrderMagicNumber()==MAGICMA)
{
if(OrderType()==OP_BUY) buys++;
if(OrderType()==OP_SELL) sells++;
}
}
if(buys>0)return(buys);
else return(-sells);
}
//+----------------------------------------------+
//îòêðûâàåì îðäåð
//+----------------------------------------------+
void CheckForOpen()
{
iStoch1=iStochastic("EURUSD",0,7,10,4,MODE_SMA,0,MODE_MAIN,0);
iStoch2=iStochastic("EURUSD",0,7,10,4,MODE_SMA,0,MODE_MAIN,1);
//---------------------------------------------------------------------------------------------------//
if(iStoch2<iStoch1&&iStoch1>=10&&iStoch1<15)
res=OrderSend("EURUSD",OP_BUY,Lots,Ask,3,Ask-StopLoss*Points,Ask+TakeProfit*Points,"",MAGICMA,0,Blue);
//---------------------------------------------------------------------------------------------------//
if(iStoch2>iStoch1&&iStoch1<=95&&iStoch1>90)
res=OrderSend("EURUSD",OP_SELL,Lots,Bid,3,Bid+StopLoss*Points,Bid-TakeProfit*Points,"",MAGICMA,0,Red);
//---------------------------------------------------------------------------------------------------//
return;
}
//---------------------------------------------------------------------+
//Çàêðûâàåì îðäåðà
//---------------------------------------------------------------------+
void CheckForClose()
{
int total=OrdersTotal();
int ordertype;
int ticket;
int index;
//double priceClose;
if(iStoch1<50)
for( index=total-1;index>=0;index--)
if(OrderSelect(index,SELECT_BY_POS))
{
ordertype=OrderType();
ticket=OrderTicket();
if(ordertype==OP_SELL&&OrderMagicNumber()==MAGICMA)
OrderClose(ticket,OrderLots(),Ask,3,Red);
else break;
}
if(iStoch1>50)
for( index=total-1;index>=0;index--)
if(OrderSelect(index,SELECT_BY_POS))
{
ordertype=OrderType();
ticket=OrderTicket();
if(ordertype==OP_BUY&&OrderMagicNumber()==MAGICMA)
OrderClose(ticket,OrderLots(),Bid,3,Red);
else break;
}
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
void start()
{
//----
if(Bars<100||IsTradeAllowed()==false)return;
if(CalculateCurrentOrders("EURUSD")==0)CheckForOpen();
else CheckForClose();
//----
//return;
}
//+------------------------------------------------------------------+
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
---