MQL4 - automated forex trading   /  

Forum

Lot Size

Back to topics list To post a new topic, please log in or register

avatar
222
Alberto_jazz 2008.07.01 16:04 

Hi, I’m trying to write the lot size as a function of the traded symbol, but I have an error, could you help me? Thank you!

int Lots;

if (Symbol() == EURUSD) {Lots = 0.04;}

else if (Symbol() == GBPUSD) {Lots = 0.02;}

else if (Symbol() == AUDUSD) {Lots = 0.06;}

else if (Symbol() == EURGBP) {Lots = 0.03;}

else if (Symbol() == EURJPY) {Lots = 0.03;}

else if (Symbol() == USDCHF) {Lots = 0.03;}

else if (Symbol() == USDJPY) {Lots = 0.04;}

else if (Symbol() == EURCHF) {Lots = 0.03;}

else if (Symbol() == USDCAD) {Lots = 0.05;}

article

Interview with Lingyu Jiang (jianglingyu)

My Expert Advisor tries to catch the main trend of a day. It's based on the famous catfx50 strategy. Sometimes it will use Moving Average cross as the signal. The main indicator is StepMA. It will take 0, 1 or 2 trades a day normally, and has a StopLoss as small as 18 pips. If it wins, it makes 20-100 pips. The theory behind this expert is: "Many a pickle makes a muckle".


avatar
1235
BarrowBoy 2008.07.01 17:02 

AJ

What error?

This code will not work on a mini account - only a micro...

Have your EA check http://docs.mql4.com/constants/marketinfo for MODE_MINLOT?

-BB-


avatar
222
Alberto_jazz 2008.07.01 17:07 

Yes I'm working on a micro account, this is the error

'EURUSD' - expression on global scope not allowed C:\Programmi\MetaTrader - Alpari UK\experts\Inside Bar Lots.mq4 (17, 17)


avatar
873
puncher 2008.07.01 17:13 

You have an error, because you can not trade with value less that 0.1. You have listed :


if (Symbol() == EURUSD) {Lots = 0.04;}

else if (Symbol() == GBPUSD) {Lots = 0.02;}

else if (Symbol() == AUDUSD) {Lots = 0.06;}

else if (Symbol() == EURGBP) {Lots = 0.03;}

else if (Symbol() == EURJPY) {Lots = 0.03;}

else if (Symbol() == USDCHF) {Lots = 0.03;}

else if (Symbol() == USDJPY) {Lots = 0.04;}

else if (Symbol() == EURCHF) {Lots = 0.03;}

else if (Symbol() == USDCAD) {Lots = 0.05;}


You should change it into:


if (Symbol() == EURUSD) {Lots = 0.4;}

else if (Symbol() == GBPUSD) {Lots = 0.2;}

else if (Symbol() == AUDUSD) {Lots = 0.6;}

else if (Symbol() == EURGBP) {Lots = 0.3;}

else if (Symbol() == EURJPY) {Lots = 0.3;}

else if (Symbol() == USDCHF) {Lots = 0.3;}

else if (Symbol() == USDJPY) {Lots = 0.4;}

else if (Symbol() == EURCHF) {Lots = 0.3;}

else if (Symbol() == USDCAD) {Lots = 0.5;}


I think so...


avatar
222
Alberto_jazz 2008.07.01 17:24 
I'm working on a micro account, in fact if I set the Lots as an external variable, Lots = 0.01 the expert works without problem.

avatar
222
Alberto_jazz 2008.07.01 18:25 

Solved.

The problem is that I wrote this statement BEFORE int start()!

Now it works.

Thank you

Back to topics list  

To add comments, please log in or register