Because I sent the executable file by mistake, I am resending the Program file that can easily be opened.
I am a new Programmer to MQL4. Doing Ok but can't figure out why this EA won't close trades or go long.
Also what I want this to do is:
- Then you should have updated the original thread not opened a new one.
//---- sell conditions if(sto>80 && rsi>70) sto=True; rsi=True; if((adx<adxx && adxa>adxaa && adxb>adxbb) && (adx>=+10) && (adxtfh>=-50)) : //---- buy conditions if(sto<20 && rsi<30)
sto and rsi are bools (0 or 1 only and initially 0 in the external) The first IF will NEVER be true so you never set sto to true. Then you set rsi to True (1). When you evaluate the buy condition, sto will still be false, thus it will never trade buys.- No Slaves here, learn to code or pay someone. We're not going to code it FOR you. We are willing to HELP you.
if(Volume[0]>1) return;
Volume is unreliable, you can miss ticks. Bars is unreliable (won't change once it reached max bars on chart.) Always use timestatic datetime Time0; if (Time0 == Time[0]) return; Time0 = Time[0];
- Always count down when closing, modifying multiple order, etc. Count down ALWAYS.
- Then you should have updated the original thread not opened a new one.
- sto and rsi are bools (0 or 1 only and initially 0 in the external) The first IF will NEVER be true so you never set sto to true. Then you set rsi to True (1). When you evaluate the buy condition, sto will still be false, thus it will never trade buys.
- No Slaves here, learn to code or pay someone. We're not going to code it FOR you. We are willing to HELP you.
- Volume is unreliable, you can miss ticks. Bars is unreliable (won't change once it reached max bars on chart.) Always use time
- Always count down when closing, modifying multiple order, etc. Count down ALWAYS.
Yeah I should have just updated the original message. Was in a hurry I guess. I appreciate the help on the Stochastic and RSI but I knew that wasn't right anyway. Also the EA didn't go long before the Stochastic
and RSI were put in the code. I wish I had never put in the Stochastic or RSI. The part I really wanted was on the Stops but I can see that that would be asking someone to do the code for you. I NEVER wanted
anybody to do it for me. By putting my entire EA code on here this is a big help. Shouldn't have the appearance of someone that want's somebody to do all the work for them.I guess this so-called Forum just isn't going to work for me. I don't know how to put a code problem on here when that's what it is. Somebody else said that once before, No Slaves here, learn to code or pay someone. I just bet that I'm not the only one that this has ever happened to on this thing. I know one thing, I NEVER want to hear it again.
Doing Ok but can't figure out why this EA won't close trades or go long.
This is your code to close Orders . . .
//+------------------------------------------------------------------+ //| Check for close order conditions | //+------------------------------------------------------------------+ void CheckForClose() { double ma; // <---- locally declared double maa; // <---- locally declared //---- go trading only for first tiks of new bar if(Volume[0]>1) return; //---- for(int i=0;i<OrdersTotal();i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue; //---- check order type if(OrderType()==OP_BUY) { if(ma<maa) OrderClose(OrderTicket(),OrderLots(),Bid,3,White); // <---- local ma & maa are both 0 break; } if(OrderType()==OP_SELL) { if(ma>maa) OrderClose(OrderTicket(),OrderLots(),Ask,3,White); // <---- local ma & maa are both 0 break; } } //---- }
You pass Symbol() in your call CalculateCurrentOrders(Symbol()) but the function then doesn't use the value you passed . . .
WHRoeder answered why your code won't place a long trade.
There are plenty of posts on this forum about Trailing SL, have a read: http://crum.be/trailsl
This is your code to close Orders . . .
You pass Symbol() in your call CalculateCurrentOrders(Symbol()) but the function then doesn't use the value you passed . . .
WHRoeder answered why your code won't place a long trade.
There are plenty of posts on this forum about Trailing SL, have a read: /go?link=http://lmgtfy.com/?q=site:forum.mql4.com+trailing+stop
Hi Raptor, Sorry about being the way I was last night. I am struggling and was upset. Wasn't going to use the Forum anymore but I need it and I will be carefull about asking for too much. Appreciate the guys
like you and others who help. Maybe there should be a small fee for help put on here. There is time involved in this code business. Anyway, I will check the link you put in for me on Trailing Stops. Just one more
quick question that I havn't seen in the manual: When should we use RES instead of Ticket for the OrderSend section. As you can probably see, the Orders code area is where I am a little unclear yet . Different
ways of doing it etc.
Thanks,
JimTrader1
Just one more quick question that I havn't seen in the manual: When should we use RES instead of Ticket for the OrderSend section.
Sorry, not sure what you mean . . RES ?
When an OrderSend works it returns it's Ticket number, otherwise it returns -1
Sorry, not sure what you mean . . RES ?
When an OrderSend works it returns it's Ticket number, otherwise it returns -1
Here are a couple of examples to make it more clear.RES is for resend.Ticket is obviously for a Ticket order. Because I am having a lot of
trouble getting this to go long and close orders, I need to fully understand these Order pre-fixes.
JimTrader1
Here are a couple of examples to make it more clear.RES is for resend.Ticket is obviously for a Ticket order. Because I am having a lot of
trouble getting this to go long and close orders, I need to fully understand these Order pre-fixes.
JimTrader1
Ah I see, you meant the variables in your code, I didn't realise . . .
res is just a variable, in your code it does nothing, it's pointless . . . it is used to store the ticket number but isn't used beyond that.
I don't see ticket in your code, in the txt file you attached it's just a variable used to store the ticket number from an order that has been placed.
Both res and ticket are variable names . . . you can call them whatever you like, but using something that makes logical sense makes your code more reasonable, don't be frightened to make them very readable if you want, e.g. LongTicketNumber, ShortTicketNumber, etc, when the code is compiled all these variable names are replaced anyway, so in this case . . length is not an issue.
Ah I see, you meant the variables in your code, I didn't realise . . .
res is just a variable, in your code it does nothing, it's pointless . . . it is used to store the ticket number but isn't used beyond that.
I don't see ticket in your code, in the txt file you attached it's just a variable used to store the ticket number from an order that has been placed.
Both res and ticket are variable names . . . you can call them whatever you like, but using something that makes logical sense makes your code more reasonable, don't be frightened to make them very readable if you want, e.g. LongTicketNumber, ShortTicketNumber, etc, when the code is compiled all these variable names are replaced anyway, so in this case . . length is not an issue.
Great. That helps. I am also confused about the different Magic Numbers. I know what it is for. Can any number be used with certain number of digits? Also
sometimes they are using Magic Moving average. What's the difference here in terms of Number vs Moving average???
JimTrader1
- Magic number is an int so anything up to 2,147,483,647. I just use the codeing start date 20111027
- Magic number has nothing to do with moving averages.
Доброго времени суток уважаемые форумчане!
Меня зовут Герман, мне 23 года, я являюсь трейдером компании "Инстафорекс"
Помогите в поиске нужного скрипта! Скрипт нужен для сетки отложенных ордеров.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Because I sent the executable file by mistake, I am resending the Program file that can easily be opened.
I am a new Programmer to MQL4. Doing Ok but can't figure out why this EA won't close trades or go long. Also what I want this
to do is: Place a StopLoss of 18 and TargetPrice of 36 pips. For OrderModify, when price gains 20 pips, move StopLoss to Breakeven.
If price then gains 30 pips, place Trailing Stop of 20 pips.
Thanks,
"JimTrader1"