النتائج 1 إلى 6 من 6
الموضوع: س سؤال محتاج الى ج جواب
- 08-06-2011, 09:37 PM #1
س سؤال محتاج الى ج جواب
السلام عليكم ورحمة الله وبركاته
سؤال حول اذا كان ممكن اخفاء ملاحقة الربح
اللى اعرفه ممكن اخفاء وقف الخساره لاكن هل يشمل ملاحة الربح
بمعنى يعمل ملاحقة الربح ولاكن يكون مخفى وعند وصول السعر وقف الخساره يغلق الصفقه
- 08-06-2011, 10:09 PM #2
example code
كود PHP:extern bool use_hidden_stop_loss = False;
extern int hidden_sl = 10;
extern bool use_hidden_take_profit = False;
extern int hidden_tp = 10;
//put before init
void hidden_take_profit()
{
int totalorders = OrdersTotal();
for(int i=totalorders-1;i>=0;i--)
{
OrderSelect(i, SELECT_BY_POS);
bool result = false;
if ( OrderSymbol()==Symbol() )
{
if (OrderType() == OP_BUY && OrderOpenPrice()+hidden_tp*Point<=Bid ) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );
if (OrderType() == OP_SELL && OrderOpenPrice()-hidden_tp*Point>=Ask ) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red );
}
}
return;
}
void hidden_stop_loss()
{
int totalorders = OrdersTotal();
for(int i=totalorders-1;i>=0;i--)
{
OrderSelect(i, SELECT_BY_POS);
bool result = false;
if ( OrderSymbol()==Symbol() )
{
if (OrderType() == OP_BUY && OrderOpenPrice()-hidden_sl*Point>=Bid ) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );
if (OrderType() == OP_SELL && OrderOpenPrice()+hidden_sl*Point<=Ask ) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red );
}
}
return;
}
// put after start
if (use_hidden_stop_loss) hidden_stop_loss();
if (use_hidden_take_profit) hidden_take_profit();
- 08-06-2011, 10:29 PM #3
hidden sl tp ea test
- 08-06-2011, 10:29 PM #4
- 08-06-2011, 10:46 PM #5كود PHP:
//+-------------------------------------------------------------------------------------------+
extern bool use_hidden_stop_loss = true;
extern int hidden_sl = 35;
extern bool use_hidden_take_profit = true;
extern int hidden_tp = 100;
extern bool ProfitTrailing = True;
extern int TrailingStop = 30;
extern int TrailingStep = 15;
extern bool UseSound = False;
//+-------------------------------------------------------------------------------------------+
void hidden_take_profit()
{
int totalorders = OrdersTotal();
for(int i=totalorders-1;i>=0;i--)
{
OrderSelect(i, SELECT_BY_POS);
bool result = false;
if ( OrderSymbol()==Symbol() )
{
if (OrderType() == OP_BUY && OrderOpenPrice()+hidden_tp*Point<=Bid ) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );
if (OrderType() == OP_SELL && OrderOpenPrice()-hidden_tp*Point>=Ask ) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red );
}
}
return;
}
//+-------------------------------------------------------------------------------------------+
void hidden_stop_loss()
{
int totalorders = OrdersTotal();
for(int i=totalorders-1;i>=0;i--)
{
OrderSelect(i, SELECT_BY_POS);
bool result = false;
if ( OrderSymbol()==Symbol() )
{
if (OrderType() == OP_BUY && OrderOpenPrice()-hidden_sl*Point>=Bid ) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );
if (OrderType() == OP_SELL && OrderOpenPrice()+hidden_sl*Point<=Ask ) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red );
}
}
return;
}
//+-------------------------------------------------------------------------------------------+
//| expert initialization function |
//+-------------------------------------------------------------------------------------------+
//+-------------------------------------------------------------------------------------------+
//| expert deinitialization function |
//+-------------------------------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+-------------------------------------------------------------------------------------------+
//| expert start function |
//+-------------------------------------------------------------------------------------------+
void start() {
for (int i=0; i<OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
TrailingPositions();
//----
if (use_hidden_stop_loss) hidden_stop_loss();
if (use_hidden_take_profit) hidden_take_profit();
//----
}
}
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void TrailingPositions() {
double pBid, pAsk, pp;
pp = MarketInfo(OrderSymbol(), MODE_POINT);
if (OrderType()==OP_BUY) {
pBid = MarketInfo(OrderSymbol(), MODE_BID);
if (!ProfitTrailing || (pBid-OrderOpenPrice())>TrailingStop*pp) {
if (OrderStopLoss()<pBid-(TrailingStop+TrailingStep-1)*pp) {
ModifyStopLoss(pBid-TrailingStop*pp);
return;
}
}
}
if (OrderType()==OP_SELL) {
pAsk = MarketInfo(OrderSymbol(), MODE_ASK);
if (!ProfitTrailing || OrderOpenPrice()-pAsk>TrailingStop*pp) {
if (OrderStopLoss()>pAsk+(TrailingStop+TrailingStep-1)*pp || OrderStopLoss()==0) {
ModifyStopLoss(pAsk+TrailingStop*pp);
return;
}
}
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void ModifyStopLoss(double ldStopLoss) {
bool fm;
fm=OrderModify(OrderTicket(),OrderOpenPrice(),ldStopLoss,OrderTakeProfit(),0,CLR_NONE);
}
//+------------------------------------------------------------------+
//+-------------------------------------------------------------------------------------------+
- 08-06-2011, 10:54 PM #6