Ask! - page 171

 

Hi,

I', trying to make an EA but have some problems with the code. The EA seems to work but there is one error.

"invalid ticket for OrderDelete function"

How to solve this?

here is the part of the code:

{

int OrderCnt;

for(OrderCnt=0;OrderCnt<total;OrderCnt++)

if(Bid>iBuyPrice){closing = true; OrderDelete(OrderTicket());return(0);}

if(Ask<iSellPrice){closing = true; OrderDelete(OrderTicket());return(0);}

{

OrderSelect(OrderCnt,SELECT_BY_POS,MODE_TRADES);

if(OrderSymbol()==Symbol() && OrderMagicNumber()== magicnumber && OrderType()== OP_BUYSTOP) OrderDelete(OrderTicket());

else if(OrderSymbol()==Symbol() && OrderMagicNumber() == magicnumber && OrderType() == OP_SELLSTOP) OrderDelete(OrderTicket());

else if(OrderSymbol()==Symbol() && OrderMagicNumber() == magicnumber && OrderType() ==OP_SELLLIMIT) OrderDelete(OrderTicket());

else if(OrderSymbol()==Symbol() && OrderMagicNumber() == magicnumber && OrderType() ==OP_BUYLIMIT) OrderDelete(OrderTicket());

}

if(!ContinueTrading) Enter=false;

}

return(0);

 

MA Cross with Scalping & Hedging

case closed...

 

Subtraction question on EA coding

I know if I wanted to say 80 pips I would code as 80 * Point.

But if I want to code the resulting pips from subtracting 2 currency values do I code A=1.4290-1.4210 / Point? to get 80 as the value of A?

Your help is greatly appreciated.

Dave

 

don't forget the "()"

it has to be "(1.4290-1.4210 )/ Point"

 

ICustom Parameters

I've got two questions about ICustom.

First, if you do not include all parameters of the indicator in the ICustom call, am I correct in assuming that the missing parameters are set by the defaults in the indicator?

The other question is if a parameter is supplied that is the wrong type, is any error message thrown that can be identified in stdlib?

Thanks in advance for the response

 

If you leave out parameters then yes the defaults will be used. Be careful though as the parameters you do wish to use need to be in exactly the same order as they appear in the indicator.

I can't recall if errors are thrown if you try to pass the wrong type but i'm sure you can test it very easily.

Good luck

Lux

 

How to do this

open trade, if trade loses, add 15 trailing stop, leave trade open and open a new trade (EA only has 1 trade open at any one time) so EA is now operating with new trade only

 

Script to add lots to open orders in profit

Hi codersguru,

I've just been reading your MT4 course and have attempted to put together a script that

adds lots to open orders that are in profit.

Also a big thankyou for for the tutorial, it is well written and quite humerous....

Heres the code:

#property show_inputs

#include

//+------------------------------------------------------------------+

//| script program start function |

//+------------------------------------------------------------------+

int start()

{

int total,cnt,err;

total = OrdersTotal();

for(cnt=0;cnt<total;cnt++)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderProfit() >= 15) // profit is greater than 15 pips

if(OrderType()==OP_BUY)

OrderSend(OrderSymbol(),OP_BUY, 0.1, MarketInfo(OrderSymbol(),MODE_ASK), 2, NULL, NULL, NULL, NULL, NULL, CLR_NONE);

else

OrderSend(OrderSymbol(),OP_SELL, 0.1, MarketInfo(OrderSymbol(),MODE_BID), 2, NULL, NULL, NULL, NULL, NULL, CLR_NONE);

err=GetLastError();

Print("error(",err,"): ",ErrorDescription(err));

Sleep(1000);

}

//----

//----

return(0);

}

Is that any good codersguru??

Thanks in advance, appreciate it...

Cheers

Jeff

 

Hi All

Can someone help me. I have been sent a file and I am told I have to ' decompile' it in metatrader window first then load the indicators on chart! What is compile and decompile exactly? How do I do this, also is there a pdf with step by step instructions on how to navigate around things such as loading EAs etc and other such things for mt4. I'm ok with a number of things on mt4 now ie downling indicators is straightforward enough, but I do need to understand more on it. Many thanks.

 

I think - you need compile.

Decompillation is illegal same with hacking.

Because ex4 files are loaded/attached to the window/chart. Compillation is made in MetaEditor.

Read this thread from the beginning about howto.

https://www.mql5.com/en/forum/178706

Reason: