I'm having trouble understanding what i'm doing wrong here. I have a simple code which
basically gives the crossover point between 2 moving averages.
This doesn't give any errors compiling or placing in a strat. However, it does give optimization errors when I try to optimize 2 of the moving averages at the same time.
The error message as follows: "Floating-point invalid operation"
Looking for help if anyone could point me in the direction on how to fix this.
Code: Select all
inputs:
Price(close),
FastAvg( 50 ),
SlowAvg( 200 ) ;
var:
CrossOverPoint(0);
//If CurrentBar > SlowAvg and CurrentBar > FastAvg then begin
CrossOverPoint = (summation(Price, SlowAvg - 1) * FastAvg
- summation(Price, FastAvg - 1)* SlowAvg)
/ (SlowAvg - FastAvg) ;
{Entries}
if MarketPosition <> 1 then
Buy next bar at CrossOverPoint Stop ;
if MarketPosition <> -1 then
SellShort next bar at CrossOverPoint Stop ;
//End; {End Strat}