How to code? - page 273

 

takeprofit not executed

There are two possible reasons.

First the takeprofit might be considered too close to the open price for the broker to accept.

Check the trade to see if the takeprofit has a value.

Second Sell trades exit at the Ask so the Ask must reach the takeprofit level.

What is the spread for your broker for that pair and at that time?

That would cause the actual exit to be at Bid - Spread.

Robert

 
LuisAY:

I 'd like to know how to read these circled in light blue,

any code sample to point me in the right direction ?

Thanks in advance.

The Indicator name is not a comment.

Since the name is visible you can use

double MaxValue, MinValue;

int WindowNum = WindowFind("Volume"); // returns -1 if not found

if (WindowNum >= 0)

{

MaxValue = WindowPriceMax(WindowNum);

MinValue = WindowPriceMin(WindowNum);

}

Hope this helps.

BTW, When you open the MT4 editor there is a window called Navigator that lists the functions in MT4 with decriptions and samples of how to use them.

Robert Hill

Professional MT4 Programmer

 

[langtitle=de]takeprofit not executed[/langtitle]

MrPip:
There are two possible reasons.

First the takeprofit might be considered too close to the open price for the broker to accept.

Check the trade to see if the takeprofit has a value.

Second Sell trades exit at the Ask so the Ask must reach the takeprofit level.

What is the spread for your broker for that pair and at that time?

That would cause the actual exit to be at Bid - Spread.

Robert

[lang=de]Thanks for you fast reply.

I have an ECN Broker (FXOpen) (5digits). I think you are right concerning the spread. But it is a constant value of 102 (=(Ask - Bid)*(1/Point)) and does not change all the time while running the strategy tester. Why? On live systems the spread is changing almost permanently. Furthermore why I don't get an OrderSend Error 130?

Thanks for helping.[/lang]

 
MrPip:
The Indicator name is not a comment.

Since the name is visible you can use

double MaxValue, MinValue;

int WindowNum = WindowFind("Volume"); // returns -1 if not found

if (WindowNum >= 0)

{

MaxValue = WindowPriceMax(WindowNum);

MinValue = WindowPriceMin(WindowNum);

}

Hope this helps.

BTW, When you open the MT4 editor there is a window called Navigator that lists the functions in MT4 with decriptions and samples of how to use them.

Robert Hill

Professional MT4 Programmer

this isexactlywhat I've been looking for, ..just hopped that the technical writters of the help file had the common sense you show in the example.

The other question I have is: the comment or note that serves as name in the custom indicator is named "IndicatorShortName" and holds a value, now, I would like to read this value. I could find a way around it by making a variable to also hold this value when I declare it, but is common sense to me that there has to be a way to use tha value of "IndicatorShortName".

Thanks

 

haha , found it -- the coding I've done (but I do not use it these day)

it should not give a SUGGESTION ENTRY , until there is some consolidation observed (so it is kind of smart -- simple logic used though)

rephrase your questions -- not clear

tiny.cc/imtran

====

this is a dig, to show that I do some coding

I spent 1 month on this indicator (I build myself)

what it does, is use the white comment text

to tell me what price level to place a Limit order

let you have these 3 links, if you like to read stuff, open the METAEDITOR IDE and learn mq4 coding -- should use some better indicator sample -- it is like

define color and thickness

draw some stuff on the chart

count the number of candles

run a arithemtic (so hard) formula

do more calculation and ifthenelse

most indicator MQ4 are in this format , so pay attention to >> draw some stuff on the chart

---- it could be a bit implicit, or autorun for some final drawing, but mq4 are like this way ---

http://tiny.cc/linsay3

http://tiny.cc/linsay2

http://tiny.cc/linsay1

I don't give away my DEVELOPMENT STUFF easily

- this may not be helpful in trading (but I learn a lot about MQ4, the compiler is not that harsh)

there is a member called WID - not sure how good he is -- coding , if he is good and stick to confidentiality agreement, I think I would give the whole indicator to him (good thing to play around though)

===

Actually, I got one point here

COMMENT -- no other MQ4 function is easier than this one

very similar to PRINT ("oooh, forex bluffer, good time to enter at price" ; perfectpriceVariable);

i.e. it can be use as a TEXT advisor, trigger, showing any variable value etc

Just add it to your favorite indicator, then you can make it appear and disappear and give you the TRIGGER

-- comparison with few hours ago etc === all these coding are CHILDPLAY

