View Single Post
 
Old 12-15-2005, 12:20 AM
Vasilyt Vasilyt is offline
Junior Member
 
Join Date: Dec 2005
Posts: 15
Vasilyt is on a distinguished road
MQLII code to MQL4 - Need to remake indicator that shows sessions and dayhigh/lows

Dear MQL4 experts,
Please help me convert the indicator below to MQL4.

Code:
 /*[[
	Name := Session2
	Author := Copyright © 2004, MetaQuotes Software Corp.
	Link := http://www.metaquotes.net/
	Separate Window := No
	First Color := Blue
	First Draw Type := Symbol
	First Symbol := 167
	Use Second Data := Yes
	Second Color := Red
	Second Draw Type := Symbol
	Second Symbol := 167
]]*/
Variable :shift(0),Ctime(0),ho(0),mi(0),i(0), count(0),val1(0), val2(0);
Input:periods(3000);


SetLoopCount(0);
// loop from first bar to current bar (with shift=0)
For shift=periods Downto 0 Begin
ho=TimeHour(T[shift]);
mi=TimeMinute(t[shift]);

    if Period = 1.0 then {
      Ctime=Ho*60+mi;
    } else 
    // 5 
    if Period = 5.0 then {
      Ctime=Ho*12+ceil((mi+5)/5);
    } else
    // 15 
    if Period = 15.0 then {
      Ctime=Ho*4+ceil((Mi+15)/15);
    } else 
    // 30 
    if Period = 30.0 then {
      Ctime=Ho*2+ceil((Mi+30)/30);
    } else 
    // 
    if Period = 60.0 then {
      exit;
    } else 
    // 4
    if Period = 240.0 then {
      exit;
    }
 
    if Ctime = 0 then Ctime = 1;
 
    val1=0;
    val2=0;
    
    if (ho>=9 and ho<=13) then {
       val1=H[Highest(MODE_HIGH,shift+Ctime-1,Ctime)];
       val2=L[Lowest(MODE_LOW,shift+Ctime-1,Ctime)];    
    }
    if (ho>=15 and ho<=17) then {
       val2=H[Highest(MODE_HIGH,shift+Ctime-1,Ctime)];
       val1=L[Lowest(MODE_LOW,shift+Ctime-1,Ctime)];    
    }
    
	SetIndexValue(shift, val1);
	SetIndexValue2(shift, val2);
    Comment("Daly Price Channel= ", (val1 - val2)/Point );

End;