[MT4-EA]2008-BUY-SELL-EA研究
2008年的一个ea指标
学习者可以拿去做下研究///+-----------------------------------------------------------------+
//| Original idea from: BUY-SELL STOP.mq4 |
//| Copyright 2008, Guillermo Arango |
//| [email protected] |
//+------------------------------------------------------------------+
#property copyright "Copyright 2008, Rob Turcotte"
#property link "[email protected]"
#property show_inputs
extern int Level = 10;
extern double Lots = 0.1;
extern int TakeProfit=140;
extern bool Place_buylimit = true;
extern bool Place_selllimit = true;
extern int GridSpacing=35;
extern double GridUpperLimit=0;
extern double GridLowerLimit=0;
extern double StartPoint= 202.45;
extern double MagicNum = 1001;
int totalOpenOrders = 0;
bool OpenOrders = false;
int total, cnt, totalBuyStop, totalSellStop, totalBuy, totalSell, TSS, TBS;
double spread;
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----Establish if Stop Order filled
total = OrdersTotal();
totalBuyStop = 0;
totalSellStop = 0;
totalSell = 0;
totalBuy = 0;
for(cnt = 0; cnt < total; cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNum)
{
if(OrderType() == OP_BUYSTOP)
totalBuyStop++;
if(OrderType() == OP_BUY)
totalBuy++;
}
}
for(cnt = 0; cnt < total; cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNum)
{
if(OrderType() == OP_SELLSTOP)
totalSellStop++;
if(OrderType() == OP_SELL)
totalSell++;
}
}
TSS = totalSellStop;
TBS = totalBuyStop;
Comment("TSS=", TSS, " TBS=", TBS);
if(totalOpenOrders < (totalBuy + totalSell)) // Order just opened, open more pending orders
{ totalOpenOrders = totalBuy + totalSell;
OpenPendingOrders();
}
if(totalOpenOrders > 0)
OpenOrders = true;
if(OpenOrders == true && (totalBuy + totalSell) == 0) // all orders closed, close pending orders
{ ClosePendingOrders();
totalOpenOrders = 0;
}
if(totalBuyStop == 0 && totalSellStop == 0) //no open orders or pending orders, start cycle again
{ StartPoint = Ask;
OpenPendingOrders();
}
return(0);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| script "send pending order with expiration data" |
//+------------------------------------------------------------------+
int OpenPendingOrders()
{
int ticket;
double CurrentLevel=0.00;
double point;
int TakeProfit1=TakeProfit;
double StartPoint1=StartPoint;
double GridUpperLimit= StartPoint1 + ((TakeProfit1+8)*Point);
double GridLowerLimit= StartPoint1 - (TakeProfit1*Point);
//----
spread = MarketInfo(Symbol(), MODE_SPREAD);
point=MarketInfo(Symbol(),MODE_POINT);
int total;
total=OrdersTotal();
//----
CurrentLevel = GridLowerLimit;
while(CurrentLevel < GridUpperLimit)
while(true)
{
if (Place_selllimit)
if(CurrentLevel < (Bid - (Point * Level)))
ticket=OrderSend(Symbol(),OP_SELLSTOP,Lots,CurrentLevel,0,GridUpperLimit,GridLowerLimit+(spread*Point),"SELLSTOP",MagicNum,0,Red);
if (Place_buylimit)
if(CurrentLevel > (Ask + (Point * Level)) && CurrentLevel < (Ask + (Point * TakeProfit))) //ONLY BUY ABOVE ASK PRICE
ticket=OrderSend(Symbol(),OP_BUYSTOP,Lots,CurrentLevel,0,GridLowerLimit,GridUpperLimit-(spread*Point),"BUYSTOP",MagicNum,0,Green);
CurrentLevel = CurrentLevel + (GridSpacing * Point);
if(CurrentLevel > GridUpperLimit)
break;
}
//----
return(0);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
// Close Pending Orders
int ClosePendingOrders()
{
int total = OrdersTotal();
for(int i=total-1;i>=0;i--)
{
OrderSelect(i, SELECT_BY_POS);
int type = OrderType();
bool result = false;
if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNum)
{
switch(type)
{
//Close pending orders
case OP_BUYLIMIT :
case OP_BUYSTOP :
case OP_SELLLIMIT :
case OP_SELLSTOP : result = OrderDelete( OrderTicket() );
}
OpenOrders = false;
if(result == false)
{
Alert("Order " , OrderTicket() , " failed to close. Error:" , GetLastError() );
Sleep(3000);
}
}
}
return(0);
}
发表于:2014-12-18 07:06只看该作者
2楼
指标?
韬客社区www.talkfx.co
发表于:2015-01-06 03:24只看该作者
3楼
不错的指标 ~谢谢楼主~
韬客社区www.talkfx.co
发表于:2015-11-15 12:53只看该作者
4楼
感谢楼主分享
韬客社区www.talkfx.co
发表于:2015-12-11 10:47只看该作者
5楼
看看
韬客社区www.talkfx.co
发表于:2015-12-11 18:02只看该作者
6楼
不错的指标 ~谢谢楼主~ ,,,,,,,,,,,
韬客社区www.talkfx.co
发表于:2015-12-11 18:02只看该作者
7楼
不错的指标 ~谢谢楼主~
韬客社区www.talkfx.co
发表于:2015-12-13 13:51只看该作者
8楼
看看。。。。。。。。。。。。。。。。
韬客社区www.talkfx.co
发表于:2016-01-30 06:37只看该作者
9楼
651501510 求给一个
韬客社区www.talkfx.co
发表于:2016-06-17 12:54只看该作者
10楼
444444444444444444444444444444444444444444444444444
韬客社区www.talkfx.co
发表于:2016-08-09 13:28只看该作者
11楼
试试看看
发表于:2016-08-09 15:18只看该作者
12楼
回复下载
韬客社区www.talkfx.co
发表于:2016-08-14 12:59只看该作者
13楼
谢谢分享~
韬客社区www.talkfx.co
发表于:2017-08-08 23:28只看该作者
14楼
缺钱,灌水赚通宝,谢谢分享!!
韬客社区www.talkfx.co