Forex Factory
  • Login

  • Username: Password:
  • 2:47pm

  • Search
  • Home

  • Forums

  • Trades

  • Calendar

  • News

  • Market

  • Brokers

Options

Search
Search
Search

Subscribe to Thread

Bookmark Thread

First Page First Unread Last Page Last Post

Printable Version

Similar Threads

4 Digit & 5 Digit Brokers 7 replies

help with 5 digit broker recode 19 replies

migrating from 4-digit to 5-digit broker. help! 0 replies

5 Digit price in 4 digit broker backtest 0 replies

Detecting 4 digit vs 5 digit broker 2 replies

  • Platform Tech
  • /
  • Reply to Thread
  • 14

Adjusting an EA from 4 digit to 5 digit broker

  • Last Post
  • First Unread
  •  
  • Page 1 2 3
  •  
  • Post# 1
  • Quote
  • First Post: Apr 10, 2009 7:49pm
  • Toothman
    Joined Aug 2006 | 1,241 Posts | Status: Member
I trade an EA on IBFX. I know when going from 4 to 5 digits I need to add a 0 to TP,SL and pip step. My question is if I'm trading .02 lots, do I need to change that to .2? If my slippage is set to 10, should I change that to 100? And finally, when I click on File then Compile, I'm then unable to attach the EA ( with changes ) to the chart. thank you
  • Post# 2
  • Quote
  • Apr 10, 2009 8:10pm
  • luxinterior
    Joined Nov 2006 | 268 Posts | Status: MQL4 Coder
I made a posting on my blog that may be of use to you.

http://www.automatedtradingsoftware....-ibfx-upgrades

In short; no, yes and not sure why that would be - any errors being reported?

Lux
  • Post# 3
  • Quote
  • May 22, 2009 1:04am
  • Dono
    Joined Apr 2009 | 4 Posts | Status: Member
Quoting luxinterior
I made a posting on my blog that may be of use to you.

http://www.automatedtradingsoftware....-ibfx-upgrades

In short; no, yes and not sure why that would be - any errors being reported?

Lux
This could be a bit late to get a reply luxinterior but to get my 4 digit code to work can I just add a 'Zero' to all my pre-sets at the top of the EA's code to catter for the 5th digit.
Example. extern int Slippage = 2; .....change the 2 to 20....and just do the same to T/P, S/L etc.

Or (apart from custom indicators/scripts) are there other factors that need to be addressed that would be covered by your example.

Thanks.
  • Post# 4
  • Quote
  • Jan 6, 2011 9:42am
  • JustJamar
    Joined Mar 2009 | 10 Posts | Status: Member
Is it possible that someone could post the code and/or rules when trying to convert a typical 4 digit EA to a 5 digit EA. I'm having a little trouble with the process and want to get it right.
  • Post# 5
  • Quote
  • Jan 6, 2011 2:31pm | Edited at 2:51pm
  • Aja
    Joined Nov 2009 | 311 Posts | Status: Member
Super Easy. Put this at the top of your code - right after start() - (I usually make xecn a global variable so I can use it anywhere. Also ECN were the first to have 5 digits so thats where the name came from)

xecn=1; if(Digits==5||Digits==3){xecn=10;}

Now just anywhere in the code where you see:

...*Point change to *Point*xecn - and all will be handled automatically.
  • Post# 6
  • Quote
  • Jan 6, 2011 2:47pm
  • JustJamar
    Joined Mar 2009 | 10 Posts | Status: Member
Thanks Aja,

I'm gonna try it out in a few. I'll let you know how I fair.

Quoting Aja
Super Easy. Put this at the top of your code (I usually make xecn a global variable so I can use it anywhere. Also ECN were the first to have 5 digits so thats where the name came from)

xecn=1; if(Digits==5||Digits==3){xecn=10;}

Now just anywhere in the code where you see:

...*Point change to *Point*xecn - and all will be handled automatically.
  • Post# 7
  • Quote
  • Jan 6, 2011 3:11pm
  • JustJamar
    Joined Mar 2009 | 10 Posts | Status: Member
