//Use data2 as day bar.//Use data1 as minute bar.
Inputs: k1( 0.5),k2 (0.5);inputs: Mday(1 ),Nday (1),lots(1), daystart(900 ), dayend(1500 ),freq_min (10);//10 min bars, you may chance to other frequency
vars: dayclose(0 ), dayhigh(0 ),daylow (0);vars: sellrange(0 ),buyrange (0),buytrig(0), selltrig(0 );Vars: HH( 0),HC (0),LC(0), LL( 0);vars: buyposition(0 ),sellposition (0);vars: opentoday(0 );
//give a start value for open price of today(data1)if time >=daystart and time <=daystart+ freq_min then begin opentoday=open ;end;
HH=highest (high ,Mday ) of data2 ;HC=highest (close ,Mday ) of data2 ;LL=lowest (low ,Mday ) of data2 ;LC=lowest (close ,Mday ) of data2 ;
if (HH-LC)>=( HC- LL) then sellrange=HH -LCelse sellrange =HC -LL ;
HH = Highest (High ,Nday ) of data2 ;HC = Highest (Close ,Nday ) of data2 ;LL = Lowest (Low ,Nday ) of data2 ;LC = Lowest (Close ,Nday ) of data2 ;
If((HH - LC) >= ( HC - LL ))then BuyRange = HH - LC Else BuyRange = HC - LL; BuyTrig = K1* BuyRange; SellTrig = K2* SellRange; BuyPosition = opentoday +BuyTrig ;SellPosition = opentoday -SellTrig ;
If(MarketPosition = 0) thenbegin If High >=BuyPosition then Buy lots shares next bar at buyposition stop ; If Low <=SellPosition then SellShort lots shares next bar at sellposition stop;end;
if marketposition =-1 thenbegin if high >=buyposition then buy lots shares next bar at buyposition stop ;end;
if marketposition =1 thenbegin if low <=sellposition then sellshort lots shares next bar at sellposition stop ;end;
//setstoploss(minmove*30);
//draw trendlinesif (time>= dayend-3 *freq_min and time<=dayend ) then begintl_new(date ,0900,buyposition, date,time ,buyposition );tl_new(date ,0900,sellposition, date,time ,sellposition );end;