-
- //+------------------------------------------------------------------+
- //| Dirty_Rat.mq4 |
- //| Agent86's Dirty Rat Trade |
- //| http://www.iclbiz.com/joomla |
- //+------------------------------------------------------------------+
- #property copyright "Agent86"
- #property link "www.iclbiz.com/joomla"
-
- //---- input parameters
- extern double TakeProfit=300.0;
- extern double Lots=0.1;
- extern double StopLoss=40.0;
- //++++ These are adjusted for 5 digit brokers.
-
- int pips2points; // slippage 3 pips 3=points 30=points
- double pips2dbl; // Stoploss 15 pips 0.0015 0.00150
- int Digits.pips; // DoubleToStr(dbl/pips2dbl, Digits.pips)
-
- // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
- //+------------------------------------------------------------------+
- //| expert initialization function |
- //+------------------------------------------------------------------+
- int init()
- {
- if (Digits == 5 || Digits == 3)
- { // Adjust for five (5) digit brokers.
- pips2dbl = Point*10; pips2points = 10; Digits.pips = 1;
- }
- else
- {
- pips2dbl = Point; pips2points = 1; Digits.pips = 0;
- }
- // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
- //----
-
- //----
- return(0);
- }
- //+------------------------------------------------------------------+
- //| expert deinitialization function |
- //+------------------------------------------------------------------+
- int deinit()
- {
- //----
-
- //----
- return(0);
- }
-
-
- //+------------------------------------------------------------------+
- //| expert start function |
- //+------------------------------------------------------------------+
- int start()
- {
- //----
-
- int ticket,i,total,result;
-
- double faster = iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1), //MODE_MAIN
- slower = iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1), //MODE_SIGNAL
- faster_2 = iMACD(NULL,PERIOD_H4,12,26,9,PRICE_CLOSE,MODE_MAIN,1), //MODE_MAIN
- slower_2 = iMACD(NULL,PERIOD_H4,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1); //MODE_SIGNAL
-
- //I'm going to have to create some loop
-
-
- total = OrdersTotal();
- if(total < 1){
- if(faster > slower)
- OrderSend(Symbol(),OP_BUY,Lots,Ask,3*pips2points,Bid-StopLoss*pips2dbl,Bid+TakeProfit*pips2dbl,"My EA",12345,0,Green);
- }
-
- /*
- if(total > 0){
- if(faster < slower)
- OrderSelect(SELECT_BY_POS, MODE_TRADES);
- if(OrderType() == OP_BUY && Symbol() == OrderSymbol()){
- result = OrderClose(OrderTicket(), OrderLots(), Bid*pips2dbl,3*pips2points, Red);
- if(result == false){
- Print("Order",OrderTicket()," failed to close Error ",GetLastError());
- return(0);
- }
- }
- }
- }
-
- */
-
- for(i = 0; i < OrdersTotal(); i++)
- OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
- if(OrderType() == OP_BUY && Symbol() == OrderSymbol()){
- if(faster < slower)
- result = OrderClose( OrderTicket(), OrderLots(), Bid,3, Red);
- if(result == false){
- Print("Order", OrderTicket()," failed to close Error ",GetLastError());
- return(0);
- }
- }
- }
-
-
-
-
- //+------------------------------------------------------------------+
-