had a quick glance at your code...
int start()
{
//----
int
Total, // Amount of orders in a window
Tip=-1, // Type of selected order (B=0,S=1)
tradeTotal, // Used for Stoploss Levels
Ticket; // Order number
double
Lot, // Amount of lots in a selected order
Lts, // Amount of lots in an opened order
// Minimal amount of lots
Step, // Step of lot size change
Free, // Current free margin
One_Lot, // Price of one lot
Price, // Price of a selected order
SL, // SL of a selected order
TP, // TP ?? a selected order
MA0, // Moving Average value 1
MA4, // Moving Average value 2
MA8, // Moving Average value 3
MA12, // Moving Average value 4
Slope1, // Equals M4-M1 10000
Slope2, // Equals M4-M1 10000
Slope3, // Equals M4-M1 10000
AverageSlope; // The Average of Slope(1-3)
bool
Ans=false, // Server response after closing
Opn_B=false, // Criterion for opening Buy
Opn_S=false, // Criterion for opening Sell
SlopeTrue=false, // Yes/No if Slope is larger than 3
Filter2=false; // Yes/No Correlation
//--------------------------------------------------------------- 3 --
// Tick Counter
{ <--------------------------------- what's this?
double tickarray[10];
static int cnt=9;
if(cnt<0) cnt=0;
{ //My addition
if(tickarray[0] !=0)
{
for (int j=9; j>1; j--)
{
tickarray[j]=tickarray[j-1];
}
}
tickarray[cnt]=Bid;
cnt--;
return;
}
} //My addition
had a quick glance at your code... [...]
The answer to your "What's this?" (and also to 7bit's question) is that it's part of a common pattern of problems as a result of Sjfit4 trying to combine bits of code together by pasting in parts of functions. For example, the following simply isn't going to work either:
double correlation=(tickarray,tickarray2)
{
I'm afraid it looks like a pretty fundamental misunderstanding of functions and program flow. I'd say that the thing to do is to take a step back, re-read things like the MQL4 book particularly including the section on functions, and then look at the code again.
Thanks for all your help!
I really appreciate it because it helps to know where i'm going wrong. Many thanks again.
Enotrek: I think the fact I don't know 'what this is' shows that I really need to do some reading.
7bit: I'm reading the link you gave now and going through my code to fix it up. Thanks for the link.
jjc: Thanks for the advice. I'll spend a few days reading more about the basics before jumping into things again. I was hoping by chance it might all work if i put each independent piece together but obviously it's not so simple and I missed a lot in the process. ALso thanks for the code on the correlation coefficient, i'm yet to put it in but it seems a much more efficient way to create an array!
and when you stumple upon compiler errors, use comments to find out where your problem lays.
// this for a line /* and this for a whole piece */
Good luck!
{ <--------------------------------- 1 double tickarray[10]; static int cnt=9; if(cnt<0) cnt=0; { //My addition <---------------2 NO mate if(tickarray[0] !=0) { <---------------3 for (int j=9; j>1; j--) { <---------------4 tickarray[j]=tickarray[j-1]; } <---------------4 } <---------------3 tickarray[cnt]=Bid; cnt--; return; } <--------------------------------- 1The extra braces can be useful if your editor include code folding (like notepad2)
/*++++ Draw Lines*/{ TLine("Rally", .. TLine("Correction", .. ... /*---- Draw Lines*/}
void something() { <---------------1 opening braces at the end of the line | double tickarray[10]; | static int cnt=9; | if(cnt<0) { <---------------2 always use the long form with braces, never the abbreviation | | cnt=0; | } <---------------2 closing brace lines up with the opening "if" statement | if(tickarray[0] !=0) { <---------------2 opening at end of line | | for (int j=9; j>1; j--) { <---------------3 opening at end of line | | | tickarray[j]=tickarray[j-1]; | | } <---------------3 closing lines up with "for" | } <---------------2 closing lines up with "if" | tickarray[cnt]=Bid; | cnt--; | return; } <---------------1 closing lines up with "void"
This is nice and compact and you will always see where your blocks start and where they end.
First make the indentation match the logic of your program, because the indentation is what you can easily see with the eye without counting any braces. Although it would compile even the most obfuscated mess as long as the braces are correct this is something you don't want to have. You want it always in a form where you can easily see at first sight what belongs to where. You should always have it in a form where the indentation is absolutely congruent with the logic and the blocks in your program. Then (and only then) after the indentation is correct you can check (and will now easily see) whether there are missing braces or braces that have no matching counterpart because for every increment in the indentation there must be exactly one opening brace and for every decrement there must be exactly one closing brace.
The extra braces can be useful if your editor include code folding (like notepad2)
i'm pleased that you understand that your coding needs some improvement. Learn the basics and work your way for more complicated stuff.
and when you stumple upon compiler errors, use comments to find out where your problem lays.
Good luck!
This is nice and compact and you will always see where your blocks start and where they end.
First make the indentation match the logic of your program,
because the indentation is what you can easily see with the eye without
counting any braces. Although it would compile even the most obfuscated
mess as long as the braces are correct this is something you don't want
to have. You want it always in a form where you can easily see at
first sight what belongs to where. You should always have it in a form
where the indentation is absolutely congruent with the logic and the
blocks in your program. Then (and only then) after the
indentation is correct you can check (and will now easily see) whether
there are missing braces or braces that have no matching counterpart
because for every increment in the indentation there must be exactly one opening brace and for every decrement there must be exactly one closing brace.
Thanks for the help guys, I think the penny has finally dropped for me. I've complete rewritten it from top to bottom and it compiled after only fixing a few errors.
Also arranging it like you said has made it so much easier, i'm no longer putting lines in the wrong order, especially stuff to do with if()'s, and it makes defining things a whole lot clearer.
Many Thanks again!

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I was wondering if someone could help me find this error. I'm new to coding but I think I did a really thorough check.
I think I have about half the hair count as this morning, and my eyes are certainly permanently damaged from staring at '{'s.
I've done:
Thank you so much if you can help out. Please don't put too much time in, but if I'm making a novice mistake be sure to let me know. And apologies in advance if I haven't noticed something obvious as I think I'm doing this a little too late at night.
I get the following errors when I try to compile:
Attached is the code.