Author: Copyright 2005,SS
Orders Execution
Checks for the total of open ordersIt can change open orders parameters, due to possible stepping strategyIt Closes Orders by itself It automatically opens orders when conditions are reached
Indicators Used
Stochastic oscillator
Miscellaneous
It plays sound alerts
0 Views
0 Downloads
0 Favorites

Profitability Reports

AUD/USD Oct 2024 - Jan 2025
51.00 %
Total Trades 614
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -0.74
Gross Profit 478.20
Gross Loss -934.20
Total Net Profit -456.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
51.00 %
Total Trades 757
Won Trades 691
Lost trades 66
Win Rate 0.91 %
Expected payoff -1.01
Gross Profit 782.60
Gross Loss -1547.40
Total Net Profit -764.80
-100%
-50%
0%
50%
100%
stox

   
//+------------------------------------------------------------------+
//|                           Copyright 2005, Gordago Software Corp. |
//|                                      mail://CENTR75@MAIL.RU      |
//+------------------------------------------------------------------+

#property copyright "Copyright 2005,SS"
#property link      " mail://CENTR75@MAIL.RU "

#define MAGIC 216457

extern double lStopLoss = 500;
extern double sStopLoss = 500;
extern double lTakeProfit = 100;
extern double sTakeProfit = 100;
extern double lTrailingStop = 4;
extern double sTrailingStop = 4;
extern color clOpenBuy = Blue;
extern color clCloseBuy = Aqua;
extern color clOpenSell = Red;
extern color clCloseSell = Violet;
extern color clModiBuy = Blue;
extern color clModiSell = Red;
extern string Name_Expert = "Generate from Gordago";
extern int Slippage = 0;
extern bool UseSound = True;
extern string NameFileSound = "alert.wav";
extern double Lots = 0.10;
extern int  per=2;
extern int  per1=4;
extern int zam=1;
extern int Bands_Mode_0_2=0;  // =0-2 MODE_MAIN, MODE_LOW, MODE_HIGH
extern int Power_Price_0_6=1; // =0-6 PRICE_CLOSE,PRICE_OPEN,PRICE_HIGH,PRICE_LOW,PRICE_MEDIAN,PRICE_TYPICAL,PRICE_WEIGHTED
extern int Price_Type_0_3=1;  // =0-3 PRICE_CLOSE,PRICE_OPEN,PRICE_HIGH,PRICE_LOW
extern int Bands_Period=50;
extern int Power_Period=90;
extern int CountBars=50;


