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- I suggest You always update those variables per tick.
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.
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; ... }
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:
|
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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.
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