Could anyone help ?...


--- In [email protected], "vinkeroo" <jetfo...@...> wrote:
>
> Hi,
> 
> I have made trades which I store in a MySQL DB.  I am reading in the trades 
> into an array.  Then I am trying to execute the read in trades when I do a 
> backtest in order get detailed information about my performance.
> 
> The only issue I run into is not being able to get the first trade to 
> execute.  If someone can help, I would greatly appreciate it.  Code is below:
> 
> ---
> // Get date and price
> bPrice        = odbcGetArraySQL( "Select price, date from ETFTimer where 
> symbol = '" + Name() + "' and action = 'BTO' order by date asc" );
> sPrice        = odbcGetArraySQL( "Select price, date from ETFTimer where 
> symbol = '" + Name() + "' and action = 'STC' order by date asc" );
> 
> // Get date and position size
> buypossz      = odbcGetArraySQL( "Select size, date from ETFTimer where 
> symbol = '" + Name() + "' and action = 'BTO' order by date asc" );
> sellpossz     = odbcGetArraySQL( "Select size, date from ETFTimer where 
> symbol = '" + Name() + "' and action = 'STC' order by date asc" );
> 
> //    Print errors
> printf(odbcGetLastError());
> 
> //    Plot buy/sell prices
> Plot( bPrice, "buyit", colorBlue, styleDots );
> Plot( sPrice, "sellit", colorRed, styleDots );
> 
> 
> // THE FOLLOWING DOESN'T EXECUTE THE FIRST BUY/SELL SIGNALS OF TRACK RECORD
> // MUST FIX !!!!!!!!!!!
> Buy   = IIf( bPrice != ref(bPrice, -1), sigScaleIn, False ); // replace 
> regular buy signals by scale in 
> Sell  = IIf( sPrice != ref(sPrice, -1), sigScaleOut, False ); // replace 
> regular buy signals by scale in 
> 
> SetPositionSize( IIf(buy, buypossz, sellpossz), spsShares );
>


Reply via email to