[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 133
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
Sorry for the intrusion.
topBuffer[i] behind the loop and drawing, try it this way:
THANK YOU SO MUCH!
Your version of the indicator works!
I tried to solve them with the MQL4 tutorial and the examples of indicators, but nothing worked.
If you have the desire, time and inclination to help me figure out why:
1. When you install the indicator line receives a value of 0 (zero) and only with the arrival of the first tick takes the value of the variable top, or should open the parameter window and immediately close it;
2. The parameter top is calculated to the 4th sign, although there is the following line in init()
IndicatorDigits(Digits+1);
and the line
top=WindowPriceMax(win_idx);
I replaced it by
top=NormalizeDouble((WindowPriceMax(win_idx)),Digits+1);
It doesn't help! And the numerical values of the indicator window scale are 5 digits.
3. With the removal of the indicator Comment is not removed from the chart.
Code
--------
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red
double ExtMapBuffer1[],
ExtMapBuffer2[];
//--------------------------------
int init()
{
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtMapBuffer2);
IndicatorShortName("MACD_max-min_v2");
IndicatorDigits(Digits+1);
return(0);
}
//--------------------------------
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted(),limit,win_idx;
double top;
if(counted_bars>0)counted_bars--;
limit=Bars-counted_bars;
win_idx=WindowFind("MACD_max-min_v2");
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);
}
// top=WindowPriceMax(win_idx);
top=NormalizeDouble((WindowPriceMax(win_idx)),Digits+1);
Comment( "\n"," top = ",top);
ObjectDelete("max");
if(ObjectFind("max")!=win_idx)
{
ObjectCreate("max",OBJ_HLINE,win_idx,Time[0],top);
ObjectSet("max",OBJPROP_COLOR,Yellow);
ObjectSet("max",OBJPROP_WIDTH,0);
}
return(0);
}
//+------------------------------------------------------------------+
P.S.
to clear the Comment line, insert Comment(") in deinit();
Technical correction - use the SRC button on the top panel to insert code, as your advisers do. It will be much easier to read.
P.S.
To clear the Comment line, insert Comment(") in deinit();
Arrays cannot be passed to Comment(). Arrays must be printed element by element.
Data of type double is printed with 4 decimal digits after the point. To output numbers with higher accuracy, use DoubleToStr().
The bool, datetime and color types will be printed as numbers.
To output datetime data as a string, use the TimeToStr() function.
To split the output into multiple lines, you may use line feed character "\n" or "\r\n".
See also Alert() and Print().
Price has crossed the horizontal line up....
And how should this line be described?
Hello,
Here's the problem I'm having.
Working on PERIOD_H1.
To close at the end of the hour I do this:
To open a position at the beginning of the hour I do the followingBut for the test it goes like this
I can't figure out where I'm going wrong.
Not all times it works this way, but it has such moments.
Thanks who will answer :).
I'm not saying that, I'm saying what difference does it make where the EA is attached? If it is written correctly, it makes no difference where it is placed - just place it on a chart of Mongolian exchange, but if it is set to operate on EURUSD 1 minute, it will do so. And it is not hard to program it, just change a couple of lines.
Thank you very much for the clarification!
Only I'm concerned about the tester simulating one-minute bars for modifications at the opening of each one-minute bar.
I'll try changing Open[0] to iOpen(NULL,1,0) and adding a function to check the opening of the one-minute bar.
A few minutes passed, during which I tweaked the code and tried it with the tester at M5 and made sure that in this case the tester does not open 1-minute bars, although prescribed, and modifies it only every 5 minutes, which I was afraid of. In all ticks mode it is a bit better, because it modifies more often. But on M1 only on bar opening it works the same, both with Open[0] and with iOpen(NULL,1,0), for which I'm still grateful!
Now I will always use green iOpen, as I see that I can do without red Open. Green profit is nicer than red loss. (:))