| New signals service! | |
|
|||||||
| 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 |
|
|
||||
|
||||
|
How about Pictures....
Here it is with ManageOrders(); disabled.... Question is why is this code opening multiple orders at the same time ? void CheckForOpen () { if (UseStoch){ double STOCHOSCMAIN = iCustom(NULL,STOCHTIME,"Zerolagstochs",0,SIGNALCAN DLE); double STOCHOSCSIGNAL = iCustom(NULL,STOCHTIME,"Zerolagstochs",1,SIGNALCAN DLE); double pSTOCHOSCMAIN = iCustom(NULL,STOCHTIME,"Zerolagstochs",0,SIGNALCAN DLE+1); double pSTOCHOSCSIGNAL = iCustom(NULL,STOCHTIME,"Zerolagstochs",1,SIGNALCAN DLE+1); if (STOCHOSCMAIN >= STOCHOSCSIGNAL && pSTOCHOSCMAIN > pSTOCHOSCSIGNAL && STOCHOSCSIGNAL < 50){ EnterOpenBuy(); } if (STOCHOSCMAIN <= STOCHOSCSIGNAL && pSTOCHOSCMAIN < pSTOCHOSCSIGNAL && STOCHOSCSIGNAL > 50){ EnterOpenSell(); } } if (UseCCI){ double CCI = iCCI(NULL,0,CciPer,PRICE_MEDIAN,SIGNALCANDLE); double CCIPrevious = iCCI(NULL,0,CciPer,PRICE_MEDIAN,SIGNALCANDLE+1); if (CCI > Cci_Level1 && CCIPrevious <= Cci_Level1){ EnterOpenBuy(); } if (CCI > Cci_Level2 && CCIPrevious <= Cci_Level2){ EnterOpenBuy(); } if (CCI > Cci_Level3 && CCIPrevious <= Cci_Level3){ EnterOpenBuy(); } if (CCI < Cci_Level1 && CCIPrevious >= (-Cci_Level1)){ EnterOpenSell(); } if (CCI < Cci_Level2 && CCIPrevious >= (-Cci_Level2)){ EnterOpenSell(); } if (CCI < Cci_Level3 && CCIPrevious >= (-Cci_Level3)){ EnterOpenSell(); } } } And here is the EnterOpen() functions... void EnterOpenBuy(){ GetTrend(); double LongLots = ((AccountFreeMargin()* AccountLeverage()* UpTrend / MarketInfo(Symbol(), MODE_LOTSIZE)) * (RiskPercent/100.0))/MaxOrders; if (LongLots < 0.1) {LongLots = 0.1;} OrderSend(Symbol(),OP_BUY,LongLots , Ask, OrderSlippage,Bid-StopLoss*Point,Ask+TakeProfit*Point, "Open Buy", Magic, 0, Green); Print ("OPEN BUY : ", OrderLots()); return (0); } void EnterOpenSell(){ GetTrend(); double ShortLots = ((AccountFreeMargin()* AccountLeverage()* DownTrend / MarketInfo(Symbol(), MODE_LOTSIZE)) * (RiskPercent/100.0))/MaxOrders; if (ShortLots < 0.1) {ShortLots = 0.1;} OrderSend(Symbol(), OP_SELL, ShortLots, Bid, OrderSlippage,Ask+StopLoss*Point,Bid-TakeProfit * Point, "Open Sell", Magic, 0, Red); Print ("OPEN SELL : ", OrderLots()); return (0); } |
|
|
||||
|
||||
|
And this is what the ManageOrders() function is doing...
Here is the Code... void ManageOrders(){ for (cnt = OrdersTotal(); cnt >= 0; cnt--) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) { if (OrderType() == OP_BUY) { if (Bid <= SL || Bid >= TP || Bid > QUICKUPPER3) { CloseOrders(); } else if (OrdersTotal() < MaxOrders && Ask >= TP - ((TakeProfit + Pips) * Point)) { EnterOpenBuy(); } } else if (OrderType() == OP_SELL) { if (Ask >= SL || Ask <= TP || Ask < QUICKLOWER3) { CloseOrders(); } else if (OrdersTotal() < MaxOrders && Bid <= TP + ((TakeProfit + Pips) * Point)) { EnterOpenSell(); } } } } return (0); } |
|
|
||||
|
||||
|
I could not post all of the indicators used in the manage order ... too many charactors.
The goal is to have ManageOrders() 1. Manage all open positions as one. cnt -- 2. If the Ask/Bid goes against you by n pips, add to the order. 3. close all OP_BUY or OP_SELL orders at the same time. seems pretty simple but it does not work....I think it has something to do with me allowing multiple trades. but then again i cannot seem to figure it out. Is there anyone here that can help? Thanks... |
|
|
||||
|
||||
|
Quote:
Why does it open more than one order per bar? |
|
|
||||
|
||||
|
Quote:
//this is pseudo code .. //find the last open order .. //loop through open orders lastOpenTime=OrderOpenTime(); //from open //loop through history lastCloseTime=OrderCloseTime(); //from History if((itime(..)-lastOpenTime)>Period()*60 && (itime(..)-lastCloseTime)>Period()*60 ) { CheckForOpen(); } at least you are trying .. that's good. regards |
|
|
|||
|
|||
|
Hey KurkaFund
Try using the "Wrap [code] tags around selected text" button. It formats your code so that it looks like . . code. Trying to read all your stuff 'left justified' is tough. Sorry I can't help more. It's tough to pick up someone's code when you are new to it and see a problem right away. Keep banging away at it, posting your thoughts, hopefully we can help you, and by doing that, help ourselves too. Tross |
| Bookmarks |
| Thread Tools | |
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Swiss Army EA (Automatic order management) | ryanklefas | Expert Advisors - Metatrader 4 | 249 | 08-29-2008 08:52 PM |