Serving Traders Since 2005
|
|
|
|||||||
| MetaTrader Expert Advisors Post and discuss the MetaTrader expert advisors here. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
||||
|
Quote:
__________________
Please, read the Forum Rules and the Signature Rules to avoid termination of your account. |
|
||||
|
It's MetaTrader 4 from Alpari.
__________________
Please, read the Forum Rules and the Signature Rules to avoid termination of your account. |
|
||||
|
TKS!
another problem:I wanna add Trailing stop for my code as follow: void TS(double ts=550) { bool res = false; int total = OrdersTotal(); for(int i = 0;i<total;i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) ==false) continue; if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGICMA) { if( OrderType()==OP_BUY && Bid-OrderOpenPrice()>Point*ts && OrderStopLoss()<Bid-Point*ts)//OrderOpenPrice() - OffsetPips * Point > OrderStopLoss()) OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*ts,OrderTakeProfit(),0,Blue); if( OrderType()==OP_SELL && OrderOpenPrice()-Ask>OrderStopLoss()&& OrderStopLoss()<Point*ts-Ask) //OrderOpenPrice() + OffsetPips * Point < OrderStopLoss() OrderModify(OrderTicket(),OrderOpenPrice(),Point*t s-Ask,OrderTakeProfit(),0,Yellow); } } } and I insert TS() into my open order condtion code,but I found it couldn't make effect.The whole frame is the same as the add.MQ4 ,thd digits is 5. |
|
||||
|
What do you mean by "couldn't make effect"? Did you see any errors in the Journal or Experts tab of MT4?
BTW, it's always better to use brackets around separate conditions inside one "if". E.g.: if ((OrderType()==OP_BUY) && (Bid-OrderOpenPrice()>Point*ts) && (OrderStopLoss()<Bid-Point*ts))
__________________
Please, read the Forum Rules and the Signature Rules to avoid termination of your account. |
|
||||
|
Quote:
It seems this is connected with the code if(CalculateCurrentOrders(Symbol())<1) when it is modified with“<2”,TS() could takes effect(sorry,not make effect ). however,under "<2" ,I found the the first open condition as follow: if (m1<m3-0.0003) { ticket1=OrderSend(Symbol(),OP_SELL,LotsOptimized() ,Bid,5,Ask+105*Point,0,"SELL#1",MAGICMA,0,Red); return; } often would open 2 orders,but the second open condition as follow: if (m1<m4-0.0005) { ticket2=OrderSend(Symbol(),OP_SELL,LotsOptimized() ,Bid,5,Ask+105*Point,0,"SELL#2",MAGICMA,0,Green); return; } often could't open any order. I wanna the code on the basis of the first conditon could open 1 order, then, if meet the second condition would add another order. I have tried to nest them,but failed. could you help me again? |
|
||||
|
Use the first open condition with && (CalculateCurrentOrders(Symbol())<1) and the second open condition with && (CalculateCurrentOrders(Symbol())<2).
__________________
Please, read the Forum Rules and the Signature Rules to avoid termination of your account. |
|
||||
|
is modify like this?
if(CalculateCurrentOrders(Symbol())<1&&(m1<m3-0.0003)) {ticket1=OrderSend(Symbol(),OP_SELL,LotsOptimized( ),Bid,5,Ask+105*Point,0,"SELL#1",MAGICMA,0,Red); return; } if(CalculateCurrentOrders(Symbol())<2&&(m1<m4-0.0005)) {ticket2=OrderSend(Symbol(),OP_SELL,LotsOptimized( ),Bid,5,Ask+105*Point,0,"SELL#2",MAGICMA,0,Green); return; } now the second condtion will open 2 orders,but the first will none. My strategy is follow trend mode.Although there are 2 open condition,when meet the second contion,the first order should be profit. but I donn't know how to nest them to when the 1 order profit meet some points,the 2 will open.but if the 1's profit (even loss)couldn't meet this point,the 2 should not be opened.This makes an add opening strategy. Last edited by univetsity; 9th April 2011 at 15:55. |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Genetic Algorithm for EA, how? | lumanauw | MetaTrader Expert Advisors | 5 | 30th June 2011 07:51 |
| MDT's Daily Forex Analysis and FX-Market Algorithm | mdtforex | Advertisements | 12 | 11th March 2009 07:45 |