| 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:
|
|
|||
|
Which programming luaguage shall I learn?
Quote:
Dear codersguru, If I wish to learn to write MQL4 codes, which programming language shall I learn? Visual basic or C++? Thank your for your answer.
__________________
~NoVenture No Gain~ |
|
||||
|
More help please
Hello,
I'm back for more help. I've been reading and looking at many other EA's to try to figure it out but I still can't get it to work properly. What I am trying to do is place two orders. 1) Sell 0.1 lot once price retraces by Ret1 (75 pips) with TP1 (75) and SL1 (150) 2) Sell 0.2 lot once price retraces by Ret2 (150 pips) with TP1 (75) and SL1 (75) In the long term, I want to get a buy order like above to be placed based on direction of trend. I haven't yet determined which indicator I will use to determine trend yet but I will get there at some point. The following is what I currently have. It seems to place the first order properly but the second one never gets triggered. Any help will be highly appreciated. extern string Expert_Name = "Albatross v1"; extern int MagicNumber = 757575; extern int Slippage = 3.0; //---- input parameters extern double TP1=75.0; extern double TP2=75.0; extern double Ret1=75.0; extern double Ret2=150.0; extern double SL1=150.0; extern double SL2=75.0; extern double Lots=0.1; double CurrentLow=1000; //double CurrentHigh=0; int OpenOrders=0,cnt=0; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ //int init() // { //---- indicators //---- // return(0); // } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ // int deinit() // { //---- TODO: add your code here //---- // return(0); //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ // int start() // { //---- TODO: add your code here //---- // return(0); // } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Check Open Position Controls | //+------------------------------------------------------------------+ int CheckOpenTrades() { int cnt; int NumTrades; // Number of buy and sell trades in this symbol NumTrades = 0; for(cnt=OrdersTotal()-1;cnt>=0;cnt--) { OrderSelect (cnt, SELECT_BY_POS, MODE_TRADES); if ( OrderSymbol() != Symbol()) continue; if ( OrderMagicNumber() != MagicNumber) continue; if(OrderType() == OP_BUY ) NumTrades++; if(OrderType() == OP_SELL ) NumTrades++; } return (NumTrades); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { int cnt, ticket, total; double TP; if(Bars<100) { Print("bars less than 100"); return(0); } total = CheckOpenTrades(); if(total < 1) { if(Bid < CurrentLow) CurrentLow = Bid; if(Bid >= CurrentLow+(Point*Ret1)) OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+(SL1*Poi nt),Bid-(TP1*Point),"Albatross_v1",MagicNumber,0,Green); } if(total < 2) { if(Bid >= CurrentLow+(Point*Ret2)) OrderSend(Symbol(),OP_SELL,Lots*2,Bid+(Point*Ret2) ,3,Bid+(SL2*Point),Bid-(TP2*Point),"Albatross_v1",MagicNumber,0,Green); return(0); } } //+------------------------------------------------------------------+ |
|
||||
|
Hello All, I am a coder and been coding for long time in C++ but my knowledege of FX and MQL4 is very basic. I am going thorugh an EA that someone wrote and trying to understand the code...
can you please explain me in simple english that what is SHIFT parameter in iMA method? double iMA(string symbol, int timeframe, int period, int ma_shift, int ma_method, int applied_price, int shift) according to MT4 help, its "Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago)." - what is indicator buffer??? he's also doing the following... PHP Code:
your answer will be highly appritiated. please help. |
|
|||
|
time calculation
Hi,
I've been working on a place pending order script but can't set the expiry time based on my entered time i.e if I want the order to expire at 15:30 I need to calculate distance between curr time and expiry time, this will give me a vlaue which is time to expire. I've asked for the following values extern int To_Hour = 15; extern int To_Min = 30; and used the following code to get the correct time distance but it doesn't work. PHP Code:
Thanks in advance for help with this, Kev |
|
||||
|
Getting closer
I am getting closer with my coding but there is still a couple of errors.
After the first two orders are placed, it does not reset itselt to start over with a new CurrentLow and recalculate the retracements from there. Can someone help me figure out what I'm doing wrong. I have been trying a variety of things but none seem to make it work properly. Attached is the cord: Code:
//+------------------------------------------------------------------+
//| Bruno test1.mq4 |
//| Copyright © 2007, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, Putz Canada Corp"
#property link "http://www.Putzfx,com"
extern string Expert_Name = "Albatross v1";
extern int MagicNumber = 757575;
extern int Slippage = 3.0;
//---- input parameters
extern double TP1=75;
extern double SL1=150;
extern double Ret1=75;
extern double TP2=75;
extern double SL2=75;
extern double Ret2=150;
extern double Lots=0.1;
double CurrentLow=1000;
double CurrentHigh;
int OpenOrders=0,cnt=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
//int init()
// {
//---- indicators
//----
// return(0);
// }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
// int deinit()
// {
//---- TODO: add your code here
//----
// return(0);
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
// int start()
// {
//---- TODO: add your code here
//----
// return(0);
// }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Check Open Position Controls |
//+------------------------------------------------------------------+
int CheckOpenTrades()
{
int cnt;
int NumTrades; // Number of buy and sell trades in this symbol
NumTrades = 0;
for(cnt=OrdersTotal()-1;cnt>=0;cnt--)
{
OrderSelect (cnt, SELECT_BY_POS, MODE_TRADES);
if ( OrderSymbol() != Symbol()) continue;
if ( OrderMagicNumber() != MagicNumber) continue;
if(OrderType() == OP_BUY ) NumTrades++;
if(OrderType() == OP_SELL ) NumTrades++;
}
return (NumTrades);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
int cnt, ticket, total;
double TP;
if(Bars<100)
{
Print("bars less than 100");
return(0);
}
total = CheckOpenTrades();
if(Bid < CurrentLow) CurrentLow = Bid;
{
if(total < 1)
{
if(Bid >= CurrentLow + (Point*Ret1))
OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+(SL1*Point),Bid-(TP1*Point),"Albatross_v1",MagicNumber,0,Green);
return(0);
}
if(total < 2)
{
if(Bid >= CurrentLow+(Point*Ret2))
OrderSend(Symbol(),OP_SELL,Lots*2,Bid,3,Bid+(SL2*Point),Bid-(TP2*Point),"Albatross_v1",MagicNumber,0,Green);
total = 0;
return(0);
}
}
}
//+------------------------------------------------------------------+
|
|
|||
|
if(Bid >= CurrentLow+(Point*Ret2))
OrderSend(Symbol(),OP_SELL,Lots*2,Bid,3,Bid+(SL2*P oint),Bid-(TP2*Point),"Albatross_v1",MagicNumber,0,Green); total = 0; return(0); total = 0 doesn't have sense, try CurrentLow = 1000 instead. But it depends of what you want to do: may be you want to restart once both orders are closed, not immediately after the second one is open ? Also, return(0) is not needed here, and you have to delete the empty ini(), deinit() and start() function : you cannot have two functions with the same name; you have mixed a template to build an indicator with one to build an EA. |
![]() |
| Bookmarks |
| Tags |
| histogram |
| 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 09:53 PM | |
| Forex SRDC Sidus Sibkis EA MT4 Forum OTCSmart | This thread | Refback | 12-08-2007 11:46 AM | |