FXEWEN:
Hello,
I just start learn to write ea, can somebody give your samples, how to code this
Enter Short:
Bar # 1 must be up bar, bar #0 price lower than bar #1 low price then enter short
Thanks
if Bar #1 = Up Bars (Close-Open)
Bar#0 ask price < Bar #1 low price - 3pip
OrderSend (Sell)
What do you think yourself.....
Trie something and show us....
off the top of my head...
if (Close[1] > Open[1])
if (Bid-3*Point < Low[1])
Place Sell logic...
serpentsnoir:
off the top of my head...
if (Close[1] > Open[1])
if (Bid-3*Point < Low[1])
Place Sell logic...
Thanks serpentsnoir, I code it like this, it give error 130 (invalid stop), please help
Code:
extern double TakeProfit = 50; extern double Lots=1; extern double MagicNumber=12345; int start() { //---- int ticket, cnt, total; if(TakeProfit<10) { Print("TakeProfit less than 10"); return(0); // check TakeProfit } //start trade - sell total = OrdersTotal(); if(total < 1) //if no trade open { if (Close[1] > Open[1] && Bid-3*Point < Low[1]) { ticket=OrderSend(Symbol(),OP_SELL,Lots,Ask,3,0,Ask+TakeProfit*Point,"My EA",MagicNumber,0,Red); if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice()); } else Print("Error opening SELL order : ",GetLastError()); return(0); } } //---- return(0); }
Files:
sendorder2.mq4
3 kb
ticket=OrderSend(Symbol(),OP_SELL,Lots,Ask,3,0,Ask+TakeProfit*Point,"My EA",MagicNumber,0,Red);
- You BUY at the ASK, you SELL at the BID
- For a SELL, your takeProfits would be LOWER then the open price.
- For 4/5 digit brokers you must adjust TP, SL, AND slippage. For ECN brokers you must open first and then set stops.
//++++ These are adjusted for 5 digit brokers. int pips2points; // slippage 3 pips 3=points 30=points double pips2dbl; // Stoploss 15 pips 0.015 0.0150 int Digits.pips; // DoubleToStr(dbl/pips2dbl, Digits.pips) int init(){ if (Digits % 2 == 1){ // DE30=1/JPY=3/EURUSD=5 https://www.mql5.com/en/forum/135345 pips2dbl = Point*10; pips2points = 10; Digits.pips = 1; } else { pips2dbl = Point; pips2points = 1; Digits.pips = 0; } // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl //---- These are adjusted for 5 digit brokers. /* On ECN brokers you must open first and THEN set stops int ticket = OrderSend(..., 0,0,...) if (ticket < 0) Alert("OrderSend failed: ", GetLastError()); else if (!OrderSelect(ticket, SELECT_BY_TICKET)) Alert("OrderSelect failed: ", GetLastError()); else if (!OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0) Alert("OrderModify failed: ", GetLastError()); */
WHRoeder:
Thanks WHRoeder. I amend the post with SRC button, great help
- You BUY at the ASK, you SELL at the BID
- For a SELL, your takeProfits would be LOWER then the open price.
- For 4/5 digit brokers you must adjust TP, SL, AND slippage. For ECN brokers you must open first and then set stops.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello,
I just start learn to write ea, can somebody give your samples, how to code this
Enter Short:
Bar # 1 must be up bar, bar #0 price lower than bar #1 low price then enter short
Thanks
if Bar #1 = Up Bars (Close-Open)
Bar#0 ask price < Bar #1 low price - 3pip
OrderSend (Sell)