WealthScript Techniques | Don't execute Strategy on open

Modified on 2010/09/12 13:25 by Eugene — Categorized as: Knowledge Base

The problem

To keep a specific ChartScript from executing right after it is opened, in Wealth-Lab Developer/Pro V4 you were placing {$NO_AUTO_EXECUTE} in your ChartScript; usually at the top. Wealth-Lab Developer/Pro 6 lacks this directive.



The approach

Note: if you open a Strategy with no particular symbol highlighted in the DataSets tree, the Strategy won't execute anyway.

Since there was user demand for that missing directive, here's a simple workaround. If you construct your script like the Example below shows, then it will not execute after opening for the first time (even if you had a symbol highlighted in the DataSets tree). The next time you run the Strategy, it will continue executing as usual.



Code example

Note the placement of NO_AUTO_EXECUTE: it should be declared as class variable, prior to the Execute method.


using System; 
using System.Collections.Generic; 
using System.Text; 
using System.Drawing; 
using WealthLab; 
using WealthLab.Indicators; 

namespace WealthLab.Strategies { public class MyStrategy : WealthScript { bool NO_AUTO_EXECUTE = true; protected override void Execute() { if( NO_AUTO_EXECUTE ) goto halt; else goto go; halt: { NO_AUTO_EXECUTE = false; return; } go: // YOUR STRATEGY CODE GOES HERE DrawLabel( PricePane, "Executed" ); } } }