Ask! - page 90

 

Help with ordersend comments please

Need some help please I have an EA that has 4 different entry criteria and would like to be able to have a comment in ordersend to let me know which entry criteria was met for any particular position. i have been trying to get this to work but all I seem to be able to do is have a list ie long1,long2,long3 etc. I know that I need to do something different to what I am currently doing but can think of what it might be. I have attached a version of the EA that I am using to experiment with. so any help in solving this would be great. Below is what I am currently seeing.

2007.12.21 21:57:22 euroform V 2.1-exp EURJPY,H1: Error opening BUY order : invalid function parameter value

2007.12.21 21:57:22 euroform V 2.1-exp EURJPY,H1: Long4 signal taken

2007.12.21 21:57:22 euroform V 2.1-exp EURJPY,H1: Long3 signal taken

2007.12.21 21:57:22 euroform V 2.1-exp EURJPY,H1: Long2 signal taken

2007.12.21 21:57:22 euroform V 2.1-exp EURJPY,H1: Long1 signal taken

2007.12.21 21:57:22 euroform V 2.1-exp EURJPY,H1: Short4 signal taken

2007.12.21 21:57:22 euroform V 2.1-exp EURJPY,H1: Short3 signal taken

2007.12.21 21:57:22 euroform V 2.1-exp EURJPY,H1: Short2 signal taken

2007.12.21 21:57:22 euroform V 2.1-exp EURJPY,H1: Short1 signal taken

2007.12.21 21:57:22 euroform V 2.1-exp EURJPY,H1: invalid lots amount for OrderSend function

2007.12.21 21:57:22 euroform V 2.1-exp EURJPY,H1: Long4 signal taken

2007.12.21 21:57:22 euroform V 2.1-exp EURJPY,H1: Long3 signal taken

2007.12.21 21:57:22 euroform V 2.1-exp EURJPY,H1: Long2 signal taken

2007.12.21 21:57:22 euroform V 2.1-exp EURJPY,H1: Long1 signal taken

2007.12.21 21:57:22 euroform V 2.1-exp EURJPY,H1: Short4 signal taken

2007.12.21 21:57:22 euroform V 2.1-exp EURJPY,H1: Short3 signal taken

Cheers

Beno

Files:
 
stevex33:
Hi guys,

I've got a question.

I'd like to learn to write my own indicators, but I don't really have any idea where I should start.

I've got an idea in my head and the basics of how it should work, but I need a little help.

I've like to create an indicator that shows the average high that a currency moves from the open every day, the same for the low and the same for the close.

So they would all be the distance from the open of the day in terms of pips.

I'd like the user the be able to specify over how many days he wants to calculate that average.

So it would be something like lines drawn in the current days bar to represent the average high, low and close of the currency over x days, and it should keep the lines drawn on the chart.

I tried using the moving average indicator as a baseline to start from, but it all looks pretty confusing. Can someone simplify it for me by breaking it all down into what I should be adding/deleting and where please?

regards

steve

Start at the beginning, i.e: learn MQL4. Download e-books by CodersGuru, print them if you are like me---not good at reading something from the screen, then read them.

Read them again if you don't understand the first time.

Do the practice.

if you still don't understand, check out as many EA as possible, see if there's any similiraties with yours. Look for explanation of each line in CodersGuru book, then try to write your own.

You may take some times to write your basic EA, but once you did, honing them is a matter of trying and keep trying.

good luck.

 

what's wrong with these?

Hey, guys

My EA at first based its profit taking from trailing-stop. Then I add some fibo point and start trailing after the last fibo point is reached. But strategy-tester won't work with the latest development. Please help me find my own mistake in the following program.

Thank you.

void CheckForTrailing()

{

double highest = High;

double lowest = Low;

double p1u = NormalizeDouble((OrderOpenPrice()-lowest)*0.618,4);

double tpb1 = p1u*10000;

double p1d = NormalizeDouble((highest-OrderOpenPrice())*0.618,4);

double tps1 = p1d*10000;

double p2u = NormalizeDouble((OrderOpenPrice()-lowest)*1,4);

double tpb2 = p2u*10000;

double p2d = NormalizeDouble((highest-OrderOpenPrice())*1,4);

double tps2 = p2d*10000;

double p3u = NormalizeDouble((OrderOpenPrice()-lowest)*1.618,4);

double tpb3 = p3u*10000;

double p3d = NormalizeDouble((highest-OrderOpenPrice())*1.618,4);

double tps3 = p3d*10000;

double p4u = NormalizeDouble((OrderOpenPrice()-lowest)*2.382,4);

double tpb4 = p4u*10000;

double p4d = NormalizeDouble((highest-OrderOpenPrice())*2.382,4);

double tps4 = p4d*10000;

double p5u = NormalizeDouble((OrderOpenPrice()-lowest)*3.236,4);

double tpb5 = p5u*10000;

double p5d = NormalizeDouble((highest-OrderOpenPrice())*3.236,4);

double tps5 = p5d*10000;

for(int i=0; i<OrdersTotal(); i++)

{

if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)

break;

if(OrderMagicNumber()!=magic || OrderSymbol()!=Symbol())

continue;

if(OrderType()<=OP_SELL)

{

if(OrderType()==OP_BUY && Bid>OrderOpenPrice())

{

if((Bid>=OrderOpenPrice()+Point*tpb1) && (OrderStopLoss()!=OrderOpenPrice()))

{

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*tpb1,0,0,CLR_NONE);

return(0);

}

if((Bid>=OrderOpenPrice()+Point*tpb2) && (OrderStopLoss()!=OrderOpenPrice()+Point*tpb1))

{

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*tpb2,0,0,CLR_NONE);

return(0);

}

if((Bid>=OrderOpenPrice()+Point*tpb3) && (OrderStopLoss()!=OrderOpenPrice()+Point*tpb2))

{

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*tpb3,0,0,CLR_NONE);

return(0);

}

