| 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 (2) | Thread Tools | Display Modes |
|
|||
|
To CodersGuru : Need help to Close Position...
To CodersGuru : Need help to Close Position.... ( 2nd post )
Hi CodersGuru, This is the second post asking you and may be you quite busy right now. So sorry for disturbing you for a second time. First time, I am learning is EuroX2_sl, extended from 10 points 3 EA script. After did a few forward test, this EA did Open Position okay but it did not Close Position as I need to when market reverse ( after setting indicator ). Maybe, something is wrong with the code ( cos' I am not a programmer ) and I think I need your help to solve it. Could please check which part may be wrong ? Condition is : 1. OPEN BUY when indicator condition exist. ie: stochastic 2. CLOSE BUY when OPEN SELL indicator exist. ie:stochastic 3. OPEN SELL as the indicator condition ( no. 2 above ) exist. ie : stochastic 4. CLOSE SELL as the indicator condition ( no. 1 above ) exist. ie : stochastic I think OPEN position is okay but the problem is with the CLOSE POSITION as it did not CLOSE ( BUY or SELL ) even when the indicator exist. The code as I did is : -------- part of script from EuroX2_sl extended from 10 points 3 as I think for close position ------- // it is important to enter the market correctly, // but it is more important to exit it correctly... for(cnt=0;cnt<total;cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if(OrderType()<=OP_SELL && // check for opened position OrderSymbol()==Symbol()) // check for symbol { //+-------------------------------------------------------------- if(OrderType()==OP_BUY) // long position is opened { //+------------------------------------------------------------------- //+ CONDITION FOR CLOSE POSITION //+------------------------------------------------------------------- //+--------------- CLOSE BUY POSITION ---------------------------- if ( Stoch_Main_M15_Cu < Stoch_Sig_M15_Cu ) //+------------------------------------------------------------------ { OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet) ; // close position return(0); // exit } //+----------------------------------------------------------------------- // check for trailing stop if(TrailingStop>0) { if(Bid-OrderOpenPrice()>Point*TrailingStop) { if(OrderStopLoss()<Bid-Point*TrailingStop) { OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green); return(0); } } } } //+---------------CLOSE SELL POSITION -------------------------------- else // go to short position { //+ DO NOT REMOVE if(OrderType()==OP_SELL) // short position is opened { } // should it be closed? //+---------------------------------------------------------------------------- if ( Stoch_Main_M15_Cu > Stoch_Sig_M15_Cu ) //+----------------------------------------------------------------------------- { OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet) ; // close position return(0); // exit } //+---------------------------------------- // check for trailing stop if(TrailingStop>0) { if((OrderOpenPrice()-Ask)>(Point*TrailingStop)) { if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0)) { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Poi nt*TrailingStop,OrderTakeProfit(),0,Red); return(0); } } } } } } -------------------------------------------------------------- Thank you, fxgroup |
|
|||
|
Lag
Codersguru..the code you gave us for protection. I used your code exactly on your page. What happens is "you can not use this program with this account" comes up for a few seconds before "Welcome to the program" when the right account number is in the code.
Thanks Rich |
|
|||
|
Alert MTF HAS
Hi codersguru,
I found this great article "Alert Once Per Bar" and I tried to make it works with 8 MTF HAS , but unfortunately I dont know how to do it, can you please add sound alert and popout window then signal shows up. Thank you for your help! |
|
||||
|
Quote:
If they are main window then you can combine them with code but it is tricky |
![]() |
| Bookmarks |
| Tags |
| histogram, forex, ZUP_v1.mq4 |
| Thread Tools | |
| Display Modes | |
|
|
LinkBacks (?)
LinkBack to this Thread: http://www.forex-tsd.com/questions/270-ask.html
|
||||
| Posted By | For | Type | Date | |
| OzFx System:) - Page 639 | This thread | Refback | 06-21-2008 10:53 PM | |
| Forex SRDC Sidus Sibkis EA MT4 Forum OTCSmart | This thread | Refback | 12-08-2007 12:46 PM | |