# Reverlsals orders

7

Hi guys can somebody help a little?

I have a EA - its working like that: ea is opening buy and sell pendings orders with sl and tp, and when sell or buy order is filled on SL is turning reversal pending order.

Is really simple algoritm But... i dont no why my reversals dont open properly - can somebody check this code? Please...

```//+------------------------------------------------------------------+
//|                                                   Marcin Mrugacz |
//|                                           finansowa.blogspot.com |
//+------------------------------------------------------------------+
#property show_inputs

#define MAGICMA 456
#include <stdlib.mqh>

/////////////////////////// Before You will start go to:
///////////////////////////

/////////////////////////  //
extern double size=0.1;    // choose lot size.
extern int tp=100;         // choose TP in points.   //You need to setup value 0 dont off this
extern int sl=100;         // choose SL in points    //You need to setup value 0 dont off this
extern int distance=300;   // choose distance in points
/////////////////////////////
extern string r="TP and SL for reversals: ";
///////////////////////////// SL and TP for reversals: (They are setup after reaching the price around placed pendings)
extern double tp2=200;     // tp for 2 reversal 0 - off this //
extern double sl2=0;       // sl for 2 reversal 0 - off this //
/////////////////////////////
extern string t="Setup time: ";
//extern bool turnon=true;   //  - Turn on/off setuping the time of running orders.
extern int houer=14;       //
extern int minute=30;      //
/////////////////////////////
extern int slipage=30;

int i=0;
int c=1;
string script=" ";
int ticket[5];
int a=0;int b=0;

int init()
{
//----
double bid=Bid;
int ticket[6];

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
{
//----
datetime T_cur = TimeCurrent();
int curenthouer= TimeHour(T_cur);
int curentminute=TimeMinute(T_cur);

// if(curenthouer>-1+houer && curentminute>-1+minute)     {

string check[10];

double bid=Bid;
double point=Point;

if (c==1) {
static double selr; selr=bid-distance*point+(sl*point);

static double sel; sel=bid-distance*point;

ticket[3]=OrderSend(Symbol(), OP_BUYSTOP, size, bid+distance*Point, 1,  bid+distance*Point-sl*Point, bid+distance*Point+tp*Point, "pending buystop", MAGICMA, 0, Green);
}c++;if (c==10) c=3;

string selrev;
if (a==234) {selrev="Revelsal to sell is on";}

double minSL=MarketInfo(Symbol(), MODE_STOPLEVEL);

if (i==0) {script="R";}
if (i==1) {script="Ru";}
if (i==2) {script="Run";}
if (i==3) {script="Runn";}
if (i==4) {script="Runni";}
if (i==5) {script="Runnin";}
if (i==6) {script="Running";}

i++; if (i==7) i=0;
if (sl2>0) double slrev=buyr+(sl2*Point); else slrev=0;
if (tp2>0) double tprev=buyr-(tp2*Point); else tprev=0;
if (sl2>0) double slrev2=selr-(sl2*Point); else slrev=0;
if (tp2>0) double tprev2=selr+(tp2*Point); else tprev=0;

OrderSelect(ticket[1],SELECT_BY_TICKET);
int order=OrderType();

int error;
if ( b!=235  && OrderType()==OP_BUY) {b=235; ticket[4]=OrderSend(Symbol(), OP_SELLSTOP, size,buyr, 1,  slrev, tprev, "revelsal sell", MAGICMA, 0, Pink);
{error=GetLastError(); Print("Sell stop Error = ",ErrorDescription(error));}  }
OrderSelect(ticket[3],SELECT_BY_TICKET);
order=OrderType();
if ( a!=234  && OrderType()==OP_SELL) {a=234; ticket[2]=OrderSend(Symbol(), OP_BUYSTOP, size,selr , 1,  slrev2, tprev2, "revelsal buy", MAGICMA, 0, Pink);
{error=GetLastError(); Print("Sell stop Error = ",ErrorDescription(error));}   }

//----
//Sleep(30); if (ticket[2]>0 || ticket[4]>0)

//         }

Comment(
"min SL/TP here is ", minSL, " pips\n",
"Revelsal to selstop is setup on: ", selr," \n",
"a ", a," \n ",  "b ", b," \n ",
"selrev",selr, "\n",
"OrderTYpe", order,
"Script is ", script," \n"
);

return(0);
}
//+------------------------------------------------------------------+
```
7

OK

I just solved the problem. Thanks :P

:)

6372

migaczyk:

OK

I just solved the problem. Thanks :P

:)