| 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 |
|
||||
|
Quote:
2) Now import the settings into your ea: Try this in your ea: Butter0=iCustom(NULL,0,"Put full name of indicator file Butter here in quotations", minus .mq4),A,B,F,G,0,0); //This should cover buffer 0. 3) Butter1 =iCustom(NULL,0,"Put full name of indicator file Butter here in quotations", minus .mq4),A,B,F,G,1,0); //This should cover buffer 1. 4) Butter2 =iCustom(NULL,0,"Put full name of indicator file Butter here in quotations", minus .mq4),A,B,F,G,2,0); //This should cover buffer 2. 5) Type this then: Print(" ",TradeLast," Butter0= ",Butter0," | ", "Butter1= ",Butter1," | ", "Butter2= ",Butter2); 6) Declare the values at the beginning of the program: double Butter0=0,Butter1=0,Butter2=0; //Or use integer instead of double depending on the scale of the indicator, such as 0-100, versus 0.00 to 100.00. 7) Compile the program and see if it compiles. If it does, place the expert over the currency plot and then look in the experts folder below the graphs under the currency you are viewing and see if the buffers being printed out show the same values that the indicator shows on the graph. If it does you can determine which buffers you will need to use in your ea. 8) Let's say Butter0 (Buffer0) matches the indicator values. Next is to use them in a logic buy or sell statement. 9) Reference Butter0 (Current Bar): Butter0=iCustom(NULL,0,"Put full name of indicator file Butter here in quotations", minus .mq4),A,B,F,G,0,0); And also the bar one back: Butter0_1Back=iCustom(NULL,0,"Put full name of indicator file Butter here in quotations", minus .mq4),A,B,F,G,0,1); Note: Use this if you want to check to see if the indicator is rising like a Moving average: if(Butter0>Butter0_1Back) BuyValue=1; //MA is rising. Note: If Buffer 0 = Up buffer, and Buffer 1 = Down buffer you can write a statement for a buy: If (Butter0>Butter1) BuyValue=1;//Buffer 0 is positive like the indicator value, Buffer 1 is probably 0.00 value until Butter0 goes negative past 0. I hope I did not confuse you. Work with it to see what you see. Dave <><<< Note: I just looked at the indicator, it is a moving average, so code it in the ea as a moving average using the example I showed for a moving average. Last edited by 1Dave7; 08-26-2007 at 03:29 AM. |
|
|||
|
checking for open positions within a range
I'm trying to check for open positions within x pips, if no position is open it will open one. It doesn't work and just opens positions continuously, can anyone help?
if(buyingPosition) { weBeBuying = true; totalorders = OrdersTotal(); for(i=0;i<totalorders;i++) { OrderSelect(i,SELECT_BY_POS); if((OrderSymbol()==Symbol()) && (OrderMagicNumber()==magicNumber)) { type = OrderType(); if((type == OP_BUY) || (type == OP_BUYLIMIT)) { if(((Bid+spread) - OrderOpenPrice()) > -0.0013) weBeBuying = false; } } } } if(weBeBuying==true) OrderSend(Symbol(),OP_BUY,lots,Bid+spread,slippage ,0,0,NULL,magicNumber,0,Green); Last edited by sbguy; 08-27-2007 at 11:48 AM. |
|
|||
|
Sere you can post your questions related to MQL4, and I'll do my best to answer them
for error code.
I have just returned account to me that on all my expert, I have an error code "OrderModify error 1", even with an expert like that of Coders Guru, below, why? Thanks ! //+------------------------------------------------------------------+ //| PriceCross.mq4 | //| Coders Guru | //| http://www.forex-tsd.com | //+------------------------------------------------------------------+ #property copyright "Coders Guru" #property link "http://www.forex-tsd.com" //---- Includes #include <stdlib.mqh> //---- Trades limits extern double TakeProfit = 200; extern double TrailingStop = 50; extern double StopLoss = 50; extern double Lots = 0.1; extern int Slippage = 5; //--- External options extern int CurrentBar = 1; extern int HedgeLevel = 6; extern double Expiration = 7200; extern int Size = 4; extern int Step = 1; extern bool UseClose = true; //--- Indicators settings extern int MaMode = 3; extern int MaPeriod = 24; //--- Global variables int MagicNumber = 101090; string ExpertComment = "PriceCross"; bool LimitPairs = true; bool LimitFrame = true; int TimeFrame = 60; string LP[] = {"EURUSD","USDCHF","GBPUSD","USDJPY"}; // add/remove the paris you want to limit. bool Optimize = true; int NumberOfTries = 5; //+------------------------------------------------------------------ int init() { return(0); } int deinit() { return(0); } //+------------------------------------------------------------------ bool isNewSymbol(string current_symbol) { //loop through all the opened order and compare the symbols int total = OrdersTotal(); for(int cnt = 0 ; cnt < total ; cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); string selected_symbol = OrderSymbol(); if (current_symbol == selected_symbol && OrderMagicNumber()==MagicNumber) return (False); } return (True); } //+------------------------------------------------------------------+ int start() { int cnt, ticket, total,n; double trend ; if(Bars<100) {Print("bars less than 100"); return(0);} if(LimitFrame) { if(Period()!=TimeFrame) {Print("This EA is not working with this TimeFrame!"); return(0);} } if(LimitPairs) { if(AllowedPair(Symbol()) == false) {Print("This EA is not working with this Currency!"); return(0);} } trend = iMA(NULL,0,MaPeriod,0,MaMode,PRICE_CLOSE,CurrentBa r); //--- Trading conditions bool BuyCondition = false , SellCondition = false , CloseBuyCondition = false , CloseSellCondition = false ; if (Open[1]<trend && Close[1]>trend) BuyCondition = true; if (Open[1]>trend && Close[1]<trend) SellCondition = true; if (Open[1]>trend && Close[1]<trend) CloseBuyCondition = true; if (Open[1]<trend && Close[1]>trend) CloseSellCondition = true; total = OrdersTotal(); if(total < 1 || isNewSymbol(Symbol())) { if(BuyCondition) //<-- BUY condition { ticket = OpenOrder(OP_BUY); //<-- Open BUY order CheckError(ticket,"BUY"); for(n=0 ; n< Size ; n++) { ticket = OpenPendingOrder(OP_BUYSTOP,Lots,HedgeLevel+(n*Ste p+1),Slippage,StopLoss,TakeProfit,ExpertComment,Ma gicNumber,CurTime() + Expiration); } return(0); } if(SellCondition) //<-- SELL condition { ticket = OpenOrder(OP_SELL); //<-- Open SELL order CheckError(ticket,"SELL"); for(n=0 ; n < Size ; n++) { ticket = OpenPendingOrder(OP_SELLSTOP,Lots,HedgeLevel+(n*St ep+1),Slippage,StopLoss,TakeProfit,ExpertComment,M agicNumber,CurTime() + Expiration); } return(0); } return(0); } for(cnt=0;cnt<total;cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if(OrderType()<=OP_SELL && OrderSymbol()==Symbol()) { if(OrderType()==OP_BUY) //<-- Long position is opened { if(UseClose) { if(CloseBuyCondition) //<-- Close the order and exit! { CloseOrder(OrderType()); return(0); } } TrailOrder(OrderType()); return(0); //<-- Trailling the order } if(OrderType()==OP_SELL) //<-- Go to short position { if(UseClose) { if(CloseSellCondition) //<-- Close the order and exit! { CloseOrder(OP_SELL); return(0); } } TrailOrder(OrderType()); return(0); //<-- Trailling the order } } } return(0); } //+------------------------------------------------------------------+ .... |
|
|||
|
Hi,
Is there anyway we can know that an order is already closed? The illustration is like this : I open 2 pending orders. open #182 buy limit 0.17 EURUSD at 1.3005 sl: 1.2970 tp: 1.3013 open #183 buy limit 0.17 EURUSD at 1.3000 sl: 1.2968 tp: 1.3011 then order #182, buy 0.17 EURUSD is opened at 1.3005 take profit #182 at 1.3013 (1.3013 / 1.3015) i want to delete order #183 after order #182 is closed. The trigger is if order #182 closed then order #183 will be deleted. Cheers |
|
|||
|
To CodersGuru : need help about 10 points 3 EA....
Hi CodersGuru,
I am new to forex trade and new to this forum too. 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 well but it did not Close Position well as I need to when market reverse. 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 OrderType()<=OP_BUY && OrderType()>=OP_SELL && OrderType()>=OP_BUY && 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 Last edited by fxgroup; 08-29-2007 at 10:01 AM. Reason: change a few words.... name of indicator |
|
||||
|
Reading data from another currency pair window
My EA is on "GBPJPY" window, but I need to find ObjectDescription() form another window, say "USDJPY". (Unfortunately, it's a Pivot indicator which doeasn't return values from iCustom())
Anybody knows the way to refer to another (not current) pair window to be able to use functions like ObjectDescription() on it? Or MQ4 doesn't allow it? Thank you euro Last edited by european; 08-29-2007 at 05:50 PM. |
|
||||
|
PHP Code:
Please review. Thanks for your help! Dave |
|
||||
|
Try this code:
PHP Code:
Quote:
|
![]() |
| 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 | |