Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt can change open orders parameters, due to possible stepping strategy
Indicators Used
Moving average indicator
0 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%
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%
mx
//------------------------------------------------------------------------------
//                                                                          mx |
//------------------------------------------------------------------------------
extern double SL=10;
extern double TP=10;
extern double TS=5;

int MAGIC=12345;
double Lots=1.0,diClose0,sMM,fMM;
//------------------------------------------------------------------------------
int init() {return(0);}
int deinit(){return(0);}
//------------------------------------------------------------------------------
int start(){
	//
	diClose0=iClose(NULL,PERIOD_M15,0);
	fMM=iMA(NULL,PERIOD_M15,5,0,3,2,0);
	sMM=iMA(NULL,PERIOD_M15,7,0,3,2,0);
	//
	if(OrdersTotal()<1){
		if(diClose0<sMM){
			OrderSend(Symbol(),OP_BUY,Lots,Ask,2,Ask-Point*SL,Ask+Point*TP,"",MAGIC,0,CLR_NONE);
		}
		if(fMM<diClose0){
			OrderSend(Symbol(),OP_SELL,Lots,Bid,2,Bid+Point*SL,Bid-Point*TP,"",MAGIC,0,CLR_NONE);
		}
	}
	TrailStop(TS);
	return(0);
}
//------------------------------------------------------------------------------
void TrailStop(double TS_){
	bool OM;
	int Ticket;
	double OOP,OTP;
	int TotalOrders=OrdersTotal();
	for(int n=OrdersTotal()-1;n>=0;n--){
		if(OrderSelect(n,SELECT_BY_POS,MODE_TRADES)){
			OOP=OrderOpenPrice();
			OTP=OrderTakeProfit();
			if(0<TS_ && OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC){
				if(OrderType()==OP_BUY){
					if(Point*TS_ < Bid-OrderOpenPrice()){
						if(OrderStopLoss() < Bid-Point*TS_){
							OrderModify(OrderTicket(),OOP,Bid-Point*TS_,OTP,0,CLR_NONE);
							return(0);
						}
					}
				}
				if(OrderType()==OP_SELL){
					if(Point*TS_ < (OrderOpenPrice()-Ask)){
						if((Ask+Point*TS_ < OrderStopLoss()) || (OrderStopLoss()==0)){
							OrderModify(OrderTicket(),OOP,Ask+Point*TS_,OTP,0,CLR_NONE);
							return(0);
						}
					}
				}
			}else{
				Print("Error : ",GetLastError());
			}
		}
	}
}
//------------------------------------------------------------------------------

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 ---