[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 196

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
buy
int start()
{
OrderSend(Symbol(),OP_BUYSTOP,0.01,Ask+20*Point,3,Bid- 50*Point,Bid+50*Point);
return(0);
}
help please...
Please don't spread heresy in public. Go nerd out somewhere else, there's plenty to go around...
Thank you, I was just coming to consult with you.
1. Well here double has only been applied to add minutes and hours. so that reference points can be designated as HH.MM (e.g. 16. 23).
2. Looked at the last pages, there is of course about datetime, but not exactly the same. They simply output in HH.MM format the time of the last order.
Not a good search. Page 190, time of post 18.09.2011 23:03
Hello.
Please help me to correct the code.
Both lines below are glitchy.
Thanks in advance.
The program itself:
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) == true)
MODE_HISTORY would make more sense
< 0.6, or something like that. The remainder of division is always less than one :)
Why is that?) The remainder of 12 divided by 10 = 2.
What if there are a lot of variables like that?
Is that too bad, or will it work?
And another small question, if say I set an interval (e.g. 16.00-16.03) for a condition to be executed. How to make it execute it only once, despite the arrival of new ticks???
That works. And to do it only once, enter an additional service variable, something like this
Why is that?) The remainder of 12 divided by 10 = 2.
This will work. And to do it once, enter an additional service variable, like this:
Yeah, it's a little glitchy :)
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) == true)
MODE_HISTORY would make more sense.
I couldn't agree more. At night, my brain slows down.
However, even with this correction I noticed that the above glitch (confusion between magic variable and number) in the script occurs when you redeclare int MAGIC; variable (this very magic is locked for some reason). If you remove int MAGIC; (extern int MAGIC = 1; remains), everything works like clockwork.
A logical question why do I need it? You may remove int MAGIC; and live your life in peace. BUT.
I need to put this code into a library. But if I do not define int MAGIC; there will be an error.
That is what I think I should do. Will it all work in my Expert Advisor? Why does this int MAGIC; ?
The script below:
Comrades, help please... I wrote a simple code, but when compiling it says that the brackets are out of balance, but I've already counted them 300 times - everything is in place
The idea is very simple - if MACD has been above (or below) 0 for 7 minutes or less, the position is opened
//+------------------------------------------------------------------+
//| MACD ^^^.mq4 |
//| Copyright © 2011, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, MetaQuotes Software Corp.
#property link "http://www.metaquotes.net"
extern int TP = 100;
extern int TS = 100;
extern double lots = 0.1;
int slip = 3;
int Magic = 1;
//+------------------------------------------------------------------+
//| expert initialisation function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialisation function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
int total,ticket; //declared total and ticket
int signal = signal_MACD(); // signal_MACD passes value to signal
AnalyzeSignal(signal); //analyze signal
int MACD[8] = {0,1,2,3,4,5,6,7}; //create a one-dimensional MACD array
MACD[0] = iMACD(Symbol(),1,5,34,5,PRICE_CLOSE,MODE_MAIN,7)
MACD[1] = iMACD(Symbol(),1,5,34,5,PRICE_CLOSE,MODE_MAIN,6);
MACD[2] = iMACD(Symbol(),1,5,34,5,PRICE_CLOSE,MODE_MAIN,5);
MACD[3] = iMACD(Symbol(),1,5,34,5,PRICE_CLOSE,MODE_MAIN,4);
MACD[4] = iMACD(Symbol(),1,5,34,5,PRICE_CLOSE,MODE_MAIN,3);
MACD[5] = iMACD(Symbol(),1,5,34,5,PRICE_CLOSE,MODE_MAIN,2);
MACD[6] = iMACD(Symbol(),1,5,34,5,PRICE_CLOSE,MODE_MAIN,1);
MACD[7] = iMACD(Symbol(),1,5,34,5,PRICE_CLOSE,MODE_MAIN,0);
total = OrdersTotal(); //total counts orders
int signal_MACD() //calculate MACD signal
{
if(total<1) //if the orders are less than 1, consider the conditions
{
if(MACD[0]<0)
{
if(MACD[1]>0)
{
if(MACD[2]>0)
{
{ if(MACD[3]>0)
{
{ if(MACD[4]>0)
{
{ if(MACD[5]>0)
{
{ if(MACD[6]>0)
{
{ if(MACD[7]<0)
{
return(-100);
}
}
}
}
}
}
}
}
if(MACD[0]>0)
{
if(MACD[1]<0)
{
if(MACD[2]<0)
{
{ if(MACD[3]<0)
{
{ if(MACD[4]<0)
{
{ if(MACD[5]<0)
{
{ if(MACD[6]<0)
{
if(MACD[7]>0)
{
return(100);
}
}
}
}
}
}
}
}
}
}
void AnalyzeSignal(int signal)
{
if(signal == 100)
{
ticket = OrderSend(Symbol(),OP_BUY,Ask,slip,Bid-TS*Point,Bid+TP*Point, "buy",Magic,0,Green);
if(ticket>0)
{
OrderSelect(ticket,SELECT_BY_TICKET;)
Print("opened for buy at price:" OrderOpenPrice());
}
else
{
Print("opened failed due to:" GetLastError());
return(0);
}
}
if(signal == -100)
{
ticket = OrderSend(Symbol(),OP_SELL,Bid,slip,Ask+TS*Point,Ask-TP*Point, "Sell",Magic,0,Green);
if(ticket>0)
{
OrderSelect(ticket,SELECT_BY_TICKET);
Print("opened for sale at price:" OrderOpenPrice());
}
else
{
Print("opened failed due to:" GetLastError());
return(0);
}
}
}
//----
return(0);
}
//+------------------------------------------------------------------+