Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 9th, 2012  |  syntax: None  |  size: 1.09 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2.     using System;
  3.     using System.Collections.Generic;
  4.     using System.Text;
  5.     using WealthLab;
  6.     using WealthLab.Indicators;
  7.     using System.Drawing;
  8.  
  9.     namespace WealthLabCompile
  10.     {
  11.     class DipBuyer : WealthScript
  12.     {
  13.     //Create parameters
  14.  
  15.                 StrategyParameter pctDip;
  16.     public DipBuyer()
  17.     {
  18.                         pctDip = CreateParameter("Dip Percent", 1.77266852407375, 1, 15, 0.5);
  19.     }
  20.  
  21.     protected override void Execute()
  22.     {
  23.     DataSeries trigger = Bars.Close * (1 - pctDip.Value/100);
  24.     // Offset the series by 1 bar to show the crossing
  25.     PlotSeries( PricePane, trigger >> 1, Color.Red, LineStyle.Solid, 1 );
  26.  
  27.             for (int bar = 0; bar < Bars.Count; bar++)
  28.             {
  29.                 if (IsLastPositionActive)
  30.                     SellAtMarket(bar + 1, LastPosition);
  31.                    
  32.             BuyAtLimit(bar + 1, trigger[bar]);
  33.             }
  34.  
  35.             // Give the largest losers the highest priority for simulations
  36.             foreach (Position Pos in Positions)
  37.                 Pos.Priority = -Pos.NetProfitPercent;
  38.         }
  39.  
  40.     }
  41. }