Orders Execution
Miscellaneous
0
Views
0
Downloads
0
Favorites
Profitability Reports
AUD/USD
Oct 2024 - Jan 2025
79.00 %
Total Trades
2
Won Trades
0
Lost trades
0
Win Rate
0.00 %
Expected payoff
-4219.15
Gross Profit
31559.17
Gross Loss
-39997.47
Total Net Profit
-8438.30
-100%
-50%
0%
50%
100%
GBP/USD
Oct 2024 - Jan 2025
93.00 %
Total Trades
2
Won Trades
1
Lost trades
1
Win Rate
0.50 %
Expected payoff
-821.83
Gross Profit
20806.52
Gross Loss
-22450.18
Total Net Profit
-1643.66
-100%
-50%
0%
50%
100%
SupRes_EA_v1.6e
//SupRes_EA_v1.6c.mq4 Copyright © 2008, Arshad Qureshi
#property copyright "Copyright © 2008, Arshad Qureshi. ArshadFX"
extern double Lots = 0.0;
extern int Percent = 10; // Allocated funds in percentage to use this function "Lot" size must be 0.0
extern double TakeProfit = 50;
extern double StopLoss = 50;
extern int ExtDepth=12;
extern int ExtDeviation=5;
extern int ExtBackstep=3;
extern int back = 0;
string Symb;
int B_M_no = 112233123; // magic no for opening long
int S_M_no = 112233321; // magic no for opening short
// GV for ZIG ZAG ---------------------------------------------------------------------------------
double high_p_temp = 0, low_p_temp = 0;
double zz_p[5], high_p[3], low_p[3]; // zigzag peaks prices and positions
int zz_i[5], high_i[3], low_i[3]; // zigzag lows prices and positions
// GV for Orders accounting -----------------------------------------------------------------------
int Mas_Tip[6]; // Order type array Mas_Tip[]: 0=B,1=S,2=BL,3=SL,4=BS,5=SS
double Mas_Ord_New[31][9], // Current order array ..
Mas_Ord_Old[31][9]; // .. old order array
// GV for calculatin of lot size ------------------------------------------------------------------
double Lots_New; // Amount of lots for new orders function Lot()
// GV for High TL and Low TL flags ----------------------------------------------------------------
bool high_flag=true, low_flag= true, new_h = false, new_l = false;
// Init and Dinit functions -----------------------------------------------------------------------
int init(){return(0);}
int deinit(){return(0);}
// expert start function --------------------------------------------------------------------------
int start()
{
int ticket;
bool buy = false, sell = false;
Symb=Symbol();
int count = 0;
for(int i = 0 ; i < Bars ; i++)
{
double zz = iCustom(Symbol(),0,"zigzag",ExtDepth,ExtDeviation,ExtBackstep,0,i);
if (zz != 0) count++;
if(count == back + 1 && zz != 0) {zz_p[0] = zz; zz_i[0] = i;}
if(count == back + 2 && zz != 0) {zz_p[1] = zz; zz_i[1] = i;}
if(count == back + 3 && zz != 0) {zz_p[2] = zz; zz_i[2] = i;}
if(count == back + 4 && zz != 0) {zz_p[3] = zz; zz_i[3] = i;}
if(count == back + 5 && zz != 0) {zz_p[4] = zz; zz_i[4] = i;}
if(count == back + 6) break;
}
count = 0;
if (zz_p[0] > zz_p[1])
{
high_p[1] = zz_p[2]; high_i[1] = zz_i[2];
high_p[2] = zz_p[4]; high_i[2] = zz_i[4];
low_p[1] = zz_p[1]; low_i[1] = zz_i[1];
low_p[2] = zz_p[3]; low_i[2] = zz_i[3];
}
else
{
high_p[1] = zz_p[1]; high_i[1] = zz_i[1];
high_p[2] = zz_p[3]; high_i[2] = zz_i[3];
low_p[1] = zz_p[2]; low_i[1] = zz_i[2];
low_p[2] = zz_p[4]; low_i[2] = zz_i[4];
}
dTrend("high_1",high_i[1],high_i[1],high_p[1],high_p[1],Green);
dTrend("Low_1",low_i[1],low_i[1],low_p[1],low_p[1],Red);
// New levels are formed --------------------------------------------------------------------------
if (high_p[1] != high_p_temp) {high_p_temp = high_p[1]; high_flag = true; Delete_Ord(4);}
if (low_p[1] != low_p_temp ) { low_p_temp = low_p[1]; low_flag = true; Delete_Ord(5);}
Terminal();
// Trading criteria -------------------------------------------------------------------------------
if (Ask >= high_p[1]-100*Point && Mas_Tip[4] == 0 && Mas_Tip[0] == 0 && high_flag == true)
{
Alert (" price is near Upper Line TradingCriteria triggered ");
buy = true;
high_flag = false;
low_flag = true;
}
if (Bid <= low_p[1]+100*Point && Mas_Tip[5] == 0 && Mas_Tip[1] == 0 && low_flag == true)
{
Alert (" price is near Lower Line TradingCriteria triggered ");
sell = true;
low_flag = false;
high_flag = true;
}
Lot();
// Order send -------------------------------------------------------------------------------------
if (buy == true)
{
Delete_Ord(5);
ticket=OrderSend(Symb,OP_BUYSTOP,Lots_New,high_p[1],2,0,0,"Comments of OrderSend",B_M_no); //Opening Buy
Alert ("return of ordersend ticket :",ticket," buy magic no : ",B_M_no);
}
if (sell == true)
{
Delete_Ord(4);
ticket=OrderSend(Symb,OP_SELLSTOP,Lots_New,low_p[1],2,0,0,"Comments of OrderSend",S_M_no); //Opening Buy
Alert ("return of ordersend ",ticket);
}
// Display on screen ------------------------------------------------------------------------------
Comment (
"TakeProfit = ",high_p[1]+TakeProfit*Point*10
,"\nStopLoss = ",high_p[1]-StopLoss*Point*10
,"\nBuyStop = ",Mas_Tip[4]," B_M_no : ",Mas_Ord_New[1][4]
,"\nSellStop = ",Mas_Tip[5]," S_M_no : ",Mas_Ord_New[1][4]
,"\nBought Mas_Tip[0] = ",Mas_Tip[0]
,"\nSold Mas_Tip[1] = ",Mas_Tip[1]
,"\nTotalOrders using Mas_Ord_New[0][0])= ",Mas_Ord_New[0][0]
,"\nhigh_flag :",high_flag," low_flag :",low_flag
);
return(0);
}
// End of start function --------------------------------------------------------------------------
// User define functions --------------------------------------------------------------------------
void dTrend (string name, int sTime, int eTime, double sPrice, double ePrice, color colour)
{
ObjectDelete(name);
ObjectCreate(name,OBJ_TREND,0,iTime(NULL,0,sTime),sPrice,iTime(NULL,0,eTime-2),ePrice);
ObjectSet(name,OBJPROP_COLOR,colour);
ObjectSetText(name,name+" "+DoubleToStr(sPrice,Digits),10);
}
int Terminal()
{
int Qnt=0; // Orders counter
//------------------------------------------------------------------------------ 3 --
ArrayCopy(Mas_Ord_Old, Mas_Ord_New);// Saves the preceding history
Qnt=0; // Zeroize orders counter
ArrayInitialize(Mas_Ord_New,0); // Zeroize the array
ArrayInitialize(Mas_Tip, 0); // Zeroize the array
//------------------------------------------------------------------------------ 4 --
for(int i=0; i<OrdersTotal(); i++) // For market and pending orders
{
if((OrderSelect(i,SELECT_BY_POS)==true) //If there is the next one
&& (OrderSymbol()==Symbol())) //.. and our currency pair
{ //--------------------------------------------------------------------- 5 --
Qnt++; // Amount of orders
Mas_Ord_New[Qnt][1]=OrderOpenPrice(); // Order open price
Mas_Ord_New[Qnt][2]=OrderStopLoss(); // SL price
Mas_Ord_New[Qnt][3]=OrderTakeProfit(); // TP price
Mas_Ord_New[Qnt][4]=OrderTicket(); // Order number
Mas_Ord_New[Qnt][5]=OrderLots(); // Amount of lots
Mas_Tip[OrderType()]++; // Amount of orders of the type
Mas_Ord_New[Qnt][6]=OrderType(); // Order type
Mas_Ord_New[Qnt][7]=OrderMagicNumber(); // Magic number
if (OrderComment()=="")
Mas_Ord_New[Qnt][8]=0; // If there is no comment
else
Mas_Ord_New[Qnt][8]=1; // If there is a comment
//--------------------------------------------------------------------- 6 --
}
}
Mas_Ord_New[0][0]=Qnt; // Amount of orders
//------------------------------------------------------------------------------ 7 --
return;
}
// -------------------------------------------------------------------------------------------------
bool Lot() // User-defined function
{
string Symb =Symbol(); // Symbol
double One_Lot=MarketInfo(Symb,MODE_MARGINREQUIRED);//!-lot cost
double Min_Lot=MarketInfo(Symb,MODE_MINLOT);// Min. amount of lots
double Step =MarketInfo(Symb,MODE_LOTSTEP);//Step in volume changing
double Free =AccountFreeMargin(); // Free margin
//----------------------------------------------------------------------------- 3 --
if (Lots>0) // Volume is explicitly set..
{ // ..check it
double Money=Lots*One_Lot; // Order cost
if(Money<=AccountFreeMargin()) // Free margin covers it..
Lots_New=Lots; // ..accept the set one
else // If free margin is not enough..
Lots_New=MathFloor(Free/One_Lot/Step)*Step;// Calculate lots
}//----------------------------------------------------------------------------- 4 --
else // If volume is not preset
{ // ..take percentage
if (Percent > 100) // Preset, but incorrectly ..
Percent=100; // .. then no more than 100
if (Percent==0) // If 0 is preset ..
Lots_New=Min_Lot; // ..then the min. lot
else // Desired amount of lots:
Lots_New=MathFloor(Free*Percent/100/One_Lot/Step)*Step;//Calc
}//----------------------------------------------------------------------------- 5 --
if (Lots_New < Min_Lot) // If it is less than allowed..
Lots_New=Min_Lot; // .. then minimum
if (Lots_New*One_Lot > AccountFreeMargin()) // It isn't enough even..
{ // ..for the min. lot:(
Alert ("This message is from Lot() "); // Message..
return(false); // ..and exit
} return(true); // Exit user-defined function
}//----------------------------------------------------------------------------- 6 --
//-------------------------------------------------------------------------------------------------
int Delete_Ord(int Tip) // User-defined function
{
int Ticket=0; // Order ticket
//---------------------------------------------------------------------------- 3 --
while(Mas_Tip[Tip]>0) // As long as the orders of the ..
{ //.. given type are available
for(int i=1; i<=Mas_Ord_New[0][0]; i++)// Cycle for live orders
{
if(Mas_Ord_New[i][6]==Tip) // .. select the most expensive one
{ // This one was found at earliest.
Ticket=Mas_Ord_New[i][4]; // Its order ticket is that
bool Ans=OrderDelete(Ticket);// Close order !:)
Terminal();
if (Ans==false)
{
Alert(" fail to delete pending order ");
return;
}
}
}
}
return; // Exit the user-defined function
}
// ---------------------------------------------------------------------------------------- The END
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
---