void deinit() {
   Comment("");
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start(){
    
   if(Bars<100){
      Print("bars less than 100");
      return(0);
   }
   if(lStopLoss<10){
      Print("StopLoss less than 10");
      return(0);
   }
   if(lTakeProfit<10){
      Print("TakeProfit less than 10");
      return(0);
   }
   if(sStopLoss<10){
      Print("StopLoss less than 10");
      return(0);
   }
   if(sTakeProfit<10){
      Print("TakeProfit less than 10");
      return(0);
   }

   double diWPR0=iStochastic(NULL,0,per,1,zam,MODE_EMA,0,MODE_MAIN,0);
 
   double diWPR1=iStochastic(NULL,0,per1,1,zam,MODE_EMA,0,MODE_MAIN,0);
   
    
     
   
   double diADX0=iCustom(NULL,0,"Trend",Bands_Mode_0_2,Power_Price_0_6,Price_Type_0_3,Bands_Period,Power_Period,CountBars,MODE_MAIN,0);
   double diADX1=iCustom(NULL,0,"Trend",Bands_Mode_0_2,Power_Price_0_6,Price_Type_0_3,Bands_Period,Power_Period,CountBars,MODE_SIGNAL,0);
   double diADX2=iCustom(NULL,0,"Trend",Bands_Mode_0_2,Power_Price_0_6,Price_Type_0_3,Bands_Period,Power_Period,CountBars,MODE_MAIN,0);
   double diADX3=iCustom(NULL,0,"Trend",Bands_Mode_0_2,Power_Price_0_6,Price_Type_0_3,Bands_Period,Power_Period,CountBars,MODE_SIGNAL,0);
   double diADX4=iCustom(NULL,0,"Trend",Bands_Mode_0_2,Power_Price_0_6,Price_Type_0_3,Bands_Period,Power_Period,CountBars,MODE_MAIN,0);
   double diADX5=iCustom(NULL,0,"Trend",Bands_Mode_0_2,Power_Price_0_6,Price_Type_0_3,Bands_Period,Power_Period,CountBars,MODE_SIGNAL,0);
   double diADX6=iCustom(NULL,0,"Trend",Bands_Mode_0_2,Power_Price_0_6,Price_Type_0_3,Bands_Period,Power_Period,CountBars,MODE_MAIN,0);
   double diADX7=iCustom(NULL,0,"Trend",Bands_Mode_0_2,Power_Price_0_6,Price_Type_0_3,Bands_Period,Power_Period,CountBars,MODE_SIGNAL,0);
   if(AccountFreeMargin()<(1000*Lots)){
      Print("We have no money. Free Margin = ", AccountFreeMargin());
      return(0);
   }
   if (!ExistPositions()){

      if ((diWPR0<1 && diADX0>diADX1 )){
         OpenBuy();
         return(0);
      }

      if ((diWPR0>99  && diADX0<diADX1 )){
         OpenSell();
         return(0);
      }
   }
   if (ExistPositions()){
      if(OrderType()==OP_BUY){

         if ((diWPR1>99 || diADX0<diADX1 )){
            CloseBuy();
            return(0);
         }
      }
      if(OrderType()==OP_SELL){

         if ((diWPR1<1 || diADX0>diADX1)){
            CloseSell();
            return(0);
         }
      }
   }
   TrailingPositionsBuy(lTrailingStop);
   TrailingPositionsSell(sTrailingStop);
   return (0);
}

bool ExistPositions() {
	for (int i=0; i<OrdersTotal(); i++) {
		if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
			if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) {
				return(True);
			}
		} 
	} 
	return(false);
}
void TrailingPositionsBuy(int trailingStop) { 
   for (int i=0; i<OrdersTotal(); i++) { 
      if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { 
         if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) { 
            if (OrderType()==OP_BUY) { 
               if (Bid-OrderOpenPrice()>trailingStop*Point) { 
                  if (OrderStopLoss()<Bid-trailingStop*Point) 
                     ModifyStopLoss(Bid-trailingStop*Point); 
               } 
            } 
         } 
      } 
   } 
} 
void TrailingPositionsSell(int trailingStop) { 
   for (int i=0; i<OrdersTotal(); i++) { 
      if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { 
         if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) { 
            if (OrderType()==OP_SELL) { 
               if (OrderOpenPrice()-Ask>trailingStop*Point) { 
                  if (OrderStopLoss()>Ask+trailingStop*Point || OrderStopLoss()==0)  
                     ModifyStopLoss(Ask+trailingStop*Point); 
               } 
            } 
         } 
      } 
   } 
} 
void ModifyStopLoss(double ldStopLoss) { 
   bool fm;
   fm = OrderModify(OrderTicket(),OrderOpenPrice(),ldStopLoss,OrderTakeProfit(),0,CLR_NONE); 
   if (fm && UseSound) PlaySound(NameFileSound); 
} 

void CloseBuy() { 
   bool fc; 
   fc=OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, clCloseBuy); 
   if (fc && UseSound) PlaySound(NameFileSound); 
} 
void CloseSell() { 
   bool fc; 
   fc=OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, clCloseSell); 
   if (fc && UseSound) PlaySound(NameFileSound); 
} 
void OpenBuy() { 
   double ldLot, ldStop, ldTake; 
   string lsComm; 
   ldLot = GetSizeLot(); 
   ldStop = GetStopLossBuy(); 
   ldTake = GetTakeProfitBuy(); 
   lsComm = GetCommentForOrder(); 
   OrderSend(Symbol(),OP_BUY,ldLot,Ask,Slippage,ldStop,ldTake,lsComm,MAGIC,0,clOpenBuy); 
   if (UseSound) PlaySound(NameFileSound); 
} 
void OpenSell() { 
   double ldLot, ldStop, ldTake; 
   string lsComm; 

   ldLot = GetSizeLot(); 
   ldStop = GetStopLossSell(); 
   ldTake = GetTakeProfitSell(); 
   lsComm = GetCommentForOrder(); 
   OrderSend(Symbol(),OP_SELL,ldLot,Bid,Slippage,ldStop,ldTake,lsComm,MAGIC,0,clOpenSell); 
   if (UseSound) PlaySound(NameFileSound); 
} 
string GetCommentForOrder() { 	return(Name_Expert); } 
double GetSizeLot() { 	return(Lots); } 
double GetStopLossBuy() { 	return (Bid-lStopLoss*Point);} 
double GetStopLossSell() { 	return(Ask+sStopLoss*Point); } 
double GetTakeProfitBuy() { 	return(Ask+lTakeProfit*Point); } 
double GetTakeProfitSell() { 	return(Bid-sTakeProfit*Point); } 
   

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