Ask! - page 142

 

Some help please with an EA

I am trying to close a sell order and open a new buy order. The buy opens but the sell gives error 4051

I am using

ticket = OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, Gold);// close position

and

ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue);

 

How to change magic number ?

Hi all,

I use difference EA (copy from one origin EA) to trade difference pairs in difference chart window and I'd like to change the magic number but don't know how is the magic number works ? Could you please tell me:

1. How is the magic number works ?

2. How to change the magic number ?

3. Can I take any number to change the magic number or I MUST use some number in some rules ?

4. Could you give me an example to change magic number at my EA's magic number: 16763 ?

Thank you so much for your help!

 

Magic number is nothing more than a unique identifier. It distinguishes each instance of the same EA while also distinguishing it from any other EA that you may have running.

If the magic number is an external variable just change it to any number you want. Just be sure it's not the same number as any other EA you have running.

If it's not an external variable then look in the code for the variable and change it to any number you want.

Hope that helps.

Lux

 
luxinterior:
Magic number is nothing more than a unique identifier. It distinguishes each instance of the same EA while also distinguishing it from any other EA that you may have running.

If the magic number is an external variable just change it to any number you want. Just be sure it's not the same number as any other EA you have running.

If it's not an external variable then look in the code for the variable and change it to any number you want.

Hope that helps.

Lux

Hi Lux,

You mean I can change my EA's magic number:16763 to 16764 ; 16765 ect... ?

Thank you for your quick reply.

Luu

 
luu:
Hi Lux,

You mean I can change my EA's magic number:16763 to 16764 ; 16765 ect... ?

Thank you for your quick reply.

Luu

Exactly! As long as the number is unique it doesn't matter what number you choose.

You don't really need to change it unless you have a specific reason to.

Lux

 
luxinterior:
Exactly! As long as the number is unique it doesn't matter what number you choose.

You don't really need to change it unless you have a specific reason to.

Lux

Thank you very much for your help Lux !

Luu

 

EA closing order problems

Friends ı have an EA with support resistance indicator.EA must complete orders on target profit.But it lacks sometime.How can ı get rid of this problem.Please help me

 

Please help with simple generic script.

Hi

Can some1 help me please with simple script.

Here is what i need.

Very generic script that can be used on any symbol that will place 3-4 orders for SELL_STOP and BUY_STOP

Let's say i want to place a buy_stop 20 points above current price, second order 40 points above current price, 3d 80 points and so on.

Same thing for Sell_Stop

I kinda was trying to assemble the script based on some examples but since i am not familiar with C language i am having some problems.

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""// improved.mq4

int start()

{

int ticket,i;

int cnt=1;

int Dist_SL =10; // Preset SL (pt)

int Dist_TP =100; // Preset TP (pt)

string Symb=Symbol(); // Symbol

RefreshRates();

double bid =MarketInfo(Symb,MODE_BID);

double ask =MarketInfo(Symb,MODE_ASK);

double point =MarketInfo(Symb,MODE_POINT);

int Min_Dist=MarketInfo(Symb,MODE_STOPLEVEL);

if (Dist_TP < Min_Dist) // If it is less than allowed

{

Dist_TP=Min_Dist; // Set the allowed

Alert(" Increased the distance of TakeP = ",Dist_TP," pt");

}

//-------------------------------------------------------------------- 6 --

Alert("The request was sent to the server. Waiting for reply..");

for(i=100;i<400;i=i+100)

{

double TP=(ask+i*Point) + Dist_TP*Point; // Requested price of TP

ticket=OrderSend(Symb,OP_BUYSTOP,0.1,ask+i*Point,1,(ask+i*Point)-Dist_SL*Point,TP);

Sleep(500);

int Error=GetLastError(); // Failed

switch(Error) // Overcomable errors

{

case 130:Alert("The SL is wrong. Retrying..");

RefreshRates(); // Update data

if (Dist_SL < Min_Dist) // If it is less than allowed

{

Dist_SL=Min_Dist; // Set the allowed

Alert(" Increased the distance of SL = ",Dist_SL," pt");

}

i=i-50;

Alert (i);

Alert (Dist_SL);

cnt=cnt+1;

Alert (cnt);

if (cnt==3)break;

continue; // At the next iteration

case 135:Alert("The price has changed. Retrying..");

RefreshRates(); // Update data

continue; // At the next iteration

case 136:Alert("No prices. Waiting for a new tick..");

while(RefreshRates()==false) // Up to a new tick

Sleep(1); // Cycle delay

continue; // At the next iteration

case 146:Alert("Trading subsystem is busy. Retrying..");

Sleep(500); // Simple solution

RefreshRates(); // Update data

continue; // At the next iteration

}

switch(Error) // Critical errors

{

case 2 : Alert("Common error.");

break; // Exit 'switch'

case 5 : Alert("Outdated version of the client terminal.");

break; // Exit 'switch'

case 64: Alert("The account is blocked.");

break; // Exit 'switch'

case 133:Alert("Trading forbidden");

break; // Exit 'switch'

default: Alert("Occurred error ",Error);// Other alternatives

}

//break;

}

//-------------------------------------------------------------------------- 9 --

Alert ("The script has completed its operations ---------------------------");

return; // Exit start()

}

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

It kinda of works but many times i am having problem with stop loss.

 

Heres my idea if we can switch the snake with the gaussian sr rate inside the

ssrc indicator it may pay dividends what do you think?so instead of it being

the ssrc it would be the one side gaussian sr rate spearmen rank correlation

"osgsrspc" lol .(i tryed to code it but it went over my head)

ssrc_bar.mq4

ssrc.mq4

os_gaussian_sr_rate.mq4

Files:
 

New Question: 5th Decimal and Money Management

In another forum I frequent that is for customers of a particular EA, one customer was complaining about the fact that the EA developer hadn't yet fixed the 5th decimal / fractional pricing issue for their EA.

The developer claimed several months ago that this issue required special scripting to solve. Now, 4 months later, I basically said it was ridiculous that it had not been fixed yet - and claimed that it only required a few lines of code to redefine "Point" similar to the method described here.

So here comes the question. The developer still insists this problem is super complicated and requires special script programming to fix it. Here is the explanation from the developer:

Hi John. You’re right. More and more brokers are going to fractional pips. However, the fractional pips issue is not a bug in [name removed]. It’s an issue with the way the MT4 platform defines the difference in the number of decimal places. We’re reprogramming the EA and the indicators so that they recognize the difference. This is supposed to be contained within the definition of the variable “Point” within the MT4 platform and EAs use this definition to determine the decimal places. However, many MT4 platforms don’t pass more than 4 decimal places on the EA, so special scripting needs to be included. Our challenge is that we use the “Point” variable throughout the EA and all of the indicators. Thus, it’s not as simple as adding a couple of lines of code to redefine “Point.” I’m hoping to have a working fractional pip program by the end of next week.

So my question is this: Have any of you experienced programmers encountered this complicated scripting requirement or issues with the MT4 Platform's value of "Point"?

Even if you assume "Point" is limited to 4 decimals, then that would mean you only have to worry about pairs with Point = 0.001 ----which still only takes a line or two of code.

Or, you could use "Digits" instead of "Point" - which still uses only a few lines of code.

Or you could just use a boolean variable like "UseFractionalPips = true;" to redefine "Point".

I really feel like the developer is either making the problem more complicated than it is (or perhaps other motives). I simply have never read or heard of this issue with "Point" being limited to only 4 decimals - and even if it is you could use "Digits" or other methods to redefine point without some special scripting.

I'm only been programming in MT4 for 18 months, so I thought I would defer to some more experienced programmers as to how complicated the "fix" is for dealing with fractional pip pricing in MT4.

Any thoughts?

Thanks in advance for your help,

-B

Reason: