[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 37

 

Here is everything that is defined in the indicator.

#property indicator_buffers 8 // Number of buffers
SetIndexBuffer(1,Set_SL); // assignment of the array
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1); // Line style

You don't need to define the SIZE for the indicator buffer?!

 
Good evening. Please advise - in my Expert Advisor, after the successful closing of a profitable trade, a position is reopened in the same direction as the previous trade (of course, it becomes unprofitable in the future). How can I prohibit reopening of such incorrect trades?
 
xruss >> :
Good evening. Please advise - in my Expert Advisor, after a successful closing of a profitable trade, a position is reopened in the same direction as the previous trade (of course, it becomes unprofitable in the future). How can I prohibit reopening such wrong trades?

Remove the condition on which your trades are opened this way, and insert the condition as you would like them to be opened.

 
Vinin >> :

And the size of the array would be a good starting point.

Here is all, what is defined in the indicator.

#property indicator_buffers 8 // Number of buffers
SetIndexBuffer(1,Set_SL); // assignment of array
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1); // Line style

You don't need to define the SIZE for the indicator buffer?!

 
ikatsko >> :

You don't need to define the SIZE for the indicator buffer?!

Not necessary. It means buffer double Set_SL[];

 
granit77 >> :

Not necessary. It means buffer double Set_SL[];

So I still have the question posted here on 22.03.2009 16:05 (previous page). Yes, here's an addition: it was all over the weekend, i.e. there were no TICKS


 
ikatsko писал(а) >>

So I still have a question.

>> put the whole code out there, let's see if we can figure it out.

 
xruss писал(а) >>
Good evening. Can you please tell me - in my Expert Advisor, after a successful closing of a profitable trade, there is a reopening of a position in the same direction as the previous trade (of course, it becomes unprofitable in the future). How can I prohibit reopening such wrong trades?

It is enough to check the last closed transaction. But you have to provide for when there is no history yet

 
ikatsko писал(а) >>

This is all that is defined in the indicator.

#property indicator_buffers 8 // Number of buffers
SetIndexBuffer(1,Set_SL); // assignment of an array
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1); // Line style

You don't need to define the SIZE for the indicator buffer?!

This was not present in the original code. If there is, the reason is something else. We should look through the whole code.

 
Figar0 >> :

Post the whole code, let's try to figure it out

I left (for simplicity) only what constitutes the problem in the code. Let's put the indicator and see the problem, so to speak.

//+------------------------------------------------------------------+
//| iK_exp_stat_v30.mq4 |
//| Ivan Katsko |
//| |
//+------------------------------------------------------------------+
#property copyright "Ivan Katsko"
#property link ""

#property indicator_separate_window // Display in a separate window
#property indicator_buffers 8 // Number of buffers
#property indicator_color1 DeepPink // Color of the first line
#property indicator_color2 Purple // Color of the second line
#property indicator_color3 Red // Colour of the third line
#property indicator_color4 LawnGreen // Color of the fourth line
#property indicator_color5 Gold // Color of the fifth line
#property indicator_color6 Blue // Color of the sixth line
#property indicator_color7 SteelBlue // Color of the seventh line
#property indicator_color8 Lime //colour of the eighth line

extern inttern
Depth=1; // Depth of history: 1 - on History value.
extern double Level=10; // Minimum level SL/TP

int History; // Number of bars in the calculated history

double
Value_TP[]; // Array - Take Profit value
Av_Sum_TP[], // Array - Average Take Profit amount
Sum_na_TP[], // Array - Incremental amount of Take Profit
Algoritm[], // Algorithm: 1 - "today is like yesterday", -1 - "today is not like yesterday"
Direction[], // Direction of order: 1 - buy, -1 - sell
Sum_TP[], // Array - Incremental adaptive Take Profit amount
Set_TP[], // Take Profit set
Set_SL[]; // Set Stop Loss


//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//--------------------------------------------------------------------
SetIndexBuffer(0,Set_TP); // assignment of array Swap Up
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,1); // Line style
SetIndexBuffer(1,Set_SL); // Assign Array Swing Down
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1); // Line style
SetIndexBuffer(2,Sum_TP); // Assign array to buffer
SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,2); // Line style
SetIndexBuffer(3,Direction); // Assigning an array to the buffer
SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID,4); // Line style
SetIndexBuffer(4,Algoritm); // Assigning an array to the buffer
SetIndexStyle(4,DRAW_LINE,STYLE_SOLID,1); // Line style
SetIndexBuffer(5,Value_TP); // Assigning an array to the buffer
SetIndexStyle(5,DRAW_HISTOGRAM,STYLE_SOLID,2); // Line style
SetIndexBuffer(6,Sum_na_TP); // Assigning an array to the buffer
SetIndexStyle(6,DRAW_LINE,STYLE_SOLID,2); // Line style
SetIndexBuffer(7,Av_Sum_TP); // Assigning an array to the buffer
SetIndexStyle(7,DRAW_HISTOGRAM,STYLE_SOLID,2); // Line style

//--------------------------------------------------------------------
switch (Period()) // Set number of bars to be examined
{
case 1: History = 30; break; // Period 1 minute
case 5: History = 24; break; // 5-minute period
case 15: History = 24; break; // 15-minute period
case 30: History = 24; break; // Period 30 minutes
case 60: History = 24; break; // One hour period
case 240: History = 30; break; // Period 4-hour
case 1440: History = 22; break; // Daily period
default: Alert("Select period M1 to D1."); break; //hourly period
}
Set_SL[History*Depth]=1.0*Level*Point;
Alert("Init:"," Set_SL[",History*Depth,"]=",Set_SL[History*Depth]);//Specialy display it to see: it shows (let's say) 0,0001
//--------------------------------------------------------------------//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
Alert("Start:"," Set_SL[",History*Depth,"]=",Set_SL[History*Depth]);//And this already shows 2147483647
return(0);
}


Files:
Reason: