RightEdge Forums
Main     Home          Members     Calendar     Who's On

Welcome Guest
        



Simple Crossover Expand / Collapse
Message
Posted 6/10/2006 19:28:15 Post #92
 

Lead DeveloperLead DeveloperLead DeveloperLead DeveloperLead DeveloperLead DeveloperLead DeveloperLead Developer
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 6/23/2008 15:32:10 Post #6045
 

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie
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 6/23/2008 21:21:58 Post #6046
 

DeveloperDeveloperDeveloperDeveloperDeveloperDeveloperDeveloperDeveloper
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);
      }    
   }
}

« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: billb, dplaisted

Permissions Expand / Collapse

All times are GMT -5:00, Time now is 9:57pm

2005-2007 © RightEdge Systems