关于根据布林通道下单,希望斑竹大大们,帮看下
基本思路就是超过布林上下限进行开平。于是直接使用了布林通道指标 但是在复盘模型里发现每个K线都进行了操作,并没有按照基本的思路进行操作。 请帮忙看下,解释下这是什么原因。 另外当takeprofit为10的时候,没办法下单 显示的OrderSend 出现为130的错误代码。 //+------------------------------------------------------------------+ //| 通道1 指标改.mq4 | //| Copyright ?2009, metaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright ?2009, metaQuotes Software Corp." #property link "http://www.metaquotes.net" extern double volume = 0.1; //默认交易量 extern int stoploss = 500; //止损 extern int takeprofit = 20; //止赢 extern int slippage = 1; //滑点 extern int magic = 0; //EA标识码 datetime last_t = 0; //用来防止同一信号位置重复进行交易 //---- indicator parameters extern int BandsPeriod=20; extern int BandsShift=0; extern double BandsDeviations=2.0; //---- buffers double MovingBuffer[]; double UpperBuffer[]; double LowerBuffer[]; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { int i,k,counted_bars=IndicatorCounted(); double deviation; double sum,oldval,newres; //---- if(Bars=i) { newres=Close[k]-oldval; sum+=newres*newres; k--; } deviation=BandsDeviations*MathSqrt(sum/BandsPeriod); UpperBuffer<i>=oldval+deviation; LowerBuffer<i>=oldval-deviation; i--; } if (Low[0]< LowerBuffer[0]&& Time[0]>last_t) { OrderSend(Symbol(), OP_BUY, volume, MarketInfo(Symbol(), MODE_ASK), slippage, MarketInfo(Symbol(), MODE_ASK)-stoploss*MarketInfo(Symbol(), MODE_POINT), MarketInfo(Symbol(), MODE_ASK)+takeprofit*MarketInfo(Symbol(), MODE_POINT), "", magic, 0, CLR_NONE); last_t = Time[0]; } else if (High[0]> UpperBuffer[0]&& Time[0]>last_t) { OrderSend(Symbol(), OP_SELL, volume, MarketInfo(Symbol(), MODE_BID), slippage, MarketInfo(Symbol(), MODE_BID)+stoploss*MarketInfo(Symbol(), MODE_POINT), MarketInfo(Symbol(), MODE_BID)-takeprofit*MarketInfo(Symbol(), MODE_POINT), "", magic, 0, CLR_NONE); last_t = Time[0]; } return(0); } //+------------------------------------------------------------------+[/td][/tr] |
打赏
最新创建圈子
- 新闻EA运行效果图圈 2019-05-05
圈主:admin 帖子:1