Log in to see Cloud of Tags

Wealth-Lab Wiki

WealthScript Techniques | Don't execute Strategy on open


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

Important Disclaimer: The information provided by Wealth-Lab is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.  The owner of Wealth-Lab.com assumes no liability resulting from the use of the material contained herein for investment purposes. By using this web site, you agree to the terms of this disclaimer and our Terms of Use.

ScrewTurn Wiki. Some of the icons created by FamFamFam.