Variables TP & SL doesn't work as external ones

 

First of all, I wan't to apologise, if I duplicated any previous subject, but I did not find topics about my problem on that forum.

I wonder why  variables TP & SL doesn't work as external ones whereas declaring them without "external" makes everything work correctly. When TP and SL are external variables, during backtesting only first position is opened correctly, but latter ones are being rejected (in journal appear OrderSendError's 130).  I know, that this lapse should be associated with too low values of SL or TP, but in my program this error comes out regardless of greatness of above mentioned gauges (even with tp=15 pp). Could you please provide me with any information about presumptive reason of that inconvenient phenomenon? Thank you in advance.

 
shirava2k12:

First of all, I wan't to apologise, if I duplicated any previous subject, but I did not find topics about my problem on that forum.

I wonder why  variables TP & SL doesn't work as external ones whereas declaring them without "external" makes everything work correctly. When TP and SL are external variables, during backtesting only first position is opened correctly, but latter ones are being rejected (in journal appear OrderSendError's 130).  I know, that this lapse should be associated with too low values of SL or TP, but in my program this error comes out regardless of greatness of above mentioned gauges (even with tp=15 pp). Could you please provide me with any information about presumptive reason of that inconvenient phenomenon? Thank you in advance.

Do you know what the values of STOP LEVEL and FREEZE LEVEL are ?  does your code comply with the requirements in this article:  Requirements and Limitations in Making Trades
 
shirava2k12: I wonder why  variables TP & SL doesn't work as external ones whereas declaring them without "external" makes everything work correctly. When TP and SL are external variables, during backtesting
  1. Are you modifying them? Say in init for 4/5 digit brokers? externals, common(globally declared), and static's are not reloaded on a deinit/init cycle.
  2. Print out the values before use so you find out why.
  3. There are no mind readers here. show your code.
 

It seems, that there's nothing amiss, when it comes to my broker:

 Digits = 4; freezelevel=0

 Ofcourse, i forgot to attach my code.

Files:
a.mq4  13 kb
 
You are modify them
extern int   SL=10;                              // SL  <= was 10
:
         SL    =OrderStopLoss();                //      <= is now 1.2345 which may be less than StopLevel
         TP    =OrderTakeProfit();              // 

         Ticket=OrderSend(Symb,OP_BUY,Lts,Ask,2,Ask-SL*Point,Ask+TP*Point);   // 
ticket=OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-25*Point,Ask+25*Point,"My order #2",16384,0,Green);