whats wrong with this code?

Jul 31, 2016 at 06:54
492 การดู
5 Replies
เป็นสมาชิกตั้งแต่ Oct 23, 2012   349 โพสต์
Jul 31, 2016 at 06:54
if(max_spread_filter && (Ask-Bid)/myPoint>max_spread) enableopen=false;


gives a critical error when trying to backtest?
if you follow the flock like sheep you always end up stepping in shit!
forex_trader_25447
เป็นสมาชิกตั้งแต่ Dec 21, 2010   131 โพสต์
Aug 01, 2016 at 03:51
Possible errors :
1. Type of 'max_spread_filter' not 'bool'
2. 'myPoint' == 0.0
เป็นสมาชิกตั้งแต่ Nov 14, 2015   325 โพสต์
Aug 01, 2016 at 11:27
Divide by zero is the only critical error that can give. Basically myPoint is 0.
เป็นสมาชิกตั้งแต่ Jul 29, 2011   5 โพสต์
Aug 04, 2016 at 05:58
very difficult to say without seeing how u declared the variables like max_spread_filter.. at first glance altho its not required always you should bracket the execution portion after your if statement runs. If youd like me to help I'd have to see more of the code. One more thing, it doesnt look like MyPoint has any value. Again, very difficult to say just from one snippet of code bc we need to see the declarations and how the code flows.
Losers Average Losers && Never throw good $ after bad trading.
เป็นสมาชิกตั้งแต่ Oct 23, 2012   349 โพสต์
Aug 05, 2016 at 04:01
extern bool max_spread_filter=true;
extern double max_spread=5.0;

double myPoint, mySpread, myStopLevel,myTickValue,myTickSize,myLotValue;
int myDigits;

init:


SetPoint();

start:


 bool enableopen = true;
   if(max_spread_filter && (Ask-Bid)/myPoint<max_spread) enableopen=false;
 if(enableopen)



function:


void SetPoint()
{

   myPoint = MarketInfo(Symbol(),MODE_POINT);
   mySpread = MarketInfo(Symbol(),MODE_SPREAD);
   myDigits = MarketInfo(Symbol(),MODE_DIGITS);
   myStopLevel = MarketInfo(Symbol(),MODE_STOPLEVEL);
   myTickValue = MarketInfo(Symbol(),MODE_TICKVALUE);
   myTickSize = MarketInfo(Symbol(),MODE_TICKSIZE);
   myLotValue = myTickValue/myTickSize;

   if(
         myDigits==3 ||
         myDigits==5
     )
      {
         myPoint = myPoint * 10;
         mySpread = mySpread / 10;
         myStopLevel = myStopLevel / 10;
         myDigits = myDigits -1;
      }

}
if you follow the flock like sheep you always end up stepping in shit!
forex_trader_25447
เป็นสมาชิกตั้งแต่ Dec 21, 2010   131 โพสต์
Aug 05, 2016 at 04:45
I see some syntax errors .
You probably know some other language , and try to write as You know.
You have to write like this :

double myPoint, mySpread, myStopLevel,myTickValue,myTickSize,myLotValue;
int myDigits;

init()
{
SetPoint();
}

start()
{
 bool enableopen = true;
   if(max_spread_filter && (Ask-Bid)/myPoint<max_spread) enableopen=false;
 if(enableopen) {} // HERE write OPERATOR for this 'if'
}


// function // No such word in MQL
// Everything below is OK.
You must be connected to Myfxbook in order to leave a comment
*การใช้งานเชิงพาณิชย์และสแปมจะไม่ได้รับการยอมรับ และอาจส่งผลให้บัญชีถูกยกเลิก
เคล็ดลับ: การโพสต์รูปภาพ/youtube url จะฝังลงในโพสต์ของคุณโดยอัตโนมัติ!
เคล็ดลับ: พิมพ์เครื่องหมาย @ เพื่อป้อนชื่อผู้ใช้ที่เข้าร่วมการสนทนานี้โดยอัตโนมัติ