Помогите новичку

 
Я начала изучать язык MQL4 (для MT3 ни когда индикаторов не писала)
Решила написать индикатор, подобный индикатору для MT3:
/*[[
Name := CandleStick
Author := Aborigen
Link :=
Separate Window := Yes
First Color := Blue
First Draw Type := Histogram
First Symbol := 217
Use Second Data := Yes
Second Color := Red
Second Draw Type := Histogram
Second Symbol := 218
]]*/
Variable : s(0),HC(0),HL(0),OL(0),CO(0),HO(0),CL(0),OC(0),HL_3(0),HL_14(0),HL_6(0);
Var: loopbegin1(0), first(True), prevbars(0), rez(0),ttime(0);
SetLoopCount(0);
if ttime=time and loopbegin1=-1 then exit;
ttime=time;

If Bars < prevbars Or Bars-prevbars>1 Then first = True;
prevbars = Bars;
If first Then Begin
loopbegin1 = Bars-2;
If loopbegin1 < 0 Then Exit; // not enough bars for counting
first = False; // this block is to be evaluated once only
End;
loopbegin1 = loopbegin1+1;
For s = loopbegin1 Downto 1 Begin
//----------------------------------------------
HC=H[s]-C[s];HL=H[s]-L[s];OL=O[s]-L[s];CO=C[s]-O[s];HO=H[s]-O[s];CL=C[s]-L[s];OC=O[s]-C[s];
HL_3=HL/3;HL_14=HL/1.4;HL_6=HL/6;

IF HC<HL_14 and OL<HL_14 and C[s]>O[s] and CO<HL/2 then SetIndexValue(s, 3);
IF HO<HL_14 and CL<HL_14 and O[s]>C[s] and OC<HL/2 then SetIndexValue(s,-3);
IF HC<CO*1.6 and OL/2>CO and C[s]>O[s] and CO<HL_3 then SetIndexValue(s, 6);
IF HO<OC*1.6 and CL/2>OC and O[s]>C[s] and OC<HL_3 then SetIndexValue(s,-6);

IF OL<CO*1.6 and HC/2>CO and C[s]>O[s] and CO<HL_3 then SetIndexValue(s, 7);//
IF CL<OC*1.6 and HO/2>OC and O[s]>C[s] and OC<HL_3 then SetIndexValue(s,-7);//

IF HO<CL and abs(CO)<HL/20 then SetIndexValue(s, 5); //
IF CL<HO and abs(OC)<HL/20 then SetIndexValue(s,-5); //

IF HC<HL_14 and OL<HL_14 and abs(CO)<HL/20 then SetIndexValue(s, 4);//
IF HO<HL_14 and CL<HL_14 and abs(OC)<HL/20 then SetIndexValue(s,-4);//

IF HC<HL_3 and OL<HL_3 and C[s]>O[s] then SetIndexValue(s, 2); //
IF HO<HL_3 and CL<HL_3 and O[s]>C[s] then SetIndexValue(s,-2); //

IF HC<HL/1.9 and OL<HL/7 and C[s]>O[s] and CO>HL_3 then SetIndexValue(s, 8);//
IF HO<HL/7 and CL<HL/1.9 and O[s]>C[s] and OC>HL_3 then SetIndexValue(s,-8);//

IF HC<HL/7 and OL<HL/1.9 and C[s]>O[s] and CO>HL_3 then SetIndexValue(s, 9);//
IF HO<HL/1.9 and CL<HL/7 and O[s]>C[s] and OC>HL_3 then SetIndexValue(s, -9);//

IF HC<HL_6 and OL<HL_6 and C[s]>O[s] then SetIndexValue(s, 1);//
IF HO<HL_6 and CL<HL_6 and O[s]>C[s] then SetIndexValue(s,-1);//
//----------------------------------------------
loopbegin1 = loopbegin1-1;
End;

______________________________
В отличии от исходного - хотела сделать индикатор не в отдельном окне, а на графике, то есть на графике должна бы появляться либо зеленая либо красная точка под или над баром

_________
Написав часть индикатора
_________
property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Crimson
extern double Kstop=0.5;
double val1[];
double val2[];
int s=0;
double HC=0;
double Hl=0;
double OL=0;
double CO=0;
double HO=0;
double HL=0;
double CL=0;
double OC=0;
double HL_3=0;
double HL_14=0;
double HL_6=0;
double loopbegin1=0;
bool first=True;
double prevbars=0;
double rez=0;
double ttime=0;
int shift;
datetime alertTime;
string symbolName;
int i, checksum;
double Range=0;

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+

string short_name;
//---- indicator line
IndicatorBuffers(2);
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,108);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,108);
SetIndexBuffer(0,val1);
SetIndexBuffer(1,val2);

//----
// return(0);

//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
//int deinit()
//----

//----
// return(0);
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{

if ((ttime!= CurTime( ) )&& ( loopbegin1!=-1)) ttime=CurTime( );
return(0);
//----
//If Bars < prevbars Or Bars-prevbars>1 Then first = True;
if ((Bars <prevbars)||((Bars-prevbars)>1)) first = True;
return(0);
//If first Then Begin
if(first == True)
{loopbegin1 = Bars-2;
if (loopbegin1 < 0)return(0);
first = False;
return(0);
}
loopbegin1 = loopbegin1+1;
for (s=0;s<loopbegin1; s++)
val1[s]=0;
val2[s]=0;

{HC=High[s]-Close[s];HL=High[s]-Low[s];OL=Open[s]-Low[s];CO=Close[s]-Open[s];HO=High[s]-Open[s];CL=Close[s]-Low[s];OC=Open[s]-Close[s];
HL_3=HL/3;HL_14=HL/1.4;HL_6=HL/6;
//IF HC<HL_14 and OL<HL_14 and C[s]>O[s] and CO<HL/2 then SetIndexValue(s, 3);// &#247;&#229;&#240;&#237;&#251;&#233; &#226;&#238;&#235;&#247;&#229;&#234;
if((HC<HL_14 )&&(OL<HL_14)&&( Close[s]>Open[s])&&(CO<HL/2))
{val1[s]=Low[s]-Range*Kstop;}
// IF HO<HL_14 and CL<HL_14 and Open[s]>C[s] and OC<HL/2 then SetIndexValue(s,-3);
if((HO<HL_14)&&(CL<HL_14)&&(Open[s]>Close[s])&&(OC<HL/2))
{val2[s]=High[s]+Range*Kstop;}


}
//----
return(0);
} // end of int start()
__________
решила проверить, появляются ли точки - ни чего не произошло :-(
Если не трудно, подскажите, что я делаю не так?
надеюсь, что этот показательный урок будет полезен не только мне, но и другим новичкам, решившимся освоить MQ4

//+------------------------------------------------------------------+
Для начала сде
 
 for (s=0;s<loopbegin1; s++)
val1[s]=0;
val2[s]=0;

{HC=High[s]-Close[s];........
.................................


Тут явно ошибка.
После for обычно в скобках {} пишется несколько операторов тела цикла.
У вас же loopbegin1 раз будет выполняться оператор val1[s]=0;

Может быть должно было быть так:

 for (s=0;s<loopbegin1; s++)
{
   val1[s]=0;
   val2[s]=0;

   HC=High[s]-Close[s];
   HL=High[s]-Low[s];
.................


или так

 for (s=0;s<loopbegin1; s++)
{
   val1[s]=0;
   val2[s]=0;
}

{HC=High[s]-Close[s]; ....
................


но тогда непонятно наличие открывающей скобки перед HC

 
Про программировании полезно использовать правило KISS (Keep It Simple Stupid) тем более начинающим
Удачи :)