

If (position lessOrEqual 0 AND signal = Signals.BUY)

If (position lessThan 0 AND signal = Signals.BUY)ĭefault: //Both Long and Short Positions Allowed //Stop and Reverse if there is an open position If (position = 0 AND signal = Signals.SELL) If (position moreThan 0 AND signal = Signals.SELL) If (position = 0 AND signal = Signals.BUY) Int qty = tradeLots * instr.getDefaultQuantity() Ĭase LONG: //Only Long Positions are allowed. Public void onSignal(OrderContext ctx, Object signal) Int qty = tradeLots * ctx.getInstrument().getDefaultQuantity() Ĭase LONG: //Only Long Positions are allowedĬase SHORT: //Only Short Positions are allowed.ĭefault: //Both Long and Short Positions Allowed Int tradeLots = getSettings().getTradeLots() Int ind = series.isLastBarComplete() ? series.size()-1 : series.size()-2 īoolean buy = series.getBoolean(ind, Signals.BUY) īoolean sell = series.getBoolean(ind, Signals.SELL) Calculation public void onActivate(OrderContext ctx)ĭataSeries series = ctx.getDataContext().getDataSeries() Please see our Risk Disclosure and Performance Disclaimer Statement. Important Disclaimer: The information provided on this page is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security. Or go to the top menu, choose Add Study, start typing in this study name until you see it appear in the list, click on the study name, click OK. Go to the top menu, choose Strategies>Tushar Chande>VIDYA2 Strategy

Open the strategy and configure the inputs for General, Display, Trading Options, Panel and Signals. Use the strategy optimiser and back testing to aid in the selection of the period length and alpha values. How To Trade using the automatic VIDYA2 StrategyĮxamine the details of the VIDYA2 study (see link above). This strategy definition is further expressed in the code given in the calculation below. A more comprehensive strategy that may include multiple studies, margins and stops could be developed.

This automated trading strategy was created to demonstrate the mechanics of an automatic trade and is not intended for actual use. Signals generated in the study are used to trigger automatic trades. The VIDYA2 Strategy is based on the VIDYA2 study.
