Trabajo finalizado
![](https://c.mql5.com/i/avatar/avatar_na2.png)
![](https://c.mql5.com/i/avatar/avatar_na2.png)
Tarea técnica
Hi everyone!
I have a working EA based on SMAs and need someone to code the following,
A. Conditions
- The programmer must allow me to do backtesting before making the payment.
- Upon payment, the programmer must provide the .mq4 file.
- The .mq4 file must compile without any "Warning".
- The EA will be tested and used on ICMarkets raw account using MetaTrader 4.
- The intellectual property of the EA belongs to the contractor.
- The programmer has no responsibility for the effectiveness of the EA.
- The EA must only place one order (BUY or SELL) at a time.
- The EA must be capable of backtesting on the following pairs - EURUSD,GBPUSD,USDCAD,EURGBP,EURAUD,AUDCAD,AUDUSD,EURCAD,NZDUSD,AUDNZD.
B. Required Coding (please adapt as required)
1. When placing a BUY order, I wish to retain the price at which the order was placed - variable "initial_price_buy" (e.g. using iOpen);
2. When placing a SELL order, I wish to retain the price at which the order was placed - variable "initial_price_sell" (e.g. using iOpen);
3. When closing a BUY, besides the provided SMA logic, the order will only close if "close_buy" is ABOVE " initial_price_buy ";
4. When closing a SELL, besides the provided SMA logic, the order will only close if "close_sell" is BELOW " initial_price_sell ";
NOTE
I've attempted to code items 1,2 and 3 above but could not manage. My code is commented in the sample code I'm attaching and is provided in the following lines..
24;25;26;27;63;64;65;66;88;93;99 and 108.
//+------------------------------------------------------------------+ //| droid_top_sma_v00.mq4 | //| Copyright 2022, Mario Vasconcelos | //| https://www.none.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2022, Mario Vasconcelos" #property link "https://www.none.com" #property version "1.00" #property strict input string iNote_1 = " --== EA Settings ==-- "; input ENUM_TIMEFRAMES iTF = PERIOD_CURRENT; //TimeFrame) input int iRC = 60; //RANGING_CANDLES input int iRL = 150; //RANGING_LIMIT input double iLot = 0.01; //Lot input int iMagic = 201159; //Mag double sma_7; //magenta double sma_14; //cyan double sma_25; //green double sma_75; //dash white double sma_200; //dash orange //static initial_price_sell; //static initial_price_buy; //double close_buy; //double close_sell; int Ranging; int ticket; datetime gBarTime; string _PR = "EAO_"; int _ae[4] = {6,136,138,129}; datetime _TimeInit = 0; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { sma_7 = iMA (_Symbol,_Period,7,0,MODE_SMA,PRICE_OPEN,0); //magenta sma_14 = iMA (_Symbol,_Period,14,0,MODE_SMA,PRICE_OPEN,0); //cyan sma_25 = iMA (_Symbol,_Period,25,0,MODE_SMA,PRICE_OPEN,0); //green sma_75 = iMA (_Symbol,_Period,75,0,MODE_SMA,PRICE_OPEN,0); //dash white sma_200 = iMA (_Symbol,_Period,200,0,MODE_SMA,PRICE_OPEN,0); //dash orange // initial_price_buy = iOpen(NULL,0,0); // initial_price_sell = iOpen(NULL,0,0); // close_buy = iOpen(NULL,0,0); // close_sell = iOpen(NULL,0,0); int HighestCandle = iHighest(_Symbol,iTF,MODE_CLOSE,iRC,0); ObjectDelete(_PR+"LH"); ObjectCreate(_PR+"LH",OBJ_HLINE,0,_Time(0),_High(HighestCandle)); int LowestCandle = iLowest(_Symbol,iTF,MODE_CLOSE,iRC,0); ObjectDelete(_PR+"LL"); ObjectCreate(_PR+"LL",OBJ_HLINE,0,_Time(0),_Low(LowestCandle)); Ranging = 0; double diff = _High(HighestCandle)-_Low(LowestCandle); if(diff<=iRL*_Point) { Ranging = 1; } if(Ranging == 0){ if(ticket <= 0){ // placing SELL if((sma_75 > sma_200) && (sma_7 > sma_75) && (sma_7 < sma_14) && (sma_7 < sma_25)) ticket = OrderSend(Symbol(),OP_SELL,iLot,Bid,10,0,0,NULL,iMagic,0,clrRed); // initial_price_sell = iOpen(NULL,0,0); // placing BUY if((sma_75 > sma_200) && (sma_7 < sma_75) && (sma_7 < sma_25) && (sma_14 < sma_75)) ticket = OrderSend(Symbol(),OP_BUY,iLot,Ask,10,0,0,NULL,iMagic,0,clrGreen); // initial_price_buy = iOpen(NULL,0,0); } } // exit SELL // if((sma_75 < sma_200) && (sma_7 < sma_75) && (sma_14 < sma_75) && (sma_14 < sma_25)) // if(close_sell < initial_price_sell) "close_sell" is the price at the moment the SMA logic above is met. if(OrderSelect(ticket, SELECT_BY_TICKET) && OrderType() == OP_SELL){ if(OrderClose(OrderTicket(),OrderLots(),Ask,10,clrOrange)){ ticket = 0; } } // exit BUY // if((sma_75 > sma_200) && (sma_7 > sma_75) && (sma_14 > sma_75) && (sma_7 < sma_25)) // if(close_buy > initial_price_buy) "close_buy" is the price at the moment the SMA logic above is met. if(OrderSelect(ticket, SELECT_BY_TICKET) && OrderType() == OP_BUY){ if(OrderClose(OrderTicket(),OrderLots(),Bid,10,clrWhite)){ ticket = 0; } } } double _Close(int i) { return(iClose(_Symbol,iTF,i)); } double _Open(int i) { return(iOpen(_Symbol,iTF,i)); } double _High(int i) { return(iHigh(_Symbol,iTF,i)); } double _Low(int i) { return(iLow(_Symbol,iTF,i)); } datetime _Time(int i) { return(iTime(_Symbol,iTF,i)); } //+------------------------------------------------------------------+