Profile Picture

Simple Crossover

Posted By billb 11 Years Ago
Message
Posted Saturday June 10 2006
The timeless classic, the moving average crossover. This system uses 50 and 200 day simple moving averages.

The system can be downloaded by clicking here

Posted Monday June 23 2008
I get the following error on line 24 when I tried running this system.

Error   Cannot implicitly convert type 'System.Collections.Generic.IList' to 'System.Collections.Generic.List'. An explicit conversion exists (are you missing a cast?)   c:\Research\Code\Simple Crossover\Simple Crossover.cs   24

When I tried casting the result of the GetOpenPositions using "(List)", I get the following runtime error:

An exception of type System.InvalidCastException was thrown.
Unable to cast object of type 'System.Collections.ObjectModel.ReadOnlyCollection`1[RightEdge.Common.Position]' to type 'System.Collections.Generic.List`1[RightEdge.Common.Position]'.
at SystemMain.NewSymbolBar(Symbol symbol, BarData bar) in c:\Research\Code\Simple Crossover\Simple Crossover.cs:line 24

Would you please repost a version of this system that works with the latest RE build?

Thanks
Posted Monday June 23 2008
Here you are:

#region Using statements
using System;
using System.Drawing;
using System.Collections.Generic;
using RightEdge.Common;
using RightEdge.Common.ChartObjects;
using RightEdge.Indicators;
#endregion

#region System class
public class MySystem : MySystemBase
{
 public override void Startup()
 {
  // Perform initialization or set system wide options here

 }
}
#endregion

public class MySymbolScript : MySymbolScriptBase
{
   SMA sma50;
   SMA sma20;
 
   public override void Startup() 
   {
      sma50 = new SMA(50, Close);
      sma20 = new SMA(20, Close);
    } 
 
    public override void NewBar() 
    {   
      if (SystemUtils.CrossOver(sma20, sma50))
      {
         OpenPosition(PositionType.Long, OrderType.Market);
      }
  
      if (SystemUtils.CrossUnder(sma20, sma50))
      {
         PositionManager.CloseAllPositions(Symbol);
      }    
   }
}



Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems