[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 131

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
When closing trades in the tester is written as you have listed, it is most likely the result of the orderclose function (TP and SL have nothing to do with it)
Thanks, but there seems to be no errors in the code:
but there is another code in the EA:
But there is another code in the EA:
put for example Print("close by CloseMarket " , j); in this function and something similar in the previous one you posted . run it and look through the logs to see which of these prints appears to analyse which one triggers. then similarly log the values of the variables checked in the close execution conditions and find the reasons for their triggering...
And what prevents you from putting the EA on the exact window where you want to draw?
My EA works better on M1, because it is better at M1 and opens 1 trade on M5 bar opening, it also refills if conditions allow. I also use indicators on M5 and other TFs. And it is better to test on M1 at bar opening, while on other TFs with all ticks it tests bad.
I don't draw, I just see the results of the calculations made by the EA and displayed in somments to make sure everything is in order. Thank you for your attention and help!
My EA works better on M1, as it trawls better on M1 and opens 1 trade on M5 bar opening, also refills if conditions allow. And I use indicators on M5 and other TFs. And it is better to test on M1 at bar opening, while on other TFs with all ticks it tests bad.
I don't draw, I just see the results of the calculations made by the EA and displayed in somments to make sure everything is OK. Thank you for your attention and help!
Both on M1 and M5 the ticks are taken from the same source, and you can use any timeframe from any chart, just replace Close[] with iClose, etc. In order to test it better, you have to make better fxt-files from ticks, here is an example, but in general google, there is a lot of information on this subject.
The practice has shown, that it is better to open on Op and test also better, than on ticks. I am not keen on ticks at all. When depo allows, I may move to higher TF, which will show better results in a day. I do not leave deals for the night to sleep well. Thanks again!
Print("Close by CloseMarket " , j); in this function and something similar in the previous one you posted. Run it and look through the log for the results of these printers to analyse which one triggers. Then similarly log the values of the variables checked in the close conditions and find the reasons for their triggering...
Practice has shown that it's better to open on Orep and test better, too, than on ticks. And I'm not into ticks at all. When depo allows, I may switch to higher TF, which will show better results within a day. I do not leave deals for the night to sleep well. Thanks again!
Dear Mr. Programmers! I can't draw a horizontal line by the maximum numerical value of the MACD indicator window.
Code
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Lime
#property indicator_color2 Red
//--- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double topBuffer[];
bool initFinished=false; // add a variable that will remember the state of initialization.
// false - initialization has not yet happened.
// true - was initialized
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(2,DRAW_NONE);
SetIndexBuffer(2,topBuffer);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted(),
limit;
if(counted_bars>0)
counted_bars--;
limit=Bars-counted_bars;
//----
for(int i=0;i<limit;i++)
{
ExtMapBuffer1[i]=iMACD(0,0,12,26,9,PRICE_CLOSE,MODE_MAIN,i);
ExtMapBuffer2[i]=iMACD(0,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,i);
if(initFinished==false)
{
IndicatorShortName("MACD_max-min");
int win_idx=WindowFind("MACD_max-min");
// find the number of our indicator subwindow
if(win_idx<0)
{
// if the subwindow number is -1, there is an error
Print("Window not found");
return(0);
}
double top=WindowPriceMax(win_idx);
//find the maximum value of the vertical scale of the specified sub-window of the current chart
ObjectCreate("max",OBJ_HLINE,win_idx,0,top);
// draw a horizontal line in a subwindow of our indicator
ObjectSet("max",OBJPROP_COLOR,Yellow);
ObjectSet("max",OBJPROP_WIDTH,0);
WindowRedraw();
// redraw the window to see the line
initFinished=true;
// drawing is finished
}
topBuffer[i]=top;
}
//----
return(0);
}
//+------------------------------------------------------------------+
It looks like in the line
double top=WindowPriceMax(win_idx);
top variable does not get any value and in the
ObjectCreate("max",OBJ_HLINE,win_idx,0,top);
instead of it (i.e. instead of top variable) I automatically get 0 (zero). So, I get a zero line in the required window and in the required colour. topBuffer[] is also empty. If in this line instead of the variable top put a numeric value, the line takes this fixed value.Somewhere I have a clinical error.Help to understand! Thank you in advance.