//+------------------------------------------------------------------+//| RSI_strategy_cyxstudio.mq4 |//| Copyright 2013, Tjipke de Vries |//| https://forum.mql4.com/53695/ |//+------------------------------------------------------------------+#property copyright "Copyright 2013, MetaQuotes Software Corp."#property link "http://www.metaquotes.net"externint RSIPeriod = 3; //number of periods for RSI//WHY DIDN't YOU LEAVE THIS VALUE 3 externdouble UpperBound = 90; //set upper bound value for RSI//WHY DID YOU MAKE THIS TO 95externdouble LowerBound = 5; //set lower bound value for RSIexternint MASlowPeriod = 200;
externint MAFastPeriod = 5;
externdouble Lots = 0.1;
externdouble StopLoss = 60; //Set the stop loss levelexterndouble TakeProfit = 120; //Set the take profit levelexterndouble TrailingStop = 40;
//extra settings for OrderSendexternint MagicNumber = 54333;
externstring CommentEA = "RSI strategy";
externint Slippage.Pips = 3;
int BUYS=1,SELLS=1; //WHY DID YOU REMOVE THIS FROM YOUR CODE//++++ These are adjusted for 5 digit brokers.int pips2points; // slippage 3 pips 3=points 30=pointsdouble pips2dbl; // Stoploss 15 pips 0.015 0.0150intDigits.pips; // DoubleToStr(dbl/pips2dbl, Digits.pips)//---//+------------------------------------------------------------------+//| expert initialization function |//+------------------------------------------------------------------+int init()
{
//---- if(Digits % 2 == 1) // DE30=1/JPY=3/EURUSD=5 forum.mql4.com/43064#515262
{pips2dbl = Point*10; pips2points = 10; Digits.pips = 1;}
else {pips2dbl = Point; pips2points = 1; Digits.pips = 0;}
// OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl //WHY DID YOU REMOVE THIS //---- //?? Alert(OrdersTotal()); //WHAT IS THIS DOING HERE THIS IS NOT IN MY CODE//----return(0);
}
//+------------------------------------------------------------------+//| expert deinitialization function |//+------------------------------------------------------------------+int deinit()
{
//----//----return(0);
}
//+------------------------------------------------------------------+//| expert start function |//+------------------------------------------------------------------+int start()
{
//----int Ticket;
double SL,TP;
int Total;
double pAsk = MarketInfo(Symbol(), MODE_ASK);
double pBid = MarketInfo(Symbol(), MODE_BID);
double MA200 = iMA(NULL, 1440, MASlowPeriod, 0,MODE_SMA,PRICE_CLOSE, 0); //200 day Moving Average double MA5 = iMA(NULL, 1440, MAFastPeriod, 0,MODE_SMA,PRICE_CLOSE, 0); // 5 day Moving Averagedouble CurrentRSI = iRSI (NULL, 1440, RSIPeriod,PRICE_CLOSE ,0);
//WHY DID YOU MAKE PrevRSI and LastRSI REMOVE IT IT IS NOT IN MY CODE
if(Bars<100)
{
Print("bars less than 100");
return(0);
}
if(AccountFreeMargin()<(1000*Lots))
{
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}
if(OrdersTotal()<1) // WHY DID YOU REMOVE THIS
{
BUYS=0;
SELLS=0;
}
这是我最新的代码。除了没有给我想要的结果外,我想不出有什么问题。
如果你看一下这个主题的第2页,你可以找到我给你的东西
这就是开始.....
把你的评论.....,到目前为止,你的评论有什么不同......
然后阅读一下https://www.mql5.com/en/forum/139654,并尝试做一个循环的倒数检查交易。
正如你所看到的,我要求做一个循环,向下检查交易。
这是我在代码中的下一步
我只要求你提供这部分的代码
让它分别计算买入交易和卖出交易
如果你看一下这个主题的第2页,你可以找到我给你的东西
我删除了它,因为我不知道如何使用它。你给了我部分代码,我看不到它的功能。
--
这就是开始.....
把你的评论.....,说说到目前为止和你有什么不同......
然后阅读一下https://www.mql5.com/en/forum/139654,并尝试做一个循环的倒数检查交易。
正如你所看到的,我要求做一个循环,倒数检查交易。
这是我在代码中的下一步
我只要求你提供这部分的代码
让它分别计算买入交易和卖出交易
像这样?
int ticket=OrderTicket()。//要执行的代码块
}
我删除了它,因为我不知道如何使用它。你给了我部分代码,我看不到它的功能。
当EA再次启动时
买入价被设置为1
卖出(SELLS)被设置为1
OrdersTotal()是您账户上所有未结交易的总和。
它可以是0,那么我们就没有交易,我们不需要检查 是否有这个EA的交易。
如果OrdersTotal()>0,则BUYS保持为1,SELLS保持为1 。
在这种情况下,我们需要检查它是否来自我们的EA,我们必须计算不同的类型(买入,卖出,买入限额....)。
所以
像这样?
int ticket=OrderTicket()。//要执行的代码块
}
使用SRC按钮
这个循环我们只开始(为什么条件)。
你怎么知道在循环中选择的交易是买入还是卖出?
你如何计算它们呢?
使用SRC按钮
这个循环我们只开始(为什么条件)。
你怎么知道循环中所选择的交易是买入还是卖出?
你如何计算它们呢?
错了。
对于平仓交易的功能。
使用
if (OrderType() == OP_SELL && pBid < MA5)
来区分买入和卖出。
我的开单条件有什么问题吗?
我是否应该删除它,用我用于平仓功能的循环来代替?
反对。
为封闭式交易功能。
使用
来区分买入和卖出。
我的开单条件有什么问题吗?
我是否应该删除它,用我用于平仓功能的循环来代替?
在这个时候,你必须检查 是否已经有一笔交易在进行。
在你开仓之前,你必须知道是否有一笔交易正在进行。
我还是看不出你已经完成了对交易的计算
.
看看你的metatrader站上的 移动平均线EA 的代码,看看它是如何完成的 ....