W-M-P-G(buy-4%)

Author: Copyright � 2007, Yavnikov Maxim
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
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/CAD 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%
W-M-P-G(buy-4%)
//+------------------------------------------------------------------+
//|                                       When my people go(buy).mq4 |
//|                                 Copyright © 2007, Yavnikov Maxim |
//|                                                       m-gm@bk.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, Yavnikov Maxim"
#property link      "m-gm@bk.ru"

extern int     Lots=1;
extern int     Timer=600; //inteval between the modifications
extern int     PerTS=10;  //period ATR for calculation TS/SL
extern double	Kts=7.5;   //ATR for calculating the level TS/SL	
extern int     risk=4;   //% risk from available capital
extern int     MiniForex=1;
extern int     Slippage=5;

datetime LastTradeTime=0;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
  int PrBuy=0,i,DolPunkt;
  double HD,LD,lotsi,StopLos;
//----

if(OrdersTotal()>0) OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
if(OrdersTotal()>0 && OrderType()==OP_BUY)  PrBuy=1;
if(OrdersTotal()>0 && OrderType()==OP_SELL) PrBuy=0;

HD=0;	LD=0; 
 for(i=1;i<=PerTS;i++) //StopLoss & TralingStop
 {
   HD+=High[i-1];
	LD+=Low[i-1];
 }
 
StopLos=Kts*MathSqrt((HD-LD)/PerTS/Point)*Point;

if(Symbol()=="EURUSD") DolPunkt = 10;
else if(Symbol()=="GBPUSD") DolPunkt = 7;
     else return(0);

if(CurTime()>LastTradeTime+10)
{
  if(OrdersTotal()<1)
  {   
 
	if(risk!=0) lotsi=NormalizeDouble(AccountBalance()*risk/100/DolPunkt/StopLos*Point,1);
 	else lotsi=Lots;
           
 	if(lotsi > 10) lotsi=MathFloor(lotsi);
 	if(lotsi < 0.1 && MiniForex!=0) lotsi=0.1;
 	if(lotsi < 1 && MiniForex==0) lotsi=1;
 	Comment("lotsi - ",lotsi,"\n","\n","lotsi - ",lotsi,"\n","\n","Buy - ",PrBuy);
   
  	if(PrBuy==0)
	 { //SetOrder(OP_BUY,lotsi,bid,Slippage,bid-StopLos,0,Lime);
      OrderSend(Symbol(),OP_BUY,lotsi,Bid,Slippage,Bid-StopLos,0,"Ïîêóïàåì",16384,0,Lime);
      LastTradeTime=CurTime();
		 					
 	 }
 	 if(PrBuy==1)
	 { //SetOrder(OP_SELL,lotsi,ask,Slippage,ask+StopLos,0,Blue);
      OrderSend(Symbol(),OP_SELL,lotsi,Ask,Slippage,Ask+StopLos,0,"Ïðîäàåì",16384,0,Blue);      
      LastTradeTime=CurTime();
      return(0);		
 	 }
  }	 
}

 	
if(OrdersTotal()<1 || (CurTime()-LastTradeTime)<Timer) return(0);
   OrderSelect(0,SELECT_BY_POS,MODE_TRADES);   
   if(OrderType()==OP_BUY && OrderSymbol()==Symbol())
     {  		
         if(OrderStopLoss()<Bid-StopLos-10*Point)
           {
               // ModifyOrder(Ord(1,VAL_TICKET),Ord(1,VAL_OPENPRICE),Bid-STOPLOS,0,LightGreen);
               OrderModify(OrderTicket(),OrderOpenPrice(),Bid-StopLos,0,LightGreen);

               return(0);  
           }
     }
   
   if(OrderType()==OP_SELL && OrderSymbol()==Symbol())
  	{      
        if(OrderStopLoss()>Ask+StopLos+10*Point || OrderStopLoss()==0)
        {
           // ModifyOrder(Ord(1,VAL_TICKET),Ord(1,VAL_OPENPRICE),Ask+STOPLOS,0,Yellow);
           OrderModify(OrderTicket(),OrderOpenPrice(),Ask+StopLos,0,Yellow);
           return(0);             
        }
  	}


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