Error 130 Assistance needed please. - page 2

 
Awsome, thanks for your help. :-)
 

please see below - you must appreciate just why NormalizeDouble() is used and not "* Point"


examples above are not any way shape or form approaching worst case ie, pushing envelope when testing your ideas to 'see' what code produces.

in ideal world their will be only 2 or 4 digits on right of decimal point (as appropriate for symPair) but in real world a double can hold any value and number of digits after decimal point, yes?

how do you 'know' for sure? answer = you do not!

you must always program defensively - even more so when you are dealing with your equity!!!!

that is why you use NormalizeDouble() and also make use of MarketInfo()

cannot take anything for granted - as seen in example alteration of script's inputs - this simple change has broken the code and proved that "* Point" is invalid


Point is only a multiplier - it only moves the decimal point - it does not normalize the fractional part to that number required by symPair - Errors 129,130 will be constant friends

Play with NormalizeDouble() in print statements - see how it (eg,for gbpusd) will not only chop/truncate fractional part to 4 digits but will also increment by 1 the rightmost 4th digit if the 5th digit is >= 5

eg, 1.12345 --> 1.1235

This massively important to understand - is your equity!

example changed script inputs:

2008.04.15 06:18:51 test USDJPY,H1 inputs: StopLoss=0; TakeProfit=20.009164; Lots=1; MagicNumber=0;


test prints output:

2008.04.15 06:18:51 test USDJPY,H1: Symbol()=USDJPY, Ask=101.2, TakeProfit=20.0092 Point=0.01
, Ask + TakeProfit * Point = 101.4001


2008.04.15 06:18:51 test USDJPY,H1: Symbol()=USDJPY, Ask=101.2, TakeProfit=20.0092 Point=0.01
, NormalizeDouble(Ask + TakeProfit * Point,Digits) = 101.4

 

Ok, I understand and also see why that is very important.


Thank you again.


Btw the Print script is VERY useful thanks.


:-)

 

hahaaaa - not really lecturing, just things that I feel strongly about, is good for me too, having to think and research about answer to questions... always shows me just how little know/remember/etc., always gotta ferret around to answer questions, but is good for me too as already mentioned - proverbial WIN - WIN situation I guess

enjoy it all and trust income comes your way too

:o)

 

Hi,

I encounter similar error 130 but I've ensured that my stop loss and take profit is in price form and normalized as advised. I've noticed that this error is not always encountered, i.e. when I run the Strategy Tester, some orders are successful while some will encounter the error 130. Below is the code I've used and the print output of the order when error 130 is encountered.


//code excerpt

stopLoss = NormalizeDouble(Low[iLowest(Symbol(),PERIOD_M5,MODE_LOW,4,1)], MarketInfo(Symbol(),MODE_DIGITS));
Print("open price: ",openPrice, ", stop: ",stopLoss,", profit: ",openPrice+TakeProfit*Point);
ticket=OrderSend(Symbol(),OP_BUYLIMIT,Lots,openPrice,3,stopLoss,openPrice+TakeProfit*Point,"EA Tester",16384,CurTime()+PERIOD_H1*60,Green);


//output of print statement with error 130 encountered.

2009.01.13 11:25:29 2008.09.01 17:16 band EURUSD,M5: open price: 1.4599, stop: 1.4591, profit: 1.4699


Can someone please advise on this?


Thanks.

Reason: