Problems with new Expert Advisor in MQL4

 
We need some help from clever people...

We wrote a new expert advisor but...

1. We keep on getting a message "invalid price"

2. We get lots of Error 138 - Requote.

Thanks!
Benna
benwiid at mweb dot co dot za
 

1. When we attach our Expert advisor and run the Strategy Tester, the results does not show on the active chart. We have to click on the "open chart" button in the strategy tester to open the chart that shows the results, and the the "smiley face" is also gone.
What are we doing wrong?

testing works with virtual not active chart. button "open chart" opens this virtual chart with all the arrows. You may doubleclick on some result line and see appropriate arrow

2. We keep on getting a message "invalid price"

learn about forex. open buy and close sell using ask. open sell and close buy using bid +-3 pips for slippage

3. We get lots of Error 138 - Requote.

same as above. bid differs from ask on spread pips. invalid price may differ from right price on spread pips also. but server don't know that You use wittingly invalid price and says "price is changed, buddy, requote" (testing assumes instant execution)
 
About this, I have run many experts in the tester and have a few issues.

Like Benna, in the journal I get "invalid price in OrderSend". However, I have all my buy orders set to buy at Ask and sell orders to sell at Bid, how can I possible be trying to input an invalid price? This issue is strictly in strategy tester and not in demo forward-testing.

I have one other problem also that I will open another thread for.
 
GT,

imho, u really need to post some code if u want help..
 
I'm pretty sure I didn't ask for help and instead was stating that I too had similar problems.
But thank you for your honest opinion, I'm sure it has helped greatly.

What do you want me to post, my OrderSend() function?
These two functions generate "invalid price" errors in the Journal when I run a back test.

OrderSend(Symbol(),OP_BUY,Lots,Ask,0,Ask-30*Point,Ask+60*Point,"Long",MagicNumber,0,Green);
OrderSend(Symbol(),OP_SELL,Lots,Bid,0,Bid+30*Point,Bid-60*Point,"Short",MagicNumber,0,Blue)
 
sorry GT, I was meaning to ask Benna!!

But anyway, in your code : OrderSend is a function which returns an error code which u should test :

int result = OrderSend(.....)

It can happen that the price changes and u specify 0 slippage.

See if that helps!

reagrds,

hugues
 
Thank you. :)
 
sorry GT, I was meaning to ask Benna!!

But anyway, in your code : OrderSend is a function which returns an error code which u should test :

int result = OrderSend(.....)

It can happen that the price changes and u specify 0 slippage.

See if that helps!

reagrds,

hugues


OK - here is the code that determines my Buying Price, and places the order...

if( OrdersTotal() > 0 ) funCloseOrder( OrdersTotal(), LinePrice );//was LastOrder

BuyPrice=Ask+iPipsAbove*Point;

if( dTakeProfit>0 )
BuyTP=BuyPrice+dTakeProfit*Point;
else
BuyTP=0.0000;

if(dStopLoss>0)
BuySL=BuyPrice-dStopLoss*Point;
else
BuySL=0.000;

BuyOrder=OrderSend( Symbol(), OP_BUY, dLots, BuyPrice, iSlippage, BuySL, BuyTP, lObjName, 0, 0, Blue );

The Selling works the same, except for using Bid-....etc
 
Benna,

If iPipsAbove = 0, this works.
If iPipsAbove > MarketInfo(Symbol(),MODE_STOPLEVEL), then u need to use OP_BUYSTOP
- this will place a buy stop order above the current price

If iPispAbove is > 0 and < MarketInfo(Symbol(),MODE_STOPLEVEL), it appears u cannot place an order.. dont ask me why.. I think its just crazy!

i.e.at iPipsAbove = 0 , u are placing a market buy order.. that is fine
if > 0, you want a stop order.. so u have to use the OP_BUYSTOP

regards,

hugues
 
Benna,

If iPipsAbove = 0, this works.
If iPipsAbove > MarketInfo(Symbol(),MODE_STOPLEVEL), then u need to use OP_BUYSTOP
- this will place a buy stop order above the current price

If iPispAbove is > 0 and < MarketInfo(Symbol(),MODE_STOPLEVEL), it appears u cannot place an order.. dont ask me why.. I think its just crazy!

i.e.at iPipsAbove = 0 , u are placing a market buy order.. that is fine
if > 0, you want a stop order.. so u have to use the OP_BUYSTOP

regards,

hugues


Thanks for your time Hugues - will try this one

Benna
Reason: