Before posting please read some of the other threads . . . then you would have seen numerous requests like this one:
Please use this to post code . . . it makes it easier to read.Hi All,
I am new to mql language and took an attempt to create my own EA based on various pdf and forum here. I have managed to built an EA that works in strategy tester but when I put it to work as EA then it does not open any trades. When I then test the same day in strategy tester - trades are open.
I have a smiley face in top right corner - i.e. trades have been enabled. Here is an extract of the code that I am using.
It is supposed to open a trade once a close of previous bar is higher or lower than max/min of last 10 bars (variables HighestSince and LowestSince). Values for StopLoss and TakeProfit will be variable in the final code but i put is like that for simplicity.
WHERE IS THE BUG?
OrderSend(Symbol(),OP_SELL,0.01,Bid,5,StopLoss,TakeProfit,"TEST",NULL,NULL,Blue);
What is for you the value "NULL" ??
Do you think it is the same as 0
If so.... Then what is the value of your NULL inside this
iHigh(NULL,0,iHighest(NULL,0,2,HighestSince,3)))This is not the only issue there can be..... Read the links RaptorUK is given you
What is for you the value "NULL" ??
Do you think it is the same as 0
If so.... Then what is the value of your NULL inside this
This is not the only issue there can be..... Read the links RaptorUK is given youI have filled in the NULLs as per mql help
so in
iHigh(NULL,0,iHighest(NULL,0,2,HighestSince,3)))
the first NULL (bold above) is to mean that current symbol should work, i.e. not for a specific currency pair
the second NULL (bold italic above) is meant to do the same, i.e. current symbol
I understand that iHighest gives me the position of the bar and by using the combination of iHigh and iHighest I can get the actual highest value which is then used as trigger
for the ordersend() you are right - it should be rather 0 than NULL
Thanks deVries!
OrderSend(Symbol(),OP_SELL,0.01,Bid,5,StopLoss,TakeProfit,"TEST",NULL,NULL,Blue);
- Use SRC
- Bad arguments
- What are Function return values ? How do I use them ? - MQL4 forum
- Not adjusting for 4/5 digit brokers TP,SL, AND slippage. 5 = 1/2 pip
- Not adjusting for ECN brokers

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi All,
I am new to mql language and took an attempt to create my own EA based on various pdf and forum here. I have managed to built an EA that works in strategy tester but when I put it to work as EA then it does not open any trades. When I then test the same day in strategy tester - trades are open.
I have a smiley face in top right corner - i.e. trades have been enabled. Here is an extract of the code that I am using.
It is supposed to open a trade once a close of previous bar is higher or lower than max/min of last 10 bars (variables HighestSince and LowestSince). Values for StopLoss and TakeProfit will be variable in the final code but i put is like that for simplicity.
int start()
{
if(Bars !=ThisBarTrade)
{
ThisBarTrade = Bars;
if(Close[1]>=iHigh(NULL,0,iHighest(NULL,0,2,HighestSince,3)))
{
StopLoss=Bid+0.0090;
TakeProfit=Ask-0.0095;
OrderSend(Symbol(),OP_SELL,0.01,Bid,5,StopLoss,TakeProfit,"TEST",NULL,NULL,Blue);
}
if(Close[1]<=iLow(NULL,0,iLowest(NULL,0,1,LowestSince,3)))
{
StopLoss=Bid-0.0090;
TakeProfit=Ask+0.0090;
OrderSend(Symbol(),OP_BUY,0.01,Ask,5,StopLoss,TakeProfit,"TEST",NULL,NULL,Blue);
}
}
return(0);
}
WHERE IS THE BUG?