How to code? - page 217

 

trouble with 5 digit

Hi team,

Short and sweet... I have an ea that used to work fine but now my broker is 5 digit and I get consistent 130 errors. Tried using the Digits, tried rounding to four or five places, no luck. Is it a simple fix? I don't want to waste your time trawling through my code (it's no secret) so I'm hoping it's mickey mouse. If you need to see the code say the word, but the ea itself used to run fine until i got the new ECN dealer, now its no good... anybody been through this before?

Love you work,

Couso

 
Couso:
Hi team,

Short and sweet... I have an ea that used to work fine but now my broker is 5 digit and I get consistent 130 errors. Tried using the Digits, tried rounding to four or five places, no luck. Is it a simple fix? I don't want to waste your time trawling through my code (it's no secret) so I'm hoping it's mickey mouse. If you need to see the code say the word, but the ea itself used to run fine until i got the new ECN dealer, now its no good... anybody been through this before?

Love you work,

Couso

You need to multiply the level values for 5 digit brokers. Eg check if Digits = 3 or 5 then it means that your broker is 5 digits, in this case you need to multiply takeprofit/stoploss etc by 10. So if you put 10 stop loss ea has to multiply it and set 100 as stop loss. Usualy i do this (check and set) in the init function like this:

if (Digits = 3 || Digits = 5)

StopLoss = StopLoss*10;

 

Just put TP/SL:

ticket=OrderSend(Symbol(),OP_SELL,Lot,Bid,Slippage,0,0,""+Symbol(),MagicNumber,0,Green);

 

No SL or TP used for ECN orders?

Couso:
Hi team,

Short and sweet... I have an ea that used to work fine but now my broker is 5 digit and I get consistent 130 errors. but the ea itself used to

---

...run fine until i got the new ECN dealer, now its no good... anybody been through this before?

Couso

Hi Couso,

I''ve been working on the same Error 130 problem with running my EA's on my ECN's...

My EA's work fine on FXDD (non-ECN) and then I tried using them on FXCBS and PFG...both ECN's.

After many hours and hours...and hours...of playing with and changing the code to deal with the 5 digits...nothing worked on FXCBS ECN.

Earlier I read somewhere that Megadroid had to tweak their code to deal with this problem, and they had to send the order without the SL and TP.

So I tried SL=0 and TP=0 for the trade entry. It worked every time and my EA's started trading on my FXCBS ECN demo account!

It appears that these ECN's don't allow SL and TP to be placed at the time the trade order is placed...?

I'm just a novice coder so this may not be the actual reasons, but it seems to have solved my Error 130 order problems with FXCBS ECN.

Hope this helps,

Robert

 

Here is the tip for ECN brokers:

It is advised to change the following line :

OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-25*Point,Ask+25*Point,"My order

#2",16384,0,Green);

With :

ticket=OrderSend(Symbol(),OP_BUY,1,Ask,0,0,0,"My order #2",16384,0,Green);

if(ticket>0)

{

OrderSelect(ticket,SELECT_BY_TICKET);

OrderModify(OrderTicket(),OrderOpenPrice(),STOPLOSS,TAKEPROFIT,0,Green);

}

else

{

Print("OrderSend failed with error #",GetLastError());

}

 
t4fast:
Hi guys,

can someone code this simple idea ..

if candle closes above a moving average ... give one alert ... untilcandle closes below the same moving average .. and also .. give one alert

should i post somewhere else

 
 

Convert Symbol() to Int

Hello, just wondering what the proper syntax code is for taking the chart Symbol() and converting it into an Int number?

What I want to do is create an AutoMagic number in my EA depending on what chart Symbol() I attach the EA to.

Thank you

 
matrixebiz:
Hello, just wondering what the proper syntax code is for taking the chart Symbol() and converting it into an Int number?

What I want to do is create an AutoMagic number in my EA depending on what chart Symbol() I attach the EA to.

Thank you

Just ask David Copperfield, he is expert on magic numbers.

https://en.wikipedia.org/wiki/David_Copperfield)

Reason: