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

[amibroker] Re: An AB Design question for Tomasz - When does Buy and BuyPrice become active?



PureBytes Links

Trading Reference Links

Fat finger check. The lines actually are:

BuyPrice   = IIf(Buy, tick  + fRound(fInRange(IIf(Buy, fMA2, 0), up), 
up), 0);
SellPrice  = IIf(Sell, -tick + fRound(fInRange(IIf(Sell, fMA2, 0), 
dn), dn), 0);
CoverPrice = IIf(Cover, tick  + fRound(fInRange(IIf(Cover, fMA2, 0), 
up), up), 0);
ShortPrice = IIf(Short, -tick + fRound(fInRange(IIf(Short, fMA2, 0), 
dn), dn), 0);

Barry

--- In amibroker@xxxxxxxxxxxxxxx, "me_rayme" <rayme9@xxx> wrote:
>
> You have syntax errors on four lines at pBuyprice etc
> 
> pBuyPrice = tick + fRound+(fInRange(IIf(Buy, fInd2, 0), up), up);
> pShortPrice = -tick + fRound(fInRange(IIf(Short, fInd2, 0), dn), 
dn);
> pSellPrice = -tick + fRound(fInRange(IIf(Sell, fInd2, 0), dn), dn);
> pCoverPrice = tick + fRound(fInRange(IIf(Cover, fInd2, 0), up), up);
> 
> Ihave also been looking at this same problem during the minute when 
> the bar comes and disappears.
> 
> Ray
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Barry Scarborough" <razzbarry@> 
> wrote:
> >
> > I am working on a system where I try to buy or sell when a couple 
> of 
> > indicators become true within the bar. I using this intraday and 
> was 
> > watching the charts. I have the conditions ANDed and it places 
> arrows 
> > on the chart when the Buy is true. The problem I ran into today 
was 
> > that the conditions were true within a minute bar, the buy arrow 
> > flashed on, then off a number of times within the bar. But 
BuyPrice 
> > which is set at the same time, never changed. What is going on?
> > 
> > I want to generate a buy/sell immediately when the conditions are 
> > true. I thought maybe the conditions had to be true at the end of 
> the 
> > bar before the Buy and BuyPrice become active. That does not seem 
> to 
> > be the case, at least not all the time. I noticed that if the 
> > conditions occurred during the bar but were not true at the end 
of 
> > the bar the Buy was not set. But if the conditions were true at 
the 
> > beginning of the next bar the Buy and BuyPrice were set 
> immediately, 
> > before the end of the bar. What is going on? Is this a bug? How 
can 
> > Buy come on without BuyPrice being set. Why does it work at the 
> > beginning of the bar but not intra bar? How is this supposed to 
> > work?  
> > 
> > I added the code below with the exception of the system code. 
> > 
> > Another problem that we noticed was that using AddColumn to dump 
> the 
> > trade prices to Excel does not always have the same value as what 
> is 
> > plotted on the chart. 
> > 
> > Thanks for the help,
> > Barry
> > 
> > Code fragment:
> > 
> > // AND the indicator conditions to find the buy points  
> > Buy   = BuySigA AND upIND;   	
> > // normal sell or if last bar and buy state 
> > Sell  = (SellSigA AND dnIND) OR tod == timeclose; 	
> > // AND the indicator conditions to find the short points    
> > Short = ShortSigA AND dnIND;  
> > // normal cover or if last bar and short state 
> > Cover = (CoverSigA AND upIND) OR tod == timeclose; 	
> >   
> > // in the following code fInRAnge determines whether to use the 
> > calculated price or the open price on a gap.
> > // roundd the price up or down then adds or subtracts a tick 
> > depending on the signal, buy or short. 
> > pBuyPrice   = tick  + fRound(fInRange(IIf(Buy, fInd2, 0), up), 
up);
> > pShortPrice = -tick + fRound(fInRange(IIf(Short, fInd2, 0), dn), 
> dn); 
> > pSellPrice  = -tick + fRound(fInRange(IIf(Sell, fInd2, 0), dn), 
> dn); 
> > pCoverPrice = tick  + fRound(fInRange(IIf(Cover, fInd2, 0), up), 
> up);
> > 	
> > 
> > // make sure there are no multiple buys OR sells while a like 
> > position is Open
> > Buy    = ExRem(Buy, Sell );
> > Sell   = ExRem(Sell , Buy);
> > Cover  = ExRem(Cover, Short );
> > Short  = ExRem(Short , Cover);
> > BuyPrice   = IIf(Buy, pBuyPrice, 0);
> > SellPrice  = IIf(Sell, pSellPrice, 0);
> > CoverPrice = IIf(Cover, pCoverPrice, 0);
> > ShortPrice = IIf(Short, pShortPrice, 0);
> > 
> > Filter = Buy OR Sell OR Short OR Cover; // set the conditions to 
> > monitor in analysis - back test, scan and explore
> > 
> > // plot buy and sell arrows on the chart
> > PlotShapes(Buy * shapeUpArrow, uparrow, 0, Low);
> > PlotShapes(Sell * shapeDownArrow, dnarrow,0,Low );
> > PlotShapes(Short * shapeCircle, dnarrow);
> > PlotShapes(Cover * shapeHollowCircle, uparrow);
> > 
> > // plotting functions
> > Plot(C, Date() + " - System 1a " + NumToStr(search, 1.0) + " - 
C", 
> > background, styleCandle); 	// plot candles on the chart
> > Plot(BuyPrice, "\nBuy Price", background ,  styleOwnScale | 
> > styleNoLine | styleNoLabel );
> > Plot(SellPrice, "Sell Price", background ,  styleOwnScale | 
> > styleNoLine | styleNoLabel );
> > Plot(ShortPrice, "Short Price", background ,  styleOwnScale | 
> > styleNoLine | styleNoLabel );
> > Plot(CoverPrice, "Cover Price", background ,  styleOwnScale | 
> > styleNoLine | styleNoLabel );
> > Plot(Buy, "\nBuy", background ,  styleOwnScale | styleNoLine | 
> > styleNoLabel );
> > Plot(Sell, "Sell", background ,  styleOwnScale | styleNoLine | 
> > styleNoLabel );
> > Plot(Short, "Short", background ,  styleOwnScale | styleNoLine | 
> > styleNoLabel );
> > Plot(Cover, "Cover", background ,  styleOwnScale | styleNoLine | 
> > styleNoLabel );
> > 
> > // code for exploration and export to spreadsheet
> > AddColumn(BuyPrice, "Buy price", 1.3);
> > AddColumn(SellPrice, "Sell price", 1.3);
> > AddColumn(ShortPrice, "Short price", 1.3);
> > AddColumn(CoverPrice, "Cover price", 1.3);
> >
>




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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> 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/