简单的顺势加仓策略问题 新评论 Junbing Xie 2016.03.13 01:25 目标:手动指定起始价格、交易方向、加仓间隔后系统每达到一个加仓间隔自动加仓 写到自动加仓的时候发现,只有第一第二笔交易按照加仓间隔进行加仓了,后面的均在第二笔交易价格之上不停买入,请高手看下代码错在哪里?//+------------------------------------------------------------------+ //| shunshi.mq4 | //| Jaguar | //| FreeWorld | //+------------------------------------------------------------------+ #property copyright "Jaguar" #property link "FreeWorld" #property version "1.00" #property strict //----------------UserInputParameter--------------------------------- extern int GridSpace=300; extern double StartPrice=1.392; extern double Lots=0.1; extern bool BuyUp=true; extern bool SellDown=false; //----------------GlobalVariable-------------------------------------- double LastBuyPrice=StartPrice; double LastSellPrice=StartPrice; int BuyCount=0; int SellCount=0; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int init() { //--- //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ int deinit(const int reason) { //--- return(0); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void start() { //---BuyUP---------------------------------------------------------- if(BuyUp) { if(Ask>(LastBuyPrice+Point*GridSpace)) { if(OrderSend(Symbol(),OP_BUY,Lots,Ask,0,0,0,"BuyUp",9541,0,Red)==true) { LastBuyPrice+=Point*GridSpace; BuyCount+=1; } } } //---SellDown /* if(SellDown) { if(Bid<(LastBuyPrice-Point*GridSpace)) { if(OrderSend(Symbol(),OP_SELL,Lots,Ask,3,0,0)==true) { LastSellPrice=Bid; SellCount+=1; } } } */ } //+------------------------------------------------------------------+ 新评论
目标:手动指定起始价格、交易方向、加仓间隔后系统每达到一个加仓间隔自动加仓
写到自动加仓的时候发现,只有第一第二笔交易按照加仓间隔进行加仓了,后面的均在第二笔交易价格之上不停买入,请高手看下代码错在哪里?