[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Darvas Box



PureBytes Links

Trading Reference Links

Thanks, Jason. I have already this code and I have
another one. Look below:
_SECTION_BEGIN("Darvas Box2");
box1=0;
box2=0;

procedure fillDarvas(start,end,swap,top, bottom )
{
   for ( j = start; j < end; j++)
   {
       if( box1[j] = swap)
 	box1[j]= top ;
	else
	box1[j]= bottom;

       if(box2[j] = swap)
 	box2[j]= bottom ;
	else
	box2[j]= top;
   }
}

BoxArr1 = 0;
BoxArr2 = 0;
StateArray = 0;
DBuy = 0;
DSell = 0;
TopArray = 0;
BotArray = 0;
tick=0;

BoxTop = High[0];
BoxBot = Low[0];
swap=0;
state = 0;
BoxStart = 0;

for (i=0; i<BarCount; i++)
{
 if (state==5)
 {
  TopArray[i]=BoxTop;
  BotArray[i]=BoxBot;
  if (Low[i]<(BoxBot*(1-tick/100)) ||
High[i]>(BoxTop*(1+tick/100)))
  {
fillDarvas(BoxStart,i,swap,BoxTop,BoxBot);

  state = 1;
  swap =  !swap;
  BoxTop = High[i];
  BoxStart = i;
  }
 }
 else
 {
  if (High[i]<BoxTop)
  {
      if ((state<3) || (Low[i]>BoxBot))
      {
   state++;
   }
      else
   {
      state=3;
   }
      if (state==3)
      BoxBot=Low[i];
  }
  else
  {
      state=1;
      BoxTop=High[i];
  }
 }
 StateArray[i] = state;
}

fillDarvas(BoxStart,BarCount,swap,BoxTop,BoxBot);

Plot(C,"",1,64);
//Plot( box1, "" , colorRed, styleLine );
//Plot( box2, "" , colorGreen , styleLine );

Plot( box1, "" , colorRed, 512);
Plot( box2, "" , colorGreen , 512);
_SECTION_END();

--- Jason Hart <jayhart_1972@xxxxxxxxx> wrote:

> which code are you using?  I have two one has a red
> and green line which does not plot the actual boxes
> and is more of a LT indicator of support/resistence.
>  The second one I have does plot the boxes.  
>    
>   try this....
>    
>     //////////begin/////////
>   box1=0;
>   box2=0;
>   SetBarsRequired(10000,10000);
>   procedure fillDarvas(start,end,swap,top, bottom )
>   {
>   for ( j = start; j < end; j++)
>   {
>   if( box1[j] == swap)
>   box1[j]= top ;
>   else
>   box1[j]= bottom;
>   if(box2[j] == swap)
>   box2[j]= bottom ;
>   else
>   box2[j]= top;
>   }
>   }
>   BoxArr1 = 0;
>   BoxArr2 = 0;
>   StateArray = 0;
>   DBuy = 0;
>   DSell = 0;
>   TopArray = 0;
>   BotArray = 0;
>   tick=0;
>   BoxTop = High[0];
>   BoxBot = Low[0];
>   swap=0;
>   state = 0;
>   BoxStart = 0;
>   for (i=0; i<BarCount; i++)
>   {
>   if (state==5)
>   {
>   TopArray[i]=BoxTop;
>   BotArray[i]=BoxBot;
>   if (Low[i]<(BoxBot*(1-tick/100)) ||
> High[i]>(BoxTop*(1+tick/100)))
>   {
>   fillDarvas(BoxStart,i,swap,BoxTop,BoxBot);
>   state = 1;
>   swap = !swap;
>   BoxTop = High[i];
>   BoxStart = i;
>   }
>   }
>   else
>   {
>   if (High[i]<BoxTop)
>   {
>   if ((state<3) || (Low[i]>BoxBot))
>   {
>   state++;
>   }
>   else
>   {
>   state=3;
>   }
>   if (state==3)
>   BoxBot=Low[i];
>   }
>   else
>   {
>   state=1;
>   BoxTop=High[i];
>   }
>   }
>   StateArray[i] = state;
>   }
>   fillDarvas(BoxStart,BarCount,swap,BoxTop,BoxBot);
>   Plot(C,"",3,64);
>   Plot( box1, "" , 1 + statearray, styleLine );
>   Plot( box2, "" , 1 + statearray , styleLine );
>   _SECTION_BEGIN("MA");
>   P = ParamField("Price field",-1);
>   Periods = Param("Periods", 15, 2, 200, 1, 10 );
>   Plot( MA( P, Periods ), _DEFAULT_NAME(),
> ParamColor( "Color", colorCycle ),
> ParamStyle("Style") ); 
>   _SECTION_END();
>   a=(C-Ref(C,-1))/(Ref(C,-1))*100;
>   Title = Name() + " - " + WriteVal( DateTime(),
> formatDateTime ) + " - " + " Open: " + O + ", Hi: "
> + H + ", Low: " + L + ", Close: " + C + " " +
> NumToStr(a,1.2) + "%" + ", Volume: " + 
>   WriteVal(V,1)+ " "; 
> 
> 
> amon_gizeh <amon_gizeh@xxxxxxxxx> wrote:
>   Hi
> Has anybody a code what ploted Darvas Box on the
> chart (the existing
> formula in AFL Library is not so good)
> Thanks
> 
> 
> 
> 
> 
> 
> Please note that this group is for discussion
> between users only.
> 
> To get support from AmiBroker please send an e-mail
> directly to 
> SUPPORT {at} amibroker.com
> 
> For other support material please check also:
> http://www.amibroker.com/support.html
> 
> 
> 
> 
> 
>   SPONSORED LINKS 
>         Investment management software   Real estate
> investment software   Investment property software  
>   Software support   Real estate investment analysis
> software   Investment software 
>     
> ---------------------------------
>   YAHOO! GROUPS LINKS 
> 
>     
>     Visit your group "amibroker" on the web.
>     
>     To unsubscribe from this group, send an email
> to:
>  amibroker-unsubscribe@xxxxxxxxxxxxxxx
>     
>     Your use of Yahoo! Groups is subject to the
> Yahoo! Terms of Service. 
> 
>     
> ---------------------------------
>   
> 
>   
> 
> 
> 		
> ---------------------------------
>  Yahoo! Personals
>  Single? There's someone we'd like you to meet.
>  Lots of someones, actually. Yahoo! Personals
> 			
> ---------------------------------
> Yahoo! Shopping
>  Find Great Deals on Gifts at Yahoo! Shopping 



		
__________________________________ 
Start your day with Yahoo! - Make it your home page! 
http://www.yahoo.com/r/hs


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/