if((Bid>=OrderOpenPrice()+Point*tpb4) && (OrderStopLoss()!=OrderOpenPrice()+Point*tpb3))

{

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*tpb4,0,0,CLR_NONE);

return(0);

}

if((Bid>=OrderOpenPrice()+Point*tpb5) && (OrderStopLoss()!=OrderOpenPrice()+Point*tpb4))

{

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*tpb5,0,0,CLR_NONE);

return(0);

}

if((Bid>=OrderOpenPrice()+Point*(tpb5+ts)) && (OrderStopLoss()+Point*ts<Bid))

{

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*ts,0,0,CLR_NONE);

return(0);

}

}

else if(OrderType()==OP_SELL && Ask<OrderOpenPrice())

{

if((Ask<=OrderOpenPrice()-Point*tps1) && (OrderStopLoss()!=OrderOpenPrice()))

{

OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*tps1,0,0,CLR_NONE);

return(0);

}

if((Ask<=OrderOpenPrice()-Point*tps2) && (OrderStopLoss()!=OrderOpenPrice()-Point*tps1))

{

OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*tps2,0,0,CLR_NONE);

return(0);

}

if((Ask<=OrderOpenPrice()-Point*tps3) && (OrderStopLoss()!=OrderOpenPrice()-Point*tps2))

{

OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*tps3,0,0,CLR_NONE);

return(0);

}

if((Ask<=OrderOpenPrice()-Point*tps4) && (OrderStopLoss()!=OrderOpenPrice()-Point*tps3))

{

OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*tps4,0,0,CLR_NONE);

return(0);

}

if((Ask<=OrderOpenPrice()-Point*tps5) && (OrderStopLoss()!=OrderOpenPrice()-Point*tps4))

{

OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*tps5,0,0,CLR_NONE);

return(0);

}

if((AskAsk))

{

OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*ts,0,0,CLR_NONE);

return(0);

}

}

}

}

}
 

How do you stop this from happening????

MACDI on 4-Hr graph shows positive, but if I use it as an indicator I get a sell because the MACDI on 1-Min may go negative for a brief period of time, but is not reflected on the 4-Hr graph. How do I code this so that my program is receiving the hourly average and not the 1-Min results.

Dave

 
 

which low?

I think you forgot about which low you use as currentlow. See, I can't imagine if you mean the low of current bar. If you mean what I think you mean, try to use iLowest[]. See it in dictionary of Metaeditor.

 

missed point

sorry, I didn't see you put currentlow = 1000;. But suggestion remains. See, currentlow = 1000; 1000 what? 1.0000 like in GBP/USD? 1000 point, from where? So, still the same, use iLowest[] for currentlow. I think it would work fine.

 

iLowest

Hi Sendra,

Thanks for your prompt reply.

What I am trying to achieve is not based on a high or low of any timeframe but the lowest point prior to a Ret1 (75 pip) retracement. I am focusing on the EUR/USD to start.

CurrentLow is supposed to track the lowest point before the retracement.

The following is an example of what I am trying to achieve.

a) Let's say we open the EA and the price is 1.4000 and it ranges between 1.4030 and 1.3970 before going to 1.4045. I would want CurrentLow to be 1.3970 (Lowest point) and to place the first sell order at 1.4045 (Entry1) with a SL of 1.4195 (SL1 =150 pips) and a Take Profit (TPA = 75 pips) of 1.3970.

b) if the price continues to go up to 1.4120 (Entry2), I would want a 2nd sell order placed with take profit (TPB =76 pips) of 1.4044 and SL of 1.4195 (same as on the first order).

My EA seems to work for the first order but it doesn't seem to get to the second order. I have been able to get it to place the second order but the price was the same as the first order and the SL was screwed up.

My long term goal is to have it decide whether it should be a buy or sell based on long term trend indicators and of course to have a buy set up like this sell set up as shown here. I have no idea whether it will be profitable but I am trying to learn and will surely make a million modifications before it is completed. I have come to the conclusion that to find out if any strategy works, it needs to be automated and take the human error out of the decision making. Obviously, fundamentals need to be looked at but that will come later...maybe.

Any help from Sendra or anyone else will be highly appreciated.

Thanks

Putz

 

i Lowest and CurrentLow

Hi Sendra,

In order to answer your question about CurrentLow, I gave it a value of 1000 as that will always be bigger than any E/U price. This is to make sure that it takes the first EU price when it opens. If I would set it to 0, the price would never be lower and therefore no trades would ever take place.

I have never seen iLowest but I will check into it to see if it would work for me.

Thanks

Putz

 

Code - Trade Once a Day

Can someone help me with a script or ea that forces only 1 trade per day?

Thanks A Bunch

Reason: