Download MetaTrader 5

MQL4 EA code works with JFD MT4 but not with ICMarkets MT4

To add comments, please log in or register
L0rd
27
L0rd  

Hello,

I tryed today to test my EA with ICMarkets MT4 Demo account, but oldAsk variable which will be settetd on JFD MT4 Demo will be not setted.

I created 4 values stack which will be filled with ticks. In oldAsk I store tick which was 4 ticks before.

For diagnistics I added Print() function. And I see that all other variables will be setted, Ask shows each tick actual values how it must be, but oldAsk is always "0". And it should be filled latest after 4 ticks with values.

input ....
input ....

double oldAsk,oA,oAA,oAAA;

void OnTick(void)
  {
   int total,cnt;
   total=OrdersTotal();
   if(total<1)
   {   
  
Print("Ask = ",Ask," oldAsk = ",oldAsk);     

      //--- check for long position (BUY) possibility

   if(oldAsk > ... )
        {
        //BUY
           
        }
      //--- check for short position (SELL) possibility
    if(......)

        {
         //SELL
        }
      //--- exit from the "no opened orders" block
      return;
     }
     
     oldAsk=oAAA;
     oAAA=oAA;
     oAA=oA;
     oA=Ask;
      

//--- it is important to enter the market correctly, but it is more important to exit it correctly...   
   for(cnt=0;cnt<total;cnt++)
   {
           //Trailing stop
     }

  }

Its everything the same, I just copied source file and ex4 from one Experts folder to another.

I tryed also to compile it new with ICMarkets MT4 but the result is the same.

So I would ask you guys if you have any ideas

Thx

whroeder1
16309
whroeder1  
  1.    total=OrdersTotal();
       if(total<1)
    Using OrdersTotal directly and/or no Magic number filtering on your OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual trading.) Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 forum
  2. I suggest You always update those variables per tick.
L0rd
27
L0rd  

1. I just want to limit overall open orders to "1". I dont use OrderSelect loop.

2. Do I not ?

double oldAsk,oA,oAA,oAAA;

void OnTick(void)
  {
  
Print("Ask = ",Ask," oldAsk = ",oldAsk);     

     
     oldAsk=oAAA;
     oAAA=oAA;
     oAA=oA;
     oA=Ask;
  }

the point to do this with shifting values is to Buy or to Sell by going over predefined price livel, like in SELL STOP or BUY STOP order.

tick values are very tide to each other. For example: I want to buy if price go over 1.00000. Actual tick is 1.00001 and last tick was 1.00000, so ?.... To enshure that price crosses level of f 1.00000, the ticks must be 0.99999 and 1.00001. So I go more back in history of ticks to stratch values a litle bit.

JC
1592
JC  
L0rd:

2. Do I not ?

This doesn't answer your question about why your code is working on one account but not on another, but I would be tempted to collect the tick history as follows, not requiring separate variables, and easily extensible to collect more or fewer ticks:

// Length of history can be increased/decreased here without needing to change other code
double glbTickHistory[4]; 

void OnTick()
{
   // Add current tick to history. Latest, new tick is in glbTickHistory[ctArray - 1].
   // Oldest collected tick (or zero) is in glbTickHistory[0]
   int ctArray = ArraySize(glbTickHistory);
   ArrayCopy(glbTickHistory, glbTickHistory, 0, 1, ctArray - 1);
   glbTickHistory[ctArray - 1] = Ask;

   ...   
}
JC
1592
JC  
JC:

This doesn't answer your question about why your code is working on one account but not on another, but I would be tempted to collect the tick history as follows, not requiring separate variables, and easily extensible to collect more or fewer ticks:

(For the record, the documentation of ArrayCopy says that the result of copying an array onto itself is "undefined". However, just like last time I posted code which did this, such a use of ArrayCopy does seem to be safe, and likely to be so for the reasons set out previously.)
whroeder1
16309
whroeder1  
L0rd:

1. I just want to limit overall open orders to "1". I dont use OrderSelect loop.

2. Do I not ?

  1. You don't have to, but I warned you that you can not have any other trades on any other charts.
  2. You changed the code!
       if(total<1)
       {   
          :
         oldAsk=oAAA;
         oAAA=oAA;
         oAA=oA;
         oA=Ask;
    The original only updated them when there where no open orders.
To add comments, please log in or register