However, if you got your favorite indicator, you have to understand that favorite indicator INSIDE -OUT first

e.g. what SIGN that you are after, how variable will change

BEFORE your can add a line of comment (.... ....) [ I got an example here in the ScreenCap]

Just wish that more people like coding, rather than whining -- by writing this

==== let us assume "IndicatorShortName" is really a variable in MQ4

you could put it somewhere comment ("\n", " this variable approx value in this candle bar is ", IndicatorShortName);

having said that, you have to search "IndicatorShortName" in the whole MQ4 indicator to see what is this !! is it a variable or does it really appear in the indicator or it is an external call -- external call could be tough, people write something like that to make it look like OOP

 
coollex:
[lang=de]Thanks for you fast reply.

I have an ECN Broker (FXOpen) (5digits). I think you are right concerning the spread. But it is a constant value of 102 (=(Ask - Bid)*(1/Point)) and does not change all the time while running the strategy tester. Why? On live systems the spread is changing almost permanently. Furthermore why I don't get an OrderSend Error 130?

Thanks for helping.[/lang]

That just means that reason one is not the problem.

So with reason 2 the TP is 1.44743 and spread is 102 points. That means the Bid would need to be 1.44641 when the Ask reaches TP to exit the trade. From your chart picture it looks like that did not happen.

Remember that bars on the chart are created from the Bid.

Robert

 

iCustom, indicator and EA to open orders

Hello everyone,

i am new to mql programming.

i have a function in indi which determines power of all currencies. what i want to do is open order for profitable pairs. for that i have 'for' loop which determines max powerful currency and then another 'for' loop which determines weakest currency.

i am stuck as what to do in indi which can later be used in EA to open orders of profitable pairs..

please check function code below....

allcurr = all the currencies

cpow = currency power

void pro (int allcurr, double cpow)

{

for (allcurr=0; allcurr<CurrencyCount; allcurr++)

{

if (cpow > 150 || cpow >160)

{

for (allcurr=0; allcurr<CurrencyCount; allcurr++)

{

if (cpow > 40 || cpow > 0)

{

I AM STUCK HERE

} // end for weak if

} // end for weak

} // end for max if

} // end for max

} // end void pro
 

iCustom, indicator and EA to open orders

Hello everyone,

i am new to mql programming.

i have a function in indi which determines power of all currencies. what i want to do is open order for profitable pairs. for that i have 'for' loop which determines max powerfull currency and then another 'for' loop which determines weakest currency.

i am stuck as what to do in indi which can later be used in EA to open orders of profitable pairs..

please check function code below....

allcurr = all currencies

cpow = power of a currency

void pro (int allcurr, double cpow)

{

for (allcurr=0; allcurr<CurrencyRepeat; allcurr++)

{

if (cpow > 150 || cpow >160)

{

for (allcurr=0; allcurr<CurrencyRepeat; allcurr++)

{

if (cpow > 40 || cpow > 0)

{

I AM STUCK HERE

} // end for weak if

} // end for weak

} // end for max if

} // end for max

} // end void pro
 

OrderComment change?

hello,

Is there any way to change the OrderComment, after the order has being created?

I have an EA that creates pending orders in key points that are likely to be reached, however sometimes those orders have to be cancelled/deleted due to undesirable fast movements on the charts, therefore it is no possible to use the ticket number to identify each order, because each key point order can be open and cancelled/deleted several times, so instead the EA uses a unique OrderComment to identify each order, but every once in a while the computer that runs the EA fails or the internet connection fails, and that messes up the key point order identification and therefore it would become useful to change the OrderComment to avoid errors caused by the mess that is created after the EA restarts without first finishing the previous execution.

Very confusing, right?

P.S. the magic number is being used to identify the orders created by the EA, so I cannot used that number to identify each order individually.

If anyone could tell me if there is any way to change the OrderComments I would appreciate,

Thank you in advance.

 

I dont know if I understoond You good, but in the moment when you "stack" do something with buffer of indicator - You must think out what value You want to have in this buffer/buffers.

second, look in this piece of code:

if (cpow > 150 || cpow >160)

if (cpow > 40 || cpow > 0)

[/CODE]

this same effect will be when You change it for:

[CODE]

if (cpow > 150)

if (cpow > 0)

edit: I dont know what effect You want but try use Arrays - probably will be needed.

Big regards

Polish student of computer since with big experience in MQL can code for You.

quote via mail: gaa1(at)poczta(dot)fm

Cheap, good, fast && and professional.

Reason: