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 [email protected], "Barry Scarborough" <[EMAIL PROTECTED]> 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); >
