Download MetaTrader 5
To add comments, please log in or register
Have you developed a profitable strategy? Share it with millions of traders via Signals!
pascalboy
238
pascalboy 2014.03.05 15:20 
extern int K=100;
extern int D=25;
extern int S=45;
extern int P=4;
extern double Min=1000;
extern double Max;
double MaxBalance;
int Lots=1;
double k=1;
bool mevcutstr;
bool yenistr;
int start()


{

int ticket;



double stoccurrM=iStochastic(Symbol(),0,K,D,S,0,0,MODE_MAIN,0);
double stocprevM=iStochastic(Symbol(),0,K,D,S,0,0,MODE_MAIN,1);
double stocprevprevM=iStochastic(Symbol(),0,K,D,S,0,0,MODE_MAIN,2);

double stoccurrS=iStochastic(Symbol(),0,K,D,S,0,0,MODE_SIGNAL,0);
double stocprevS=iStochastic(Symbol(),0,K,D,S,0,0,MODE_SIGNAL,1);
double stocprevSS=iStochastic(Symbol(),0,K,D,S,0,0,MODE_SIGNAL,2);


double stocmin=MathMin(stoccurrM,Min);
Min=stocmin;



double stocmax=MathMax(stoccurrM,Max);
Max=stocmax;

double Balance=AccountBalance();
MaxBalance=MathMax(Balance,MaxBalance);

double X=1000;
if(mevcutstr==0&&(MaxBalance-X)>=Balance)
{
yenistr=1;
if(mevcutstr==0&&yenistr==1)
{
MaxBalance=Balance;
}
}

if(mevcutstr==1&&(MaxBalance-X)>=Balance)
{
yenistr=0;
if(mevcutstr==1&&yenistr==0)
{
MaxBalance=Balance;
}

}

mevcutstr=yenistr;

Lots=1;



if(Balance<=10000)
{
Lots=1;
}

if(mevcutstr==1&&stoccurrS<stocprevS&&stocprevS>stocprevSS)
{

bool sellcondition=1;
bool buycondition=0;

} 


if(mevcutstr==1&&stoccurrS>stocprevS&&stocprevS<stocprevSS)
{

sellcondition=0;
buycondition=1;

} 



double sslope=stoccurrM/stocprevM;



//if(stoccurrM<stoccurrS)
if(mevcutstr==0&&stoccurrS>stocprevS&&stocprevS<stocprevSS)
//if(sslope<0.9995)
//if(Max-2>=stoccurrM)
{


sellcondition=1;
buycondition=0;
} 

//if(Min+2<=stoccurrM)
//if(stoccurrM>stoccurrS)
if(mevcutstr==0&&stoccurrS<stocprevS&&stocprevS>stocprevSS)
//if(sslope>1.0005)
{

buycondition=1;
sellcondition=0;
} 





double smacurr=iMA(Symbol(),0,P,0,0,0,0);
double smaprev=iMA(Symbol(),0,P,0,0,0,3);

double stoslope=stoccurrM/stocprevM;


double A=smacurr-smaprev;

//double stdcurr=iStdDev(Symbol(),0,P,0,0,0,0);
//double stdprev=iStdDev(Symbol(),0,P,2,0,0,0);
//double std =stdcurr/stdprev;
double smaslope=(smacurr/smaprev);
stoslope=stoccurrM/stocprevM;



double zamancur=iTime(Symbol(),0,0);
double zamanprev=iTime(Symbol(),0,3);

double smavelocity=10000*((smacurr-smaprev)/(zamancur-zamanprev));
double stovelocity=10000*((stoccurrM-stocprevM)/(zamancur-zamanprev));









//Print(slope);


if(buycondition==1&&OrdersTotal()==0)

{

Print("Mevcutstr", mevcutstr);
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,0,0,0);
Min=1000;
}


if(sellcondition==1&&OrdersTotal()==0)
{

Print("Mevcutstr", mevcutstr);
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,0,0,0);
Max=0;
}




for(int i=OrdersTotal();i>=0;i--)

{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
}
Lots=OrderLots();
ticket=OrderTicket();
int type=OrderType();
double orderprice=OrderOpenPrice();
datetime ordertime=OrderOpenTime();
datetime orderclosetime=OrderCloseTime();
double B=orderclosetime-ordertime;
double emirsuresi;

Print(B);



//if(ticket==64)
//{
//str=1;
//MaxBalance=0;
//}

//if(ticket==132)
//{
//str=0;
//MaxBalance=0;
//}


//if(ticket==231)
//{
//str=1;
//MaxBalance=0;
//}


if(type==OP_BUY&&sellcondition==1&&buycondition==0)
{

OrderClose(ticket,Lots,Bid,3,0);
}

if(type==OP_SELL&&buycondition==1&&sellcondition==0)
{

OrderClose(ticket,Lots,Ask,3,0);
}



if(OrdersTotal()>0&&emirsuresi>180000&&type==OP_BUY)
{

OrderClose(ticket,Lots,Bid,3,0);
}


if(OrdersTotal()>0&&emirsuresi>180000&&type==OP_SELL)
{

OrderClose(ticket,Lots,Ask,3,0);
}

if(OrdersTotal()>0&&emirsuresi>20000&&type==OP_BUY&&(Ask-orderprice)<0)
{

OrderClose(ticket,Lots,Bid,3,0);
}


if(OrdersTotal()>0&&emirsuresi>20000&&type==OP_SELL&&(orderprice-Ask)>0)
{

OrderClose(ticket,Lots,Ask,3,0);
}




return;
}
pascalboy
238
pascalboy 2014.03.05 15:24  

datetime ordertime=OrderOpenTime();
datetime orderclosetime=OrderCloseTime();
double B=orderclosetime-ordertime;
double emirsuresi;

Print(B);


At the above program at time difference part,

when printing "B" the result is very very big.

like billions numbers .

Why?

Simon Gniadkowski
Moderator
17990
Simon Gniadkowski 2014.03.05 15:38  
pascalboy:



At the above program at time difference part,

when printing "B" the result is very very big.

like billions numbers .

Why?

Your loop is wrong . . .

for(int i=OrdersTotal();i>=0;i--)
   {
   OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
   }
   //  loop has ended here  . . .


Lots=OrderLots();
ticket=OrderTicket();
int type=OrderType();
double orderprice=OrderOpenPrice();
datetime ordertime=OrderOpenTime();
datetime orderclosetime=OrderCloseTime();
double B=orderclosetime-ordertime;
double emirsuresi;

Print(B);

it should start at OrdersTotal() - 1


Is your Order closed ? if not it has a OrderCloseTime() of 0

Try this . . .

for(int i = OrdersTotal() - 1; i >= 0; i--)
   {
   if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES) )
      continue;

   Lots = OrderLots();
   ticket = OrderTicket();
   int type = OrderType();
   double orderprice = OrderOpenPrice();
   datetime ordertime = OrderOpenTime();
   datetime orderclosetime = OrderCloseTime();
   ulong B = orderclosetime - ordertime;
   double emirsuresi;

   if (orderclosetime > 0) Print("Ticket: ", ticket, "difference from OpenTime to CloseTime: ", B);   
}
 

pascalboy
238
pascalboy 2014.03.06 06:34  
Thanks
pascalboy
238
pascalboy 2014.03.06 20:15  
This time no result.
whroeder1
14203
whroeder1 2014.03.06 20:50  
RaptorUK: Is your Order closed ? if not it has a OrderCloseTime() of 0


Try this . . .

for(int i = OrdersTotal() - 1; i >= 0; i--)
   {
   if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES) )
:
   if (orderclosetime > 0
If you are reading the trades pool, ALL the orders will ALWAYS be open (or pending.)
Simon Gniadkowski
Moderator
17990
Simon Gniadkowski 2014.03.06 20:52  
WHRoeder:
If you are reading the trades pool, ALL the orders will ALWAYS be open (or pending.)

good point.
James Hodges
3053
James Hodges 2014.03.07 05:48  
pascalboy:

datetime ordertime=OrderOpenTime();
datetime orderclosetime=OrderCloseTime();
double B=orderclosetime-ordertime;
double emirsuresi;

Print(B);


At the above program at time difference part,

when printing "B" the result is very very big.

like billions numbers .

Why?


The OrderOpenTime() and OrderCloseTime() are functions that return data of the datetime type.

What this means is that the time it is returning is the number of seconds since the first second of 1970.

Which is over 1 billion 394 million.... however the difference between the open and close time should only display

the number of seconds the order was open.

However as WHRoeder pointed out....if you are selecting an order close of zero because you are selecting

an open trade from trade pool that has not closed yet. Then you are right .. it will be the open time minus zero..

a reallly big number.. If you'll use the loop that RaptorUK provided with the MODE-HISTORY change that WHRoeder

noticed instead of MODE-TRADES you should get some kind of a better result.

pascalboy
238
pascalboy 2014.03.07 20:16  
Mode history :)
whroeder1
14203
whroeder1 2014.03.07 21:15  
Jimdandy: MODE-HISTORY
pascalboy: Mode history :)
MODE_HISTORY even.
James Hodges
3053
James Hodges 2014.03.07 21:20  
LOL.. I've really got to get a new laptop ... my shift key has stopped working on one side.... I'm gonna get me one a them there apples.... I hope....
/ /12
To add comments, please log in or register