Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 446

 
Forexman77:

Dear, I need some help.

I took the code for accounting, opening and closing orders from the tutorial (tradingexpert.mq4). The code is intended to work with one position. I need to have five positions.

We have slightly modified the code in the following way (changed lines in bold), so that the positions are opened in the right amount, but when we reverse, only one position is closed and the reverse one is opened right away.

How can I make it so that all positions are closed at the reversal and then only the opposite position is opened?


Make Ticket an array Ticket[5], store all 5 tickets in it. When closing, cycle through all the tickets accordingly.
 
Vinin:

You can't be considered a beginner by the level of use of the libraries. Having looked at your code, it would take me two weeks to figure it out. If not more. So I think you won't get an answer.
Vitya, there is no need to understand anything - the man wants to make global variables from one "sandbox" (EA with its libraries) visible in the other "sandbox" (compiled library). :)))
 

I am not a progamer, I am a code builder. So I built this indicator (I see that you can do a text exposition, not a file t-that's what I will do to make it easier to understand.

#property indicator_separate_window
#property indicator_buffers 1
#property  indicator_color1 Lime

//--------------------------------------------------------------------
double Buffer[];
//--------------------------------------------------------------------

int init()
{
SetIndexStyle(0,DRAW_HISTOGRAM, EMPTY, 2);
SetIndexBuffer(0,Buffer);
return(0);
}
// -------------------------------------------------------------------

int deinit()
{
return(0);
}
//--------------------------------------------------------------------

int start()
{
int StartBar = Bars - IndicatorCounted() - 1;
for(int i = StartBar; i >= 0; i--)
{
if(TimeDayOfWeek(Time[i]) < TimeDayOfWeek(Time[i+1]))
Buffer[i] = 0;
else
Buffer[i] = Buffer[i+1];
if(Close[i]>Close[i+1]&&Close[i+1]>=Close[i+2]){//если текущее и преддыдущее движение растут
Buffer[i] += NormalizeDouble((Close[i] - Close[i+1])/Point,0);}
if(Close[i]<Close[i+1]&&Close[i+1]<Close[i+2]){//если текущее и преддыдущее движение падают
Buffer[i] += NormalizeDouble((Close[i+1] - Close[i])/Point,0);}
if(Close[i]>Close[i+1]&&Close[i+1]<Close[i+2]){//если текущее лвижение растет а предыдущее падает
Buffer[i] += NormalizeDouble((Close[i+1] - Close[i])/Point,0);}
if(Close[i]<Close[i+1]&&Close[i+1]>=Close[i+2]){//если текущее движение падает а предыдущее растет
Buffer[i] += NormalizeDouble((Close[i] - Close[i+1])/Point,0);}
}
return(0);
}
//--------------------------------------------------------------------

It shows the sum of points and the dynamics of their summation during the week - at smaller timeframes, if the previous movement continues from Close[i+2] to Close[i+1] the current movement Close[i] is added, if against - is subtracted. I should prescribe it so the program should see Friday's close- instead of close the bar-. I know it can be done with DayOfWeek and 5 (Friday's number), but how can I do it practically? Help.

 
TarasBY:
Vitya, nothing needs to be sorted out here - the person wants global variables from one sandbox (EA with its libraries) to be visible in another sandbox (compiled library). :)))

Igor, a little bit wrong! In the "sandbox" (compiled library) only functions, and all variables are declared in the inluder. And the variables which are declared in the inluder (include file) should be visible in the owl, because I have inserted the inluder directly into the owl. Do you disagree?
 
Vitek2010:

I am not a progamer, I am a code builder. So I built this indicator (I see that you can do a text exposition, not a file t-that's what I will do to make it easier to understand.

It shows the sum of points and the dynamics of their summation during the week - at smaller timeframes, if the previous movement continues from Close[i+2] to Close[i+1] the current movement Close[i] is added, if against - is subtracted. I should prescribe it so the program should see Friday's close- instead of close the bar-. I know it can be done with DayOfWeek and 5 (Friday's number), but how can I do it practically? Help.


Will it suit?

//+------------------------------------------------------------------+
//|                                                    Vitek2010.mq4 |
//|                                            Copyright 2014, Vinin |
//|                                                    vinin@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, Vinin"
#property link      "vinin@mail.ru"
#property version   "1.00"
#property indicator_separate_window
#property indicator_buffers 1
#property  indicator_color1 Lime

//--------------------------------------------------------------------
double Buffer[];
//--------------------------------------------------------------------

int init()
  {
   SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY,2);
   SetIndexBuffer(0,Buffer);
   return(0);
  }
// -------------------------------------------------------------------

int deinit()
  {
   return(0);
  }
//--------------------------------------------------------------------

int start()
  {
   int StartBar=Bars-IndicatorCounted()-1;
   if (StartBar>1) StartBar--;
   
   for(int i=StartBar; i>=0; i--)
     {
      Buffer[i]=Buffer[i+1];
      int pos0=iBarShift(NULL, PERIOD_W1, Time[i]);
      int pos1=iBarShift(NULL, PERIOD_W1, Time[i+1]);
      if (pos0==pos1) 
         Buffer[i]+=MathAbs(Close[i]-Close[i+1]);
      else 
         Buffer[i]=MathAbs(Close[i]-Close[i+1]);
     }
   return(0);
  }
//--------------------------------------------------------------------
 
hoz:

Igor, a little wrong! Only functions are in the sandbox (compiled library), and all variables are declared in the inluder. And the variables which are declared in the inluder (include file) should be visible in the owl, because I have inserted the inluder directly into the owl. Don't you agree?
then what does the reference to the compiled library have to do with it?
 
Vinin:


Is that all right?

No it does not. I will explain - your forum is like a hope for the last competent stronghold of prog. and insertion of size - that's how the writing PERIOD_W1 sees itbut neither use of size nor use of fixed reference points as dates get any desired effect. I posted a specific question about Friday - by the way your code doesn't compile because it says 'version' - unknown property, so if you don't know how to put DayOfWeek and 5 (Friday's number) into the code other options won't help .
 
Vitek2010:
No it does not. I will explain - your forum is like a hope for the last competent stronghold of prog. and insertion of size - that's how the writing PERIOD_W1 sees itbut neither use of size nor use of fixed datums as dates get any desired effect. I posted a specific question about Friday - by the way your code doesn't compile because it says 'version' - unknown property, so if you don't know how to put DayOfWeek and 5 (Friday's number) into the code other options won't help .

TimeDayOfWeek(Time[i]) does not specify Time[i] but a specific date in the format D'2014.01.27'.

And if you need to determine what day it is, just call DayOfWeek().

 
evillive:

In TimeDayOfWeek(Time[i]) you do not set Time[i] but a specific date in the format D'2014.01.27'.

And if you want to determine what day it is, just call DayOfWeek().

Where did you read about TimeDayOfWeek () (in the example)? :)))
 
TarasBY:
And where did you read that about TimeDayOfWeek () (in the example)? :)))

On the right ;)

I was wrong, I can set it in Time[] form too, but in the example it is different and more convenient ))))

Reason: