ผมลองเอาไปแปะแบบนี้ก่อน แล้วจะเขียนคำสั่งให้หยุดเทรดเพื่อรอไปเทรดครั้งต่อไปยังไงหรอครับ
รบกวนแนะนำด้วยครับ
ขอบคุณครับ
/////////////////////////////////////////////////////////////////
extern double Lots=0.5;
extern double StartHours = 15;
extern double EndHours = 17;
int start()
{
int total=OrdersTotal();
if(total==0)
if ((Hour()>StartHours)&&(Hour()<EndHours))
double closeprice;
closeprice=iClose( NULL,0,1);
{
OrderSend(Symbol(), OP_BUYSTOP, Lots, closeprice+200*Point, 3, closeprice, closeprice+400*Point, "ea", 4321, CurTime()+PERIOD_H1*60, Green);
OrderSend(Symbol(), OP_SELLSTOP, Lots, closeprice-200*Point, 3, closeprice, closeprice-400*Point, "ea", 1234, CurTime()+PERIOD_H1*60, Pink);
}
if(total==2)
{ int buy ,sell;
for(int i=0;i<total;i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderType()==OP_BUY)
{ buy=buy+1;
}
if(OrderType()==OP_SELL)
{
sell=sell+1;
}
}
if(buy==1 || sell==1)
{
for( i=0;i<total;i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderType()==OP_BUYSTOP)
{ OrderDelete( OrderTicket());
}
if(OrderType()==OP_SELLSTOP)
{
OrderDelete( OrderTicket());
}
}
}
}
{
int type;
int count=0;
int total2 = OrdersHistoryTotal();
for (int po = total2-1; po >=0; po--)
{
OrderSelect( po, SELECT_BY_POS, MODE_HISTORY );
if (OrderSymbol() == Symbol() )
{
if ( OrderType()== type )
{
if ( OrderType()== OP_BUY )
{
if ( iBarShift(Symbol(),PERIOD_H1,OrderCloseTime()) == 0 )
{
count++;
}
}
else if ( OrderType()== OP_SELL )
{
if ( iBarShift(Symbol(),PERIOD_H1,OrderCloseTime()) == 0 )
{
count++;
}
}
}
}
}
return(count);
}
}