自动交易系统编程求助。
发表于:2006-10-28 00:22只看该作者
2楼
我还想找一个人帮我呢。有好的说一声
韬客社区www.talkfx.co
发表于:2006-10-28 01:31只看该作者
3楼
和和。 看看书,能编出来的。或者, 直接从别的交易系统改造。
4楼
看来要自己弄了,好好研究下。
韬客社区www.talkfx.co
发表于:2006-10-28 13:57只看该作者
5楼
根据别人的EA修改的,希望你能用得上。
//+------------------------------------------------------------------+
//| MA_3_27.mq4 |
//| Coders Guru |
//| |
//+------------------------------------------------------------------+
#property copyright "Coders Guru"
//---- Includes
#include
//---- Trades limits
extern double TrailingStop = 40;
extern double TakeProfit = 1000; //any big number
extern double Lots = 0.1;
extern int Slippage = 5;
//--- External options
extern int CurrentBar = 1;
extern bool UseClose = true;
//--- Indicators settings
extern int MaMode = 0; /* MODE_SMA 0 MODE_EMA 1 MODE_SMMA 2 MODE_LWMA 3 */
extern int ShortEma = 3;
extern int LongEma = 27;
//--- Global variables
int MagicNumber = 123430;
string ExpertComment = "MA_3_27";
bool LimitPairs = false;
bool LimitFrame = false;
int TimeFrame = 60;
string LP = {"GBPUSD","USDCHF","EURUSD","USDJPY","AUDUSD","USDCAD"}; // add/remove the paris you want to limit.
bool Optimize = false;
int NumberOfTries = 5;
//+------------------------------------------------------------------
int init()
{
return(0);
}
int deinit()
{
return(0);
}
//+------------------------------------------------------------------
bool isNewSymbol(string current_symbol)
{
//loop through all the opened order and compare the symbols
int total = OrdersTotal();
for(int cnt = 0 ; cnt < total ; cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
string selected_symbol = OrderSymbol();
if (current_symbol == selected_symbol && OrderMagicNumber()==MagicNumber)
return (False);
}
return (True);
}
//+------------------------------------------------------------------
int Crossed()
{
double EmaLongPrevious = iMA(NULL,0,LongEma,0,MaMode, PRICE_CLOSE, CurrentBar+1);
double EmaLongCurrent = iMA(NULL,0,LongEma,0,MaMode, PRICE_CLOSE, CurrentBar);
double EmaShortPrevious = iMA(NULL,0,ShortEma,0,MaMode, PRICE_CLOSE, CurrentBar+1);
double EmaShortCurrent = iMA(NULL,0,ShortEma,0,MaMode, PRICE_CLOSE, CurrentBar);
if (EmaShortPreviousEmaLongCurrent ) return (1); //up trend
if (EmaShortPrevious>EmaLongPrevious && EmaShortCurrent0)
{
if(OrderMagicNumber() == MagicNumber)
{
if(type==OP_BUY)
{
if(Bid-OrderOpenPrice()>Point*TrailingStop)
{
if(OrderStopLoss()(Point*TrailingStop))
{
if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
}
}
}
}
}
}
void CheckError(int ticket, string Type)
{
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print(Type + " order opened : ",OrderOpenPrice());
}
else Print("Error opening " + Type + " order : ", ErrorDescription(GetLastError()));
}
bool AllowedPair(string pair)
{
bool result=false;
for (int n = 0 ; n < ArraySize(LP); n++)
{
if(Symbol() == LP[n])
{
result = true;
}
}
return (result);
}
[ 本帖最后由 管理员No.6 于 2006-10-29 00:56 编辑 ]
韬客社区www.talkfx.co
发表于:2006-10-28 16:33只看该作者
6楼
谢谢楼上滴高手呀
Patience!Wisdom, concentrated, sincere, will