|
|||||||
| Register in Forex TSD! | |
|
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information |
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Quote:
But better is to post it betweet this sign # like this: Code:
This is the code |
|
|||
|
testing
hi
some code: Code:
void MoneyManagement()
{
int i,hstTotal=HistoryTotal();
int losses;
static double val1;
for(i=hstTotal-1;i>=0;i--)
{
//---- check selection result
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==fals e)
{
Print("Access to history failed with error (",GetLastError(),")");
break;
}
if(OrderProfit()>0){
val1 = 0;
break;
}
if(OrderProfit()<0) {
losses++;
val1 = val1 + orderProfit();
}
if(losses==2) {
lotMM = MathCeil(AccountFreeMargin() * 50 / 10000) / 10; // 50 risk :)
if (lotMM < 0.1) lotMM = Lots;
if (lotMM > 1.0) lotMM = MathCeil(lotMM);
if (lotMM > 100) lotMM = 100;
}
}
Got it - thanks - were would one find the different html tags one can use on this forum? Last edited by cardio : 01-06-2006 at 09:21 PM. |
|
||||
|
Quote:
|
|
||||
|
Hello,
I am not sure if this could be integrated into your EA, but I put a separate fonction that you can put at the end of the code and call during the main loop. Make sure you have a global variable "Magic" that you are using when placing order: ---- int Magic; ----- Also you need to set the number of pips in profit "ProfitModifySL" before you would like to set your stopLoss to the actual opening price: ---- extern double ProfitModifySL=15; // After being in 15 pips Profit Stoploss is adjusted to the opening price of the order ----- //+------------------------------------------------------------------+ //| Scan through Order and if in profit by PrmSL Modify SL | //+------------------------------------------------------------------+ void fModifySLWhenInProfit() { for (int i=0; i<OrdersTotal(); i++) { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol()==Symbol() && OrderMagicNumber()==Magic) { if (OrderType()==OP_BUY && Bid-OrderOpenPrice()>=ProfitModifySL*Point) fModifyStopLoss(OrderOpenPrice()); if (OrderType()==OP_SELL && OrderOpenPrice()-Ask>=ProfitModifySL*Point) fModifyStopLoss(OrderOpenPrice()); } } } } //+------------------------------------------------------------------+ //| Modify Stop Loss | //+------------------------------------------------------------------+ void fModifyStopLoss(double tStopLoss) { bool result = OrderModify(OrderTicket(),OrderOpenPrice(),tStopLo ss,OrderTakeProfit(),0,NULL); } Otherwise I attached to the post a simple EA that does it. Hope this help ![]() Cheers |
|
||||
|
You are welcome, also to avoid to modify your orders all the time and do it once you could change:
if (OrderType()==OP_BUY && Bid-OrderOpenPrice()>=ProfitModifySL*Point) fModifyStopLoss(OrderOpenPrice()); if (OrderType()==OP_SELL && OrderOpenPrice()-Ask>=ProfitModifySL*Point) fModifyStopLoss(OrderOpenPrice()); to if (OrderType()==OP_BUY && Bid-OrderOpenPrice()>=ProfitModifySL*Point) if (OrderStopLoss()<OrderOpenPrice()) fModifyStopLoss(OrderOpenPrice()); if (OrderType()==OP_SELL && OrderOpenPrice()-Ask>=ProfitModifySL*Point) if (OrderStopLoss()>OrderOpenPrice()) fModifyStopLoss(OrderOpenPrice()); S. |
|
||||
|
Vertical line production in mql code
Hi folks,
I am interested in an mql code set that can produce a vertical line on a chart at a selectable time. Does anything like this exist or can it be coded?? My understanding of mql codes are very minimal and I cannot code anything. The best I can do is change the colour of 'objects' and their density. My appreciation to any and all who respond and to this wonderful forum... Good trading to all....................... |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to code this? | iscuba11 | Metatrader 4 mql 4 - Development course | 1 | 08-03-2007 04:22 PM |