Hey Aja,

I just tried what you suggested, to no avail though. I'm trying to get the EA to run on FXDDs Metatreder4. Here the error I got when trying to complile:

"'xecn' - expression on global scope not allowed"

&

"'xecn' - variable not defined"

I'm assuming that it's something I'm doing wrong. I know nothing about this stuff and sorry for seeming so dumb when it comes to it. LOL I just saved it after changing all the *Points to *Point*xecn as you mentioned. I've included an attachment of the script that I'm trying to get to work if you want to refer to it.

I’ve been able to add the EA to my indicator to my expert advisers as I would any other but for one reason or another it fails to load and operate. After trying to add the the EA to my chart or trade by double clicking it I get no response so I’m assuming that there is something slight in the EA that’s not allowing it to function.

Any other suggesting or can you tell me what I'm doing wrong?


Quoting Aja
Super Easy. Put this at the top of your code - right after start() - (I usually make xecn a global variable so I can use it anywhere. Also ECN were the first to have 5 digits so thats where the name came from)

xecn=1; if(Digits==5||Digits==3){xecn=10;}

Now just anywhere in the code where you see:

...*Point change to *Point*xecn - and all will be handled automatically.
  • Post# 8
  • Quote
  • Jan 6, 2011 3:16pm
  • JustJamar
    Joined Mar 2009 | 10 Posts | Status: Member
Sorry I forgot to add the attachment. It's with this post.

Quoting JustJamar
Hey Aja,

I just tried what you suggested, to no avail though....
Attached File
File Type: mq4 PowerSM.mq4   8 KB | 251 downloads
  • Post# 9
  • Quote
  • Jan 6, 2011 5:02pm | Edited at 5:44pm
  • Aja
    Joined Nov 2009 | 311 Posts | Status: Member
You didnt define the variable type - just put 'double' in front of it. (I usually define as a global but locals work just as good)

double xecn=1; if(Digits==5||Digits==3){xecn=10;}

Also scanned your code and wherever ... /Point also change to /Point/xecn.... (in code i saw /Point/10 = /Point/xecn/10)
  • Post# 10
  • Quote
  • Jan 6, 2011 6:24pm
  • JustJamar
    Joined Mar 2009 | 10 Posts | Status: Member
Aja,

I can't thank you enough for getting me thus far and I did get rid of some of the errors after modifying those other 'Point' entries.

I apologize for being totally ignorant to the things you are pointing out but I'm still having one error when attempting compile. You can see it here:

'{' - expression on global scope not allowed C/documents and Settings4592DesktopPowerSM2.mq4 (43, 1)

So apparently there's one other thing I'm doing wrong. Please help me out if you still have the patience to do so.

Again I've attached the EA. This time I didn't attach it in it's raw form but with the provisions you directed me to input. This way you can see exactly where I have anything.

Thanks again!



Quoting Aja
You didnt define the variable type - just put 'double' in front of it. (I usually define as a global but locals work just as good)

double xecn=1; if(Digits==5||Digits==3){xecn=10;}

Also scanned your code and wherever ... /Point also change to /Point/xecn.... (in code i saw /Point/10 = /Point/xecn/10)
Attached File
File Type: mq4 PowerSM2.mq4   8 KB | 110 downloads
  • Post# 11
  • Quote
  • Jan 6, 2011 6:32pm
  • Aja
    Joined Nov 2009 | 311 Posts | Status: Member
int init();double xecn=1; if(Digits==5||Digits==3){xecn=10;} - ERROR

move the line and place after the start() like this..

void start() { double xecn=1; if(Digits==5||Digits==3){xecn=10;}

In the error example you put it in the init() AND placed it before the '{'
  • Post# 12
  • Quote
  • Jan 6, 2011 7:18pm
  • JustJamar
    Joined Mar 2009 | 10 Posts | Status: Member
Aja,

I did as you said once again. Changed lines and making sure it appears like so :void start() { double xecn=1; if(Digits==5||Digits==3){xecn=10;}.

I'm now getting the error that the variable can't be defined 16 times. I'm assuming that each time it comes up it's in reference to the appearance of Point in the code (I am learning, slowly but I didn't know that prior to this).

Again I've included a copy for your reference with the movement I made. Thanks again and wish I knew some info I could share with you to make up for all you're informing me with.

Quoting Aja
int init();double xecn=1; if(Digits==5||Digits==3){xecn=10;} - ERROR

move the line and place after the start() like this..

void start() { double xecn=1; if(Digits==5||Digits==3){xecn=10;}

In the error example you put it in the init() AND placed it before the '{'
Attached File
File Type: mq4 PowerSM2.mq4   8 KB | 102 downloads
  • Post# 13
  • Quote
  • Jan 7, 2011 9:34am
  • Aja
    Joined Nov 2009 | 311 Posts | Status: Member
Here ya go. The variable needed to be defined as a global (meaning the entire program can access the variable not just routines in the start() function) - It now compiles without error.
Attached File
File Type: mq4 PowerSM2.mq4   8 KB | 363 downloads
  • Post# 14
  • Quote
  • Jan 11, 2011 12:05pm
  • JustJamar
    Joined Mar 2009 | 10 Posts | Status: Member
Aja,

I didn't get a chance to offer you a thanks for guiding me through the process and showing me exactly how to get to the result I was in search for.

Thanks a million and you are absolutely the best. I'll keep you updated with how the EA goes for me via this thread.

Quoting Aja
Here ya go. The variable needed to be defined as a global (meaning the entire program can access the variable not just routines in the start() function) - It now compiles without error.
  • Post# 15
  • Quote
  • Jan 11, 2011 4:39pm
  • Aja
    Joined Nov 2009 | 311 Posts | Status: Member
Sounds good.
  • Post# 16
  • Quote
  • Jan 19, 2011 3:12am
  • cai
    Joined Jun 2010 | 1 Post | Status: Junior Member
I have the same problem with this EA. Can you please help me to?


PHP Code:
extern double GapRange = 10;
extern double SL_Factor = 2;
extern double TP_Factor = 3;
extern double MM_Risk = 2;
extern int ExpertID=844478;
 
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
 
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
 
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//---- ONE TRADE PER BAR
 
static bool ToTrade;
 
if(
NewBar() == true)
{
if(
COT(1, 101187) == 0 && COT(2, 201187) == 0) ToTrade = true;
}
 
//---- GAP
 
bool GAP;
 
double CurrOpen = iOpen(NULL, 0, 0);
double PrevClose = iClose(NULL, 0, 1);
double Range = MathAbs(PrevClose - CurrOpen);
 
if(
Range >= GapRange * Point * 10) GAP = true;
 
//---- TP / SL
 
double ATR = iATR(NULL, 0, 13, 1);
double Spread = MarketInfo(Symbol(), MODE_SPREAD) * Point;
 
double TakeProfit = ATR * TP_Factor;
double StopLoss = (ATR * SL_Factor) + Spread;
 
//---- TRADE
 
int Ticket;
 
if(
ToTrade == true && GAP == true)
{
if(
CurrOpen < PrevClose)
{
Ticket = OrderSend(Symbol(), OP_BUY, LotSize(MM_Risk, StopLoss), Ask, 3, Ask - StopLoss, Ask + TakeProfit, "Gap_Trader.B", 101187, 0, Blue);
 
if(
Ticket < 0)
{
Print(
"Error in OrderSend : ", GetLastError());
}
else
{
ToTrade = false;
}
}
 
if(
CurrOpen > PrevClose)
{
Ticket = OrderSend(Symbol(), OP_SELL, LotSize(MM_Risk, StopLoss), Bid, 3, Bid + StopLoss, Bid - TakeProfit, "Gap_Trader.S", 201187, 0, Red);
 
if(
Ticket < 0)
{
Print(
"Error in OrderSend : ", GetLastError());
}
else
{
ToTrade = false;
}
}
}
 
//----
return(0);
}
//+------------------------------------------------------------------+
//+ Check Open Trades |
//+------------------------------------------------------------------+
int COT(int BS, int MN)
{
int Buys = 0, Sells = 0;
 
for(
int cnt_COT = 0; cnt_COT < OrdersTotal(); cnt_COT++)
{
OrderSelect(cnt_COT, SELECT_BY_POS, MODE_TRADES);
 
if(
OrderSymbol() == Symbol() && OrderMagicNumber() == MN && OrderType() == OP_BUY) Buys++;
if(
OrderSymbol() == Symbol() && OrderMagicNumber() == MN && OrderType() == OP_SELL) Sells++;
}
 
if(
BS == 1) return(Buys);
if(
BS == 2) return(Sells);
}
//+------------------------------------------------------------------+
//| LotSize |
//+------------------------------------------------------------------+
double LotSize(double Risk, double SL)
{
double MaxLot = MarketInfo(Symbol(), MODE_MAXLOT);
double MinLot = MarketInfo(Symbol(), MODE_MINLOT);
 
double StopLoss = SL / Point / 10;
double Size = Risk / 100 * AccountBalance() / 10 / StopLoss;
 
if(
Size < MinLot) Size = MinLot;
if(
Size > MaxLot) Size = MaxLot;
 
return(
NormalizeDouble(Size, 2));
}
//+------------------------------------------------------------------+
//| New Bar |
//+------------------------------------------------------------------+
bool NewBar()
{
static 
datetime PrevBar;
 
if(
PrevBar < Time[0])
{
PrevBar = Time[0];
return(
true);
}
else
{
return(
false);
}
} 
  • Post# 17
  • Quote
  • Jun 24, 2011 11:10pm
  • dtruong4 ● Online
    Joined Oct 2010 | 2 Posts | Status: Junior Member
Hey Aja-

I need help with a code as well. I'm not quite sure where to stick the line of code {double xecn=1; if(Digits==5||Digits==3){xecn=10;} so that my EA can work. Can you help? thanks.
Attached File
File Type: mq4 PSAR and 3SMA.mq4   9 KB | 56 downloads
  • Post# 18
  • Quote
  • Jun 25, 2011 6:14am
  • ido370
    Joined Mar 2010 | 458 Posts | Status: Member
Quoting dtruong4
Hey Aja-

I need help with a code as well. I'm not quite sure where to stick the line of code {double xecn=1; if(Digits==5||Digits==3){xecn=10;} so that my EA can work. Can you help? thanks.
Done
Attached File
File Type: mq4 PSAR and 3SMA.mq4   9 KB | 111 downloads
  • Post# 19
  • Quote
  • Jun 25, 2011 6:19am
  • ido370
    Joined Mar 2010 | 458 Posts | Status: Member
[quote=cai;4325256]I have the same problem with this EA. Can you please help me to?

try this:
Attached File
File Type: mq4 ea.mq4   4 KB | 84 downloads
  • Post# 20
  • Quote
  • Jun 25, 2011 2:27pm
  • dtruong4 ● Online
    Joined Oct 2010 | 2 Posts | Status: Junior Member
Quoting ido370
Done
Attachment 728519

thanks for your help. when a add a stop loss, whether it's 1 or 50, I get error message OrderSend error 130. Not sure why though. If I add a take profit and the code works just fine. Please help
Thread Tools Search this Thread
Show Printable Version Show Printable Version
Email This Thread Email This Thread
Search this Thread:

Advanced Search

  • Platform Tech
  • /
  • Adjusting an EA from 4 digit to 5 digit broker
  • Reply to Thread
    • Page 1 2 3
0 traders viewing now
  • More

©2013 Forex Factory, Inc. / Terms of Use / Privacy Policy

Forex Factory® is a registered trademark.

Connect

  • Facebook
  • Twitter
  • RSS

Company

  • About FF
  • FF Blog
  • Careers at FF
  • Advertising
  • Contact FF

Products

  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer

Website

  • Homepage
  • Search
  • User Guide
  • Member List
  • Online Now
  • Report a Bug