How to code? - page 181

 

Help with Modifying OrderHistory 2.0

Wondered if someone could modify this MQ4 file for me. I want the description that comes when the cursor is over the arrows and trendlines to look more like this..:

SELL

(ordername removed)

Open Time: 2009.05.25 10.00

Close Time: 2009.05.25 11.00

Open Price: 94.98

Close Price: 94.992

Pips: 25.0 |

SL: 50.0 | -> (make 5digit)

TP: 25.0 |

Max Fl. L: 16.9 ("Max Floating Loss/Profit" - Cool if this could be integrated)

Lots: 0.38

Gross: 100.28

...instead of this:

Sell: 12345678 2009.05.25 10.00 @ 94.98

Pips: 250 SL: -750 TP: 250 Lots: 0.38 Gross: $ 100.28

94.992

I tried to change this myself, but with no success. I'm not a programmer (of course), but it would be cool if somebody that is could fix this. It would be appreciated.

 

NFA antihedging please help

hi, i have a problem with NFA new rule. My EA cannot make any pending orders anymore . It is a simple EA : open 1 order , delete 1 unused pending order and make 2 new pending orders , buy limit and sell limit.

Here is the code :

if (TotalMikuOrders()==2 && TotalMikuOrders_Mode(OP_BUY)+TotalMikuOrders_Mode(OP_SELL)==1){

for (int j=0;j<OrdersTotal();j++){

OrderSelect(j,SELECT_BY_POS);

if (OrderType()==OP_BUY){

if (OrderMagicNumber()==Magic_Miku_B){

deleteMikuPending();

sendMikuPending(OrderOpenPrice(),Magic_Miku_S,Magic_Miku_B+1,XFactor*CoA,XFactor*CoB,com+"XA",com+"XB",sl1,sl2,r1,r1,sp,sp0,tp1,tp2);

return(0);

}

}

if (OrderType()==OP_SELL){

if (OrderMagicNumber()==Magic_Miku_S){

deleteMikuPending();

sendMikuPending(OrderOpenPrice(),Magic_Miku_S+1,Magic_Miku_B,XFactor*CoB,XFactor*CoA,com+"XB",com+"XA",sl2,sl1,r1,r1,sp0,sp,tp2,tp1);

return(0);

}

}

}

}

}

return(0);

}

void sendMikuPending(double price, int ms,int mb,double lots,double lotb,string coms,string comb,double sls,double slb,double rs,double rb,double sps,double spb,double tps,double tpb){

double SL=0,TP=0;

int i;

if (StopLoss>0) {SL=NormalizeDouble(NormalizeDouble(OrderOpenPrice()-Range*rb*Point+spb*Point,Digits)-StopLoss*slb*Point,Digits);}else{SL=0;}

if (TakeProfit>0) {TP=NormalizeDouble(NormalizeDouble(OrderOpenPrice()-Range*rb*Point+spb*Point,Digits)+TakeProfit*tpb*Point,Digits);}else{TP=0;}

if (OrderSend(Symbol(),OP_BUYLIMIT,lotb,NormalizeDouble(OrderOpenPrice()-Range*rb*Point+spb*Point,Digits),Slippage,SL,TP,comb,mb,0,Blue)==-1) {

i=GetLastError();

if (i!=1 && i!=0) Print("Buy stop Error :"+error(i)+" at "+Symbol()+" "+Period());

}

if (StopLoss>0) {SL=NormalizeDouble(NormalizeDouble(OrderOpenPrice()+Range*rs*Point-sps*Point,Digits)+StopLoss*sls*Point,Digits);}else{SL=0;}

if (TakeProfit>0) {TP=NormalizeDouble(NormalizeDouble(OrderOpenPrice()+Range*rs*Point-sps*Point,Digits)-TakeProfit*tps*Point,Digits);}else{TP=0;}

if (OrderSend(Symbol(),OP_SELLLIMIT,lots,NormalizeDouble(OrderOpenPrice()+Range*rs*Point-sps*Point,Digits),Slippage,SL,TP,coms,ms,0,Red)==-1) {

i=GetLastError();

if (i!=1 && i!=0) Print("Sell stop Error :"+error(i)+" at "+Symbol()+" "+Period());

}

}

the full code is on attachment. I am thinking maybe the EA should read the last closed order, and make directly 1 open order. But i don't have a clue.

Please Help anyone . Thank you so much.

Files:
miku_test.mq4  15 kb
 

Coding issue

Ok I have a piece of code that seems to cause the error OrderSend #130. I've checked the Stop Loss and the Take Profit settings and they should be well away from the minimum distance required if placing one in the order. I even normalized the numbers to make sure they fit the parameters of the site. So my guess is that there must be a problem with the Ask price or the Bid price that it receives and so the server won't accept it.

This is code from the section where it would place a buy order:

RefreshRates();

ticket = OrderSend(Symbol(),openType,lots,Ask,Slippage,SL,TP,comment,ExpertMagicNumber,0,Color);

Is there something special I should be doing to the Ask to make sure that it fits what the site is looking for when it gets the order? I just assumed that it would get the pricing exactly as the site gave it out.

 

Hi there is a GOOD system that works, posted by JoeSmoe

It would be helpful if someone would know how to create the simplest EA that would only open position when there is a breakout - this would be a lot of help. I tried, but don't know how.

best,

j

 

How to conditionally include a file as part of an EA?

Hello,

I posted this in another section of the forum, but then discovered this section. Please excuse the double posting...

Is it is possible to conditionally include a file as part of an EA? Although the syntax may be incorrect, the concept is...

switch(MASTER_PERIOD)

{

case 30:

#include ;

break;

case 240:

#include ;

break;

}

...with MASTER_PERIOD being an Extern variable.

I appreciate and look forward to your comments ,suggestions and examples of how to accomplish this!

Regards,

DMMcCollum

 

How to Read/Retrieve Price at a Certain Time?

My friend & I are working on an EA. At some stage it (the EA) needs to read & retrieve the price at a certain time, say, 17:00 EST... etc.

Can any senior please advise how to do so, instead of counting the price bars backward? Maybe there is already a function written for it. Kindly help. Thank you all & God Bless!

B rgds/abundance

 
 

Edit

Steven_1974:
Ok I have a piece of code that seems to cause the error OrderSend #130. I've checked the Stop Loss and the Take Profit settings and they should be well away from the minimum distance required if placing one in the order. I even normalized the numbers to make sure they fit the parameters of the site. So my guess is that there must be a problem with the Ask price or the Bid price that it receives and so the server won't accept it.

This is code from the section where it would place a buy order:

RefreshRates();

ticket = OrderSend(Symbol(),OP_BUY,lots,Ask,Slippage,Bid - SL*Point,Ask + TP*Point,comment,ExpertMagicNumber,0,Color);

ticket = OrderSend(Symbol(),OP_SELL,lots,Bid,Slippage,Ask + SL*Point,Bid - TP*Point,comment,ExpertMagicNumber,0,Color);

Is there something special I should be doing to the Ask to make sure that it fits what the site is looking for when it gets the order? I just assumed that it would get the pricing exactly as the site gave it out.

edit as above

OTR

 

JoseMoe System EA

janekpietrzyk:
It would be helpful if someone would know how to create the simplest EA that would only open position when there is a breakout - this would be a lot of help. I tried, but don't know how.

best,

j

find RonaldRaygun EA in that thread.(100 300 pips daily...)

OTR

 

Unmatched data error

Hi Coders

I'm still learning my first steps in MQL-Code.

what's the reason when I have following message in the journal:

Testgenerator:

unmatched data error ( volume limit 159 at 2009.05.06 19 15 exceeded )

where I must look in the code?

Thanks