[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 647
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
right.
I drew the code below. May someone tell me what's the problem - the snippet I put in bold?
The problem is that the indicator draws the history backward immediately and does not reset it after changing the parameters.
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 LimeGreen
double AUD;
extern int PerAvr=5,Delta=1;
double Idx[];
//+------------------------------------------------------------------+
//| Custom indicator initialisation function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
SetIndexBuffer(0,Idx);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
int limit=Bars-counted_bars;
for(int i=limit; i>=0; i--)
{
AUD=(iMA("AUDUSD",0,PerAvr,0,MODE_LWMA,PRICE_CLOSE,i)-iMA("AUDUSD",0,PerAvr,0,MODE_LWMA,PRICE_CLOSE,i+De lta)*100/iMA("AUDUSD",0,PerAvr,0,MODE_LWMA,PRICE_CLOSE,i+De lta);
//if (Curency =="AUDUSD")
Idx[i] = AUD;
}
//----
//----
return(0);
}
//+------------------------------------------------------------------+
Good afternoon, forum members. I found an interesting code for building a trend line. I decided to play with it a little bit.
For some reason I was reminded of an anecdote: in a family of a programmer, a son approaches his father and asks why the sun rises in the east and sets in the west.
Daddy, without taking his eyes off his computer, does it really rise in the east? -Yes. -And it sets in the west? - Yeah. So, what, every day? - Yes. Well, don't touch anything if it's working.
For some reason I was reminded of an anecdote: in a family of a programmer, a son approaches his father and asks why the sun rises in the east and sets in the west.
Daddy, without taking his eyes off his computer, does it really rise in the east? -Yes. -And it sets in the west? - Yeah. So, what, every day? - Yeah. Well, you don't have to touch anything if it's working.
Hello forum users, I have found an interesting code for drawing the trend line.
You know what's funny - you've changed the code according to your principles and want a brigade of scholars to find faults
and you just try to output the information that you want to get in the commentary? it's possible that everything works but you get the data that is not displayed at the current price but somewhere at the bottom of the chart - i think it's the separatetwinds
SZS good luck
You know what's funny - you've changed the code according to your principles and want a brigade of scholars to find faults
and you just try to output the information that you want to get in the commentary? it's possible that everything works but you get the data that is not displayed at the current price but somewhere at the bottom of the chart - i think it's the separatetwinds
SZS good luck
I know about the separator - I know, it's in a separate window, it's not about it. I can't see what will happen with this code - apparently this method of calculation will not work for percentages((.
Immediately, for some reason I recall a joke - a programmer's son comes to his father and asks why the sun rises in the east and sets in the west?
Daddy, without taking his eyes off his computer, does it really rise in the east? -Yes. -And it sets in the west? - Yeah. So, what, every day? - Yeah. Well, you don't have to touch anything if it's working.
Thank you. I guess the only difference is that the EA is launched every time a new tick comes in, while the script has to be launched in infinite loop to keep it running?
Not necessarily. It all depends on the purpose of the script. If the purpose of the script is for a one-off run (which is the vast majority), there's no need to make up endless loops. The need of calculating the amount of money to be involved in the market when opening a position with a preset lot can serve as an example of such a one-time script. Since the point price at minimum lot is different for different instruments, it is easier to open the required instrument, apply the script to it, enter the intended lot into the parameters window and see how much money will be blocked if the trade is opened.
This is just an example. The purpose of the scripts may be different.
I'm aware of the separateness - I know, it's in a separate window, it's not about it. I don't see how this code will work - apparently this method of percentage calculation won't work((.
Immediately, for some reason I recalled an anecdote: a son in a family of a programmer comes to his father and asks why the sun rises in the east and sets in the west?
Daddy, without taking his eyes off his computer, does it really rise in the east? -Yes. -And it sets in the west? - Yeah. So, what, every day? - Yeah. Well, you don't have to touch anything if it's working.
It's a pretty simple indicator. I don't see how percentages are any better than pips, but whatever.
You've made some mistakes, though :)
1.
To correctly calculate the percentage you must add parentheses.
2.
The problem is that the indicator draws the history backward immediately and does not reset it after changing the parameters.
The most interesting thing is that it woke up the sporting interest and sat for half an hour on your indicator.
Why wasn't the history calculated?
The answer is that you added a division operation.
The fact that the iMA("AUDUSD",0,PerAvr,0,MODE_LWMA,PRICE_CLOSE ,i+Delta) function returns 0 at the very beginning of the history has not been taken into account. And you were "kicked out" with error 4013 (ERR_ZERO_DIVIDE) when trying to divide by 0, check the log.
We may add one more check into FOR loop.
And everything will be all right. Below is my variant.
#property indicator_color1 White
Is it possible to change this parameter programmatically in the start() module,
i.e. is it possible to change the colour set for the buffer as the program progresses?
#property indicator_color1 White
Is it possible to change this parameter programmatically in the start() module,
i.e. is it possible to change the colour set for the buffer as the program progresses?
I don't think so. And why should it be?