package com.dukascopy.visualforex.spaima1976; import java.util.*; import com.dukascopy.api.*; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.concurrent.CopyOnWriteArrayList; import java.lang.reflect.*; import java.math.BigDecimal; /* * Created by VisualJForex Generator, version 2.35 * Date: 28.10.2016 10:54 */ public class A2012 implements IStrategy { private CopyOnWriteArrayList tradeEventActions = new CopyOnWriteArrayList(); private static final String DATE_FORMAT_NOW = "yyyyMMdd_HHmmss"; private IEngine engine; private IConsole console; private IHistory history; private IContext context; private IIndicators indicators; private IUserInterface userInterface; @Configurable("defaultSlippage:") public int defaultSlippage = 5; @Configurable("defaultTradeAmount:") public double defaultTradeAmount = 0.001; @Configurable("defaultPeriod:") public Period defaultPeriod = Period.TEN_MINS; @Configurable("defaultInstrument:") public Instrument defaultInstrument = Instrument.EURNZD; @Configurable("defaultTakeProfit:") public int defaultTakeProfit = 50; @Configurable("defaultStopLoss:") public int defaultStopLoss = 25; private String AccountCurrency = ""; private int _tempVar92 = 200; private double _tempVar122 = 1.25; private int _tempVar121 = 200; private Period _tempVar90 = Period.THIRTY_MINS; private double _P_5; private double _P_4; private double _P_3; private double _P_2; private Period _tempVar119 = Period.THIRTY_MINS; private double _P_1; private double _tempVar116 = 1.5; private Period _tempVar95 = Period.THIRTY_MINS; private Tick LastTick = null ; private double _tempVar98 = 0.5; private int _tempVar97 = 200; private int _tempVar115 = 200; private double _P_8; private double _P_7; private double _P_6; private double Equity; private double _lowBand14; private double _lowBand13; private double _lowBand16; private double _lowBand15; private double _tempVar150 = 1.0; private IOrder _Pos_18 = null ; private double _lowBand12; private IOrder _Pos_17 = null ; private double _lowBand11; private double _tempVar110 = 1.75; private Period _tempVar101 = Period.THIRTY_MINS; private Period _tempVar113 = Period.THIRTY_MINS; private List AllPositions = null ; private double _ema10; private Period _tempVar107 = Period.THIRTY_MINS; private int _tempVar109 = 200; private int _tempVar103 = 200; private double _tempVar104 = 0.75; private double _highBand11; private double _highBand12; private IOrder _Pos_15 = null ; private double _highBand13; private IOrder _Pos_16 = null ; private double _highBand14; private IOrder _Pos_13 = null ; private double _highBand15; private IOrder _Pos_14 = null ; private double _highBand16; private double _highBand17; private double _lowBand17; private IOrder _Pos_12 = null ; private Period _tempVar147 = Period.THIRTY_MINS; private double _highBand18; private double _lowBand18; private Candle LastBidCandle = null ; private int _tempVar149 = 2; private double Leverage; private IOrder _Pos_1 = null ; private Period _tempVar142 = Period.THIRTY_MINS; private double _tempVar145 = 1.0; private int _tempVar144 = 2; private int _tempVar139 = 200; private Period _tempVar137 = Period.THIRTY_MINS; private String AccountId = ""; private double UseofLeverage; private double _t319; private List PendingPositions = null ; private Period _tempVar131 = Period.THIRTY_MINS; private int _tempVar133 = 200; private double _tempVar134 = 0.25; private Period _tempVar125 = Period.THIRTY_MINS; private int _tempVar127 = 200; private Candle LastAskCandle = null ; private int MarginCutLevel; private int OverWeekendEndLeverage; private double _tempVar128 = 200.0; private boolean GlobalAccount; private List OpenPositions = null ; private double _t320; private IMessage LastTradeEvent = null ; public void onStart(IContext context) throws JFException { this.engine = context.getEngine(); this.console = context.getConsole(); this.history = context.getHistory(); this.context = context; this.indicators = context.getIndicators(); this.userInterface = context.getUserInterface(); subscriptionInstrumentCheck(defaultInstrument); ITick lastITick = context.getHistory().getLastTick(defaultInstrument); LastTick = new Tick(lastITick, defaultInstrument); IBar bidBar = context.getHistory().getBar(defaultInstrument, defaultPeriod, OfferSide.BID, 1); IBar askBar = context.getHistory().getBar(defaultInstrument, defaultPeriod, OfferSide.ASK, 1); LastAskCandle = new Candle(askBar, defaultPeriod, defaultInstrument, OfferSide.ASK); LastBidCandle = new Candle(bidBar, defaultPeriod, defaultInstrument, OfferSide.BID); if (indicators.getIndicator("EMA") == null) { indicators.registerDownloadableIndicator("12084","EMA"); } if (indicators.getIndicator("EMAENVELOPE") == null) { indicators.registerDownloadableIndicator("1323","EMAENVELOPE"); } if (indicators.getIndicator("EMAENVELOPE") == null) { indicators.registerDownloadableIndicator("1323","EMAENVELOPE"); } if (indicators.getIndicator("EMAENVELOPE") == null) { indicators.registerDownloadableIndicator("1323","EMAENVELOPE"); } if (indicators.getIndicator("EMAENVELOPE") == null) { indicators.registerDownloadableIndicator("1323","EMAENVELOPE"); } if (indicators.getIndicator("EMAENVELOPE") == null) { indicators.registerDownloadableIndicator("1323","EMAENVELOPE"); } if (indicators.getIndicator("EMAENVELOPE") == null) { indicators.registerDownloadableIndicator("1323","EMAENVELOPE"); } if (indicators.getIndicator("EMAENVELOPE") == null) { indicators.registerDownloadableIndicator("1323","EMAENVELOPE"); } if (indicators.getIndicator("EMAENVELOPE") == null) { indicators.registerDownloadableIndicator("1323","EMAENVELOPE"); } if (indicators.getIndicator("T3") == null) { indicators.registerDownloadableIndicator("1311","T3"); } if (indicators.getIndicator("T3") == null) { indicators.registerDownloadableIndicator("1311","T3"); } subscriptionInstrumentCheck(Instrument.fromString("EUR/NZD")); } public void onAccount(IAccount account) throws JFException { AccountCurrency = account.getCurrency().toString(); Leverage = account.getLeverage(); AccountId= account.getAccountId(); Equity = account.getEquity(); UseofLeverage = account.getUseOfLeverage(); OverWeekendEndLeverage = account.getOverWeekEndLeverage(); MarginCutLevel = account.getMarginCutLevel(); GlobalAccount = account.isGlobal(); } private void updateVariables(Instrument instrument) { try { AllPositions = engine.getOrders(); List listMarket = new ArrayList(); for (IOrder order: AllPositions) { if (order.getState().equals(IOrder.State.FILLED)){ listMarket.add(order); } } List listPending = new ArrayList(); for (IOrder order: AllPositions) { if (order.getState().equals(IOrder.State.OPENED)){ listPending.add(order); } } OpenPositions = listMarket; PendingPositions = listPending; } catch(JFException e) { e.printStackTrace(); } } public void onMessage(IMessage message) throws JFException { if (message.getOrder() != null) { updateVariables(message.getOrder().getInstrument()); LastTradeEvent = message; for (TradeEventAction event : tradeEventActions) { IOrder order = message.getOrder(); if (order != null && event != null && message.getType().equals(event.getMessageType())&& order.getLabel().equals(event.getPositionLabel())) { Method method; try { method = this.getClass().getDeclaredMethod(event.getNextBlockId(), Integer.class); method.invoke(this, new Integer[] {event.getFlowId()}); } catch (SecurityException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } tradeEventActions.remove(event); } } } } public void onStop() throws JFException { } public void onTick(Instrument instrument, ITick tick) throws JFException { LastTick = new Tick(tick, instrument); updateVariables(instrument); EMA_block_10(0); } public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException { LastAskCandle = new Candle(askBar, period, instrument, OfferSide.ASK); LastBidCandle = new Candle(bidBar, period, instrument, OfferSide.BID); updateVariables(instrument); EMA_block_10(1); } public void subscriptionInstrumentCheck(Instrument instrument) { try { if (!context.getSubscribedInstruments().contains(instrument)) { Set instruments = new HashSet(); instruments.add(instrument); context.setSubscribedInstruments(instruments, true); Thread.sleep(100); } } catch (InterruptedException e) { e.printStackTrace(); } } public double round(double price, Instrument instrument) { BigDecimal big = new BigDecimal("" + price); big = big.setScale(instrument.getPipScale() + 1, BigDecimal.ROUND_HALF_UP); return big.doubleValue(); } public ITick getLastTick(Instrument instrument) { try { return (context.getHistory().getTick(instrument, 0)); } catch (JFException e) { e.printStackTrace(); } return null; } private void EMA_block_10(Integer flow) { Instrument argument_1 = defaultInstrument; Period argument_2 = _tempVar90; int argument_3 = 0; int argument_4 = _tempVar92; OfferSide[] offerside = new OfferSide[1]; IIndicators.AppliedPrice[] appliedPrice = new IIndicators.AppliedPrice[1]; offerside[0] = OfferSide.BID; appliedPrice[0] = IIndicators.AppliedPrice.CLOSE; Object[] params = new Object[1]; params[0] = _tempVar92; try { subscriptionInstrumentCheck(argument_1); long time = context.getHistory().getBar(argument_1, argument_2, OfferSide.BID, argument_3).getTime(); Object[] indicatorResult = context.getIndicators().calculateIndicator(argument_1, argument_2, offerside, "EMA", appliedPrice, params, Filter.WEEKENDS, 1, time, 0); if ((new Double(((double [])indicatorResult[0])[0])) == null) { this._ema10 = Double.NaN; } else { this._ema10 = (((double [])indicatorResult[0])[0]); } EMAENVELOPE_block_17(flow); } catch (JFException e) { e.printStackTrace(); console.getErr().println(e); this._ema10 = Double.NaN; } } private void EMAENVELOPE_block_11(Integer flow) { Instrument argument_1 = defaultInstrument; Period argument_2 = _tempVar95; int argument_3 = 0; int argument_4 = _tempVar97; double argument_5 = _tempVar98; OfferSide[] offerside = new OfferSide[1]; IIndicators.AppliedPrice[] appliedPrice = new IIndicators.AppliedPrice[1]; offerside[0] = OfferSide.BID; appliedPrice[0] = IIndicators.AppliedPrice.CLOSE; Object[] params = new Object[2]; params[0] = _tempVar97; params[1] = _tempVar98; try { subscriptionInstrumentCheck(argument_1); long time = context.getHistory().getBar(argument_1, argument_2, OfferSide.BID, argument_3).getTime(); Object[] indicatorResult = context.getIndicators().calculateIndicator(argument_1, argument_2, offerside, "EMAENVELOPE", appliedPrice, params, Filter.WEEKENDS, 1, time, 0); if ((new Double(((double [])indicatorResult[0])[0])) == null) { this._lowBand11 = Double.NaN; } else { this._lowBand11 = (((double [])indicatorResult[0])[0]); } if ((new Double(((double [])indicatorResult[1])[0])) == null) { this._highBand11 = Double.NaN; } else { this._highBand11 = (((double [])indicatorResult[1])[0]); } EMAENVELOPE_block_12(flow); } catch (JFException e) { e.printStackTrace(); console.getErr().println(e); this._lowBand11 = Double.NaN; this._highBand11 = Double.NaN; } } private void EMAENVELOPE_block_12(Integer flow) { Instrument argument_1 = defaultInstrument; Period argument_2 = _tempVar101; int argument_3 = 0; int argument_4 = _tempVar103; double argument_5 = _tempVar104; OfferSide[] offerside = new OfferSide[1]; IIndicators.AppliedPrice[] appliedPrice = new IIndicators.AppliedPrice[1]; offerside[0] = OfferSide.BID; appliedPrice[0] = IIndicators.AppliedPrice.CLOSE; Object[] params = new Object[2]; params[0] = _tempVar103; params[1] = _tempVar104; try { subscriptionInstrumentCheck(argument_1); long time = context.getHistory().getBar(argument_1, argument_2, OfferSide.BID, argument_3).getTime(); Object[] indicatorResult = context.getIndicators().calculateIndicator(argument_1, argument_2, offerside, "EMAENVELOPE", appliedPrice, params, Filter.WEEKENDS, 1, time, 0); if ((new Double(((double [])indicatorResult[0])[0])) == null) { this._lowBand12 = Double.NaN; } else { this._lowBand12 = (((double [])indicatorResult[0])[0]); } if ((new Double(((double [])indicatorResult[1])[0])) == null) { this._highBand12 = Double.NaN; } else { this._highBand12 = (((double [])indicatorResult[1])[0]); } EMAENVELOPE_block_18(flow); } catch (JFException e) { e.printStackTrace(); console.getErr().println(e); this._lowBand12 = Double.NaN; this._highBand12 = Double.NaN; } } private void EMAENVELOPE_block_13(Integer flow) { Instrument argument_1 = defaultInstrument; Period argument_2 = _tempVar107; int argument_3 = 0; int argument_4 = _tempVar109; double argument_5 = _tempVar110; OfferSide[] offerside = new OfferSide[1]; IIndicators.AppliedPrice[] appliedPrice = new IIndicators.AppliedPrice[1]; offerside[0] = OfferSide.BID; appliedPrice[0] = IIndicators.AppliedPrice.CLOSE; Object[] params = new Object[2]; params[0] = _tempVar109; params[1] = _tempVar110; try { subscriptionInstrumentCheck(argument_1); long time = context.getHistory().getBar(argument_1, argument_2, OfferSide.BID, argument_3).getTime(); Object[] indicatorResult = context.getIndicators().calculateIndicator(argument_1, argument_2, offerside, "EMAENVELOPE", appliedPrice, params, Filter.WEEKENDS, 1, time, 0); if ((new Double(((double [])indicatorResult[0])[0])) == null) { this._lowBand13 = Double.NaN; } else { this._lowBand13 = (((double [])indicatorResult[0])[0]); } if ((new Double(((double [])indicatorResult[1])[0])) == null) { this._highBand13 = Double.NaN; } else { this._highBand13 = (((double [])indicatorResult[1])[0]); } EMAENVELOPE_block_16(flow); } catch (JFException e) { e.printStackTrace(); console.getErr().println(e); this._lowBand13 = Double.NaN; this._highBand13 = Double.NaN; } } private void EMAENVELOPE_block_14(Integer flow) { Instrument argument_1 = defaultInstrument; Period argument_2 = _tempVar113; int argument_3 = 0; int argument_4 = _tempVar115; double argument_5 = _tempVar116; OfferSide[] offerside = new OfferSide[1]; IIndicators.AppliedPrice[] appliedPrice = new IIndicators.AppliedPrice[1]; offerside[0] = OfferSide.BID; appliedPrice[0] = IIndicators.AppliedPrice.CLOSE; Object[] params = new Object[2]; params[0] = _tempVar115; params[1] = _tempVar116; try { subscriptionInstrumentCheck(argument_1); long time = context.getHistory().getBar(argument_1, argument_2, OfferSide.BID, argument_3).getTime(); Object[] indicatorResult = context.getIndicators().calculateIndicator(argument_1, argument_2, offerside, "EMAENVELOPE", appliedPrice, params, Filter.WEEKENDS, 1, time, 0); if ((new Double(((double [])indicatorResult[0])[0])) == null) { this._lowBand14 = Double.NaN; } else { this._lowBand14 = (((double [])indicatorResult[0])[0]); } if ((new Double(((double [])indicatorResult[1])[0])) == null) { this._highBand14 = Double.NaN; } else { this._highBand14 = (((double [])indicatorResult[1])[0]); } EMAENVELOPE_block_13(flow); } catch (JFException e) { e.printStackTrace(); console.getErr().println(e); this._lowBand14 = Double.NaN; this._highBand14 = Double.NaN; } } private void EMAENVELOPE_block_15(Integer flow) { Instrument argument_1 = defaultInstrument; Period argument_2 = _tempVar119; int argument_3 = 0; int argument_4 = _tempVar121; double argument_5 = _tempVar122; OfferSide[] offerside = new OfferSide[1]; IIndicators.AppliedPrice[] appliedPrice = new IIndicators.AppliedPrice[1]; offerside[0] = OfferSide.BID; appliedPrice[0] = IIndicators.AppliedPrice.CLOSE; Object[] params = new Object[2]; params[0] = _tempVar121; params[1] = _tempVar122; try { subscriptionInstrumentCheck(argument_1); long time = context.getHistory().getBar(argument_1, argument_2, OfferSide.BID, argument_3).getTime(); Object[] indicatorResult = context.getIndicators().calculateIndicator(argument_1, argument_2, offerside, "EMAENVELOPE", appliedPrice, params, Filter.WEEKENDS, 1, time, 0); if ((new Double(((double [])indicatorResult[0])[0])) == null) { this._lowBand15 = Double.NaN; } else { this._lowBand15 = (((double [])indicatorResult[0])[0]); } if ((new Double(((double [])indicatorResult[1])[0])) == null) { this._highBand15 = Double.NaN; } else { this._highBand15 = (((double [])indicatorResult[1])[0]); } EMAENVELOPE_block_14(flow); } catch (JFException e) { e.printStackTrace(); console.getErr().println(e); this._lowBand15 = Double.NaN; this._highBand15 = Double.NaN; } } private void EMAENVELOPE_block_16(Integer flow) { Instrument argument_1 = defaultInstrument; Period argument_2 = _tempVar125; int argument_3 = 0; int argument_4 = _tempVar127; double argument_5 = _tempVar128; OfferSide[] offerside = new OfferSide[1]; IIndicators.AppliedPrice[] appliedPrice = new IIndicators.AppliedPrice[1]; offerside[0] = OfferSide.BID; appliedPrice[0] = IIndicators.AppliedPrice.CLOSE; Object[] params = new Object[2]; params[0] = _tempVar127; params[1] = _tempVar128; try { subscriptionInstrumentCheck(argument_1); long time = context.getHistory().getBar(argument_1, argument_2, OfferSide.BID, argument_3).getTime(); Object[] indicatorResult = context.getIndicators().calculateIndicator(argument_1, argument_2, offerside, "EMAENVELOPE", appliedPrice, params, Filter.WEEKENDS, 1, time, 0); if ((new Double(((double [])indicatorResult[0])[0])) == null) { this._lowBand16 = Double.NaN; } else { this._lowBand16 = (((double [])indicatorResult[0])[0]); } if ((new Double(((double [])indicatorResult[1])[0])) == null) { this._highBand16 = Double.NaN; } else { this._highBand16 = (((double [])indicatorResult[1])[0]); } T3_block_20(flow); } catch (JFException e) { e.printStackTrace(); console.getErr().println(e); this._lowBand16 = Double.NaN; this._highBand16 = Double.NaN; } } private void EMAENVELOPE_block_17(Integer flow) { Instrument argument_1 = defaultInstrument; Period argument_2 = _tempVar131; int argument_3 = 0; int argument_4 = _tempVar133; double argument_5 = _tempVar134; OfferSide[] offerside = new OfferSide[1]; IIndicators.AppliedPrice[] appliedPrice = new IIndicators.AppliedPrice[1]; offerside[0] = OfferSide.BID; appliedPrice[0] = IIndicators.AppliedPrice.CLOSE; Object[] params = new Object[2]; params[0] = _tempVar133; params[1] = _tempVar134; try { subscriptionInstrumentCheck(argument_1); long time = context.getHistory().getBar(argument_1, argument_2, OfferSide.BID, argument_3).getTime(); Object[] indicatorResult = context.getIndicators().calculateIndicator(argument_1, argument_2, offerside, "EMAENVELOPE", appliedPrice, params, Filter.WEEKENDS, 1, time, 0); if ((new Double(((double [])indicatorResult[0])[0])) == null) { this._lowBand17 = Double.NaN; } else { this._lowBand17 = (((double [])indicatorResult[0])[0]); } if ((new Double(((double [])indicatorResult[1])[0])) == null) { this._highBand17 = Double.NaN; } else { this._highBand17 = (((double [])indicatorResult[1])[0]); } EMAENVELOPE_block_11(flow); } catch (JFException e) { e.printStackTrace(); console.getErr().println(e); this._lowBand17 = Double.NaN; this._highBand17 = Double.NaN; } } private void EMAENVELOPE_block_18(Integer flow) { Instrument argument_1 = defaultInstrument; Period argument_2 = _tempVar137; int argument_3 = 0; int argument_4 = _tempVar139; double argument_5 = 1.0; OfferSide[] offerside = new OfferSide[1]; IIndicators.AppliedPrice[] appliedPrice = new IIndicators.AppliedPrice[1]; offerside[0] = OfferSide.BID; appliedPrice[0] = IIndicators.AppliedPrice.CLOSE; Object[] params = new Object[2]; params[0] = _tempVar139; params[1] = 1.0; try { subscriptionInstrumentCheck(argument_1); long time = context.getHistory().getBar(argument_1, argument_2, OfferSide.BID, argument_3).getTime(); Object[] indicatorResult = context.getIndicators().calculateIndicator(argument_1, argument_2, offerside, "EMAENVELOPE", appliedPrice, params, Filter.WEEKENDS, 1, time, 0); if ((new Double(((double [])indicatorResult[0])[0])) == null) { this._lowBand18 = Double.NaN; } else { this._lowBand18 = (((double [])indicatorResult[0])[0]); } if ((new Double(((double [])indicatorResult[1])[0])) == null) { this._highBand18 = Double.NaN; } else { this._highBand18 = (((double [])indicatorResult[1])[0]); } EMAENVELOPE_block_15(flow); } catch (JFException e) { e.printStackTrace(); console.getErr().println(e); this._lowBand18 = Double.NaN; this._highBand18 = Double.NaN; } } private void T3_block_19(Integer flow) { Instrument argument_1 = defaultInstrument; Period argument_2 = _tempVar142; int argument_3 = 0; int argument_4 = _tempVar144; double argument_5 = _tempVar145; OfferSide[] offerside = new OfferSide[1]; IIndicators.AppliedPrice[] appliedPrice = new IIndicators.AppliedPrice[1]; offerside[0] = OfferSide.BID; appliedPrice[0] = IIndicators.AppliedPrice.LOW; Object[] params = new Object[2]; params[0] = _tempVar144; params[1] = _tempVar145; try { subscriptionInstrumentCheck(argument_1); long time = context.getHistory().getBar(argument_1, argument_2, OfferSide.BID, argument_3).getTime(); Object[] indicatorResult = context.getIndicators().calculateIndicator(argument_1, argument_2, offerside, "T3", appliedPrice, params, Filter.WEEKENDS, 1, time, 0); if ((new Double(((double [])indicatorResult[0])[0])) == null) { this._t319 = Double.NaN; } else { this._t319 = (((double [])indicatorResult[0])[0]); } If_block_80(flow); } catch (JFException e) { e.printStackTrace(); console.getErr().println(e); this._t319 = Double.NaN; } } private void T3_block_20(Integer flow) { Instrument argument_1 = defaultInstrument; Period argument_2 = _tempVar147; int argument_3 = 0; int argument_4 = _tempVar149; double argument_5 = _tempVar150; OfferSide[] offerside = new OfferSide[1]; IIndicators.AppliedPrice[] appliedPrice = new IIndicators.AppliedPrice[1]; offerside[0] = OfferSide.BID; appliedPrice[0] = IIndicators.AppliedPrice.HIGH; Object[] params = new Object[2]; params[0] = _tempVar149; params[1] = _tempVar150; try { subscriptionInstrumentCheck(argument_1); long time = context.getHistory().getBar(argument_1, argument_2, OfferSide.BID, argument_3).getTime(); Object[] indicatorResult = context.getIndicators().calculateIndicator(argument_1, argument_2, offerside, "T3", appliedPrice, params, Filter.WEEKENDS, 1, time, 0); if ((new Double(((double [])indicatorResult[0])[0])) == null) { this._t320 = Double.NaN; } else { this._t320 = (((double [])indicatorResult[0])[0]); } T3_block_19(flow); } catch (JFException e) { e.printStackTrace(); console.getErr().println(e); this._t320 = Double.NaN; } } private void CalculationExpression_block_21(Integer flow) { _P_1 = (_t319-_ema10)/ (float)(_lowBand11-_ema10)*100; If_block_29(flow); } private void CalculationExpression_block_22(Integer flow) { _P_2 = (_t319-_lowBand11)/ (float)(_lowBand12-_lowBand11)*100; If_block_38(flow); } private void CalculationExpression_block_23(Integer flow) { _P_5 = (_t319-_lowBand14)/ (float)(_lowBand15-_lowBand14)*100; If_block_55(flow); } private void CalculationExpression_block_24(Integer flow) { _P_3 = (_t319-_lowBand12)/ (float)(_lowBand13-_lowBand12)*100; If_block_45(flow); } private void CalculationExpression_block_25(Integer flow) { _P_6 = (_t319-_lowBand15)/ (float)(_lowBand16-_lowBand15)*100; If_block_56(flow); } private void CalculationExpression_block_26(Integer flow) { _P_4 = (_t319-_lowBand13)/ (float)(_lowBand14-_lowBand13)*100; If_block_46(flow); } private void CalculationExpression_block_27(Integer flow) { _P_8 = (_t319-_lowBand17)/ (float)(_lowBand18-_lowBand17)*100; If_block_69(flow); } private void CalculationExpression_block_28(Integer flow) { _P_7 = (_t319-_lowBand16)/ (float)(_lowBand17-_lowBand16)*100; If_block_65(flow); } private void If_block_29(Integer flow) { double argument_1 = _P_1; double argument_2 = 10.0; if (argument_1< argument_2) { } else if (argument_1> argument_2) { If_block_30(flow); } else if (argument_1== argument_2) { } } private void If_block_30(Integer flow) { double argument_1 = _P_1; double argument_2 = 15.0; if (argument_1< argument_2) { If_block_79(flow); } else if (argument_1> argument_2) { If_block_31(flow); } else if (argument_1== argument_2) { } } private void If_block_31(Integer flow) { double argument_1 = _P_1; double argument_2 = 55.0; if (argument_1< argument_2) { } else if (argument_1> argument_2) { CloseandCancelPosition_block_33(flow); } else if (argument_1== argument_2) { } } private void OpenatMarket_block_32(Integer flow) { Instrument argument_1 = defaultInstrument; double argument_2 = 0.1; int argument_3 = 1; int argument_4 = 1000; int argument_5 = 1000; String argument_6 = ""; ITick tick = getLastTick(argument_1); IEngine.OrderCommand command = IEngine.OrderCommand.BUY; double stopLoss = tick.getBid() - argument_1.getPipValue() * argument_4; double takeProfit = round(tick.getBid() + argument_1.getPipValue() * argument_5, argument_1); try { String label = getLabel(); _Pos_1 = context.getEngine().submitOrder(label, argument_1, command, argument_2, 0, argument_3, stopLoss, takeProfit, 0, argument_6); } catch (JFException e) { e.printStackTrace(); } } private void CloseandCancelPosition_block_33(Integer flow) { try { if (_Pos_1 != null && (_Pos_1.getState() == IOrder.State.OPENED||_Pos_1.getState() == IOrder.State.FILLED)){ _Pos_1.close(); TradeEventAction event = new TradeEventAction(); event.setMessageType(IMessage.Type.ORDER_CLOSE_OK); event.setNextBlockId("CalculationExpression_block_22"); event.setPositionLabel(_Pos_1.getLabel()); event.setFlowId(flow); tradeEventActions.add(event); } } catch (JFException e) { e.printStackTrace(); } } private void If_block_36(Integer flow) { double argument_1 = _P_2; double argument_2 = 55.0; if (argument_1< argument_2) { } else if (argument_1> argument_2) { CloseandCancelPosition_block_39(flow); } else if (argument_1== argument_2) { } } private void If_block_37(Integer flow) { double argument_1 = _P_2; double argument_2 = 15.0; if (argument_1< argument_2) { If_block_78(flow); } else if (argument_1> argument_2) { If_block_36(flow); } else if (argument_1== argument_2) { } } private void If_block_38(Integer flow) { double argument_1 = _P_2; double argument_2 = 10.0; if (argument_1< argument_2) { } else if (argument_1> argument_2) { If_block_37(flow); } else if (argument_1== argument_2) { } } private void CloseandCancelPosition_block_39(Integer flow) { try { if (_Pos_12 != null && (_Pos_12.getState() == IOrder.State.OPENED||_Pos_12.getState() == IOrder.State.FILLED)){ _Pos_12.close(); TradeEventAction event = new TradeEventAction(); event.setMessageType(IMessage.Type.ORDER_CLOSE_OK); event.setNextBlockId("CalculationExpression_block_24"); event.setPositionLabel(_Pos_12.getLabel()); event.setFlowId(flow); tradeEventActions.add(event); } } catch (JFException e) { e.printStackTrace(); } } private void OpenatMarket_block_40(Integer flow) { Instrument argument_1 = defaultInstrument; double argument_2 = 0.5; int argument_3 = 1; int argument_4 = 1000; int argument_5 = 1000; String argument_6 = ""; ITick tick = getLastTick(argument_1); IEngine.OrderCommand command = IEngine.OrderCommand.BUY; double stopLoss = tick.getBid() - argument_1.getPipValue() * argument_4; double takeProfit = round(tick.getBid() + argument_1.getPipValue() * argument_5, argument_1); try { String label = getLabel(); _Pos_12 = context.getEngine().submitOrder(label, argument_1, command, argument_2, 0, argument_3, stopLoss, takeProfit, 0, argument_6); } catch (JFException e) { e.printStackTrace(); } } private void CloseandCancelPosition_block_41(Integer flow) { try { if (_Pos_13 != null && (_Pos_13.getState() == IOrder.State.OPENED||_Pos_13.getState() == IOrder.State.FILLED)){ _Pos_13.close(); TradeEventAction event = new TradeEventAction(); event.setMessageType(IMessage.Type.ORDER_CLOSE_OK); event.setNextBlockId("CalculationExpression_block_26"); event.setPositionLabel(_Pos_13.getLabel()); event.setFlowId(flow); tradeEventActions.add(event); } } catch (JFException e) { e.printStackTrace(); } } private void OpenatMarket_block_42(Integer flow) { Instrument argument_1 = defaultInstrument; double argument_2 = 1.5; int argument_3 = 0; int argument_4 = 1000; int argument_5 = 1000; String argument_6 = ""; ITick tick = getLastTick(argument_1); IEngine.OrderCommand command = IEngine.OrderCommand.BUY; double stopLoss = tick.getBid() - argument_1.getPipValue() * argument_4; double takeProfit = round(tick.getBid() + argument_1.getPipValue() * argument_5, argument_1); try { String label = getLabel(); _Pos_13 = context.getEngine().submitOrder(label, argument_1, command, argument_2, 0, argument_3, stopLoss, takeProfit, 0, argument_6); } catch (JFException e) { e.printStackTrace(); } } private void If_block_43(Integer flow) { double argument_1 = _P_3; double argument_2 = 55.0; if (argument_1< argument_2) { } else if (argument_1> argument_2) { CloseandCancelPosition_block_41(flow); } else if (argument_1== argument_2) { } } private void If_block_44(Integer flow) { double argument_1 = _P_3; double argument_2 = 15.0; if (argument_1< argument_2) { If_block_77(flow); } else if (argument_1> argument_2) { If_block_43(flow); } else if (argument_1== argument_2) { } } private void If_block_45(Integer flow) { double argument_1 = _P_3; double argument_2 = 10.0; if (argument_1< argument_2) { } else if (argument_1> argument_2) { If_block_44(flow); } else if (argument_1== argument_2) { } } private void If_block_46(Integer flow) { double argument_1 = _P_4; double argument_2 = 10.0; if (argument_1< argument_2) { } else if (argument_1> argument_2) { If_block_47(flow); } else if (argument_1== argument_2) { } } private void If_block_47(Integer flow) { double argument_1 = _P_4; double argument_2 = 15.0; if (argument_1< argument_2) { If_block_76(flow); } else if (argument_1> argument_2) { If_block_48(flow); } else if (argument_1== argument_2) { } } private void If_block_48(Integer flow) { double argument_1 = _P_4; double argument_2 = 55.0; if (argument_1< argument_2) { } else if (argument_1> argument_2) { CloseandCancelPosition_block_49(flow); } else if (argument_1== argument_2) { } } private void CloseandCancelPosition_block_49(Integer flow) { try { if (_Pos_14 != null && (_Pos_14.getState() == IOrder.State.OPENED||_Pos_14.getState() == IOrder.State.FILLED)){ _Pos_14.close(); TradeEventAction event = new TradeEventAction(); event.setMessageType(IMessage.Type.ORDER_CLOSE_OK); event.setNextBlockId("CalculationExpression_block_23"); event.setPositionLabel(_Pos_14.getLabel()); event.setFlowId(flow); tradeEventActions.add(event); } } catch (JFException e) { e.printStackTrace(); } } private void OpenatMarket_block_50(Integer flow) { Instrument argument_1 = defaultInstrument; double argument_2 = 2.0; int argument_3 = 1; int argument_4 = 1000; int argument_5 = 1000; String argument_6 = ""; ITick tick = getLastTick(argument_1); IEngine.OrderCommand command = IEngine.OrderCommand.BUY; double stopLoss = tick.getBid() - argument_1.getPipValue() * argument_4; double takeProfit = round(tick.getBid() + argument_1.getPipValue() * argument_5, argument_1); try { String label = getLabel(); _Pos_14 = context.getEngine().submitOrder(label, argument_1, command, argument_2, 0, argument_3, stopLoss, takeProfit, 0, argument_6); } catch (JFException e) { e.printStackTrace(); } } private void CloseandCancelPosition_block_51(Integer flow) { try { if (_Pos_15 != null && (_Pos_15.getState() == IOrder.State.OPENED||_Pos_15.getState() == IOrder.State.FILLED)){ _Pos_15.close(); TradeEventAction event = new TradeEventAction(); event.setMessageType(IMessage.Type.ORDER_CLOSE_OK); event.setNextBlockId("CalculationExpression_block_25"); event.setPositionLabel(_Pos_15.getLabel()); event.setFlowId(flow); tradeEventActions.add(event); } } catch (JFException e) { e.printStackTrace(); } } private void OpenatMarket_block_52(Integer flow) { Instrument argument_1 = defaultInstrument; double argument_2 = 3.0; int argument_3 = 1; int argument_4 = 1000; int argument_5 = 1000; String argument_6 = ""; ITick tick = getLastTick(argument_1); IEngine.OrderCommand command = IEngine.OrderCommand.BUY; double stopLoss = tick.getBid() - argument_1.getPipValue() * argument_4; double takeProfit = round(tick.getBid() + argument_1.getPipValue() * argument_5, argument_1); try { String label = getLabel(); _Pos_15 = context.getEngine().submitOrder(label, argument_1, command, argument_2, 0, argument_3, stopLoss, takeProfit, 0, argument_6); } catch (JFException e) { e.printStackTrace(); } } private void If_block_53(Integer flow) { double argument_1 = _P_5; double argument_2 = 15.0; if (argument_1< argument_2) { If_block_75(flow); } else if (argument_1> argument_2) { If_block_54(flow); } else if (argument_1== argument_2) { } } private void If_block_54(Integer flow) { double argument_1 = _P_5; double argument_2 = 55.0; if (argument_1< argument_2) { } else if (argument_1> argument_2) { CloseandCancelPosition_block_51(flow); } else if (argument_1== argument_2) { } } private void If_block_55(Integer flow) { double argument_1 = _P_5; double argument_2 = 10.0; if (argument_1< argument_2) { } else if (argument_1> argument_2) { If_block_53(flow); } else if (argument_1== argument_2) { } } private void If_block_56(Integer flow) { double argument_1 = _P_6; double argument_2 = 10.0; if (argument_1< argument_2) { } else if (argument_1> argument_2) { If_block_57(flow); } else if (argument_1== argument_2) { } } private void If_block_57(Integer flow) { double argument_1 = _P_6; double argument_2 = 15.0; if (argument_1< argument_2) { If_block_74(flow); } else if (argument_1> argument_2) { If_block_58(flow); } else if (argument_1== argument_2) { } } private void If_block_58(Integer flow) { int argument_1 = defaultTakeProfit; double argument_2 = 55.0; if (argument_1< argument_2) { } else if (argument_1> argument_2) { CloseandCancelPosition_block_59(flow); } else if (argument_1== argument_2) { } } private void CloseandCancelPosition_block_59(Integer flow) { try { if (_Pos_16 != null && (_Pos_16.getState() == IOrder.State.OPENED||_Pos_16.getState() == IOrder.State.FILLED)){ _Pos_16.close(); TradeEventAction event = new TradeEventAction(); event.setMessageType(IMessage.Type.ORDER_CLOSE_OK); event.setNextBlockId("CalculationExpression_block_28"); event.setPositionLabel(_Pos_16.getLabel()); event.setFlowId(flow); tradeEventActions.add(event); } } catch (JFException e) { e.printStackTrace(); } } private void OpenatMarket_block_60(Integer flow) { Instrument argument_1 = defaultInstrument; double argument_2 = 4.0; int argument_3 = 1; int argument_4 = 1000; int argument_5 = 1000; String argument_6 = ""; ITick tick = getLastTick(argument_1); IEngine.OrderCommand command = IEngine.OrderCommand.BUY; double stopLoss = tick.getBid() - argument_1.getPipValue() * argument_4; double takeProfit = round(tick.getBid() + argument_1.getPipValue() * argument_5, argument_1); try { String label = getLabel(); _Pos_16 = context.getEngine().submitOrder(label, argument_1, command, argument_2, 0, argument_3, stopLoss, takeProfit, 0, argument_6); } catch (JFException e) { e.printStackTrace(); } } private void CloseandCancelPosition_block_61(Integer flow) { try { if (_Pos_17 != null && (_Pos_17.getState() == IOrder.State.OPENED||_Pos_17.getState() == IOrder.State.FILLED)){ _Pos_17.close(); TradeEventAction event = new TradeEventAction(); event.setMessageType(IMessage.Type.ORDER_CLOSE_OK); event.setNextBlockId("CalculationExpression_block_27"); event.setPositionLabel(_Pos_17.getLabel()); event.setFlowId(flow); tradeEventActions.add(event); } } catch (JFException e) { e.printStackTrace(); } } private void If_block_63(Integer flow) { double argument_1 = _P_7; double argument_2 = 55.0; if (argument_1< argument_2) { } else if (argument_1> argument_2) { CloseandCancelPosition_block_61(flow); } else if (argument_1== argument_2) { } } private void If_block_64(Integer flow) { double argument_1 = _P_7; double argument_2 = 15.0; if (argument_1< argument_2) { If_block_73(flow); } else if (argument_1> argument_2) { If_block_63(flow); } else if (argument_1== argument_2) { } } private void If_block_65(Integer flow) { double argument_1 = _P_7; double argument_2 = 10.0; if (argument_1< argument_2) { } else if (argument_1> argument_2) { If_block_64(flow); } else if (argument_1== argument_2) { } } private void OpenatMarket_block_66(Integer flow) { Instrument argument_1 = defaultInstrument; double argument_2 = 6.0; int argument_3 = 1; int argument_4 = 1000; int argument_5 = 1000; String argument_6 = ""; ITick tick = getLastTick(argument_1); IEngine.OrderCommand command = IEngine.OrderCommand.BUY; double stopLoss = tick.getBid() - argument_1.getPipValue() * argument_4; double takeProfit = round(tick.getBid() + argument_1.getPipValue() * argument_5, argument_1); try { String label = getLabel(); _Pos_17 = context.getEngine().submitOrder(label, argument_1, command, argument_2, 0, argument_3, stopLoss, takeProfit, 0, argument_6); } catch (JFException e) { e.printStackTrace(); } } private void CloseandCancelPosition_block_67(Integer flow) { try { if (_Pos_18 != null && (_Pos_18.getState() == IOrder.State.OPENED||_Pos_18.getState() == IOrder.State.FILLED)){ _Pos_18.close(); TradeEventAction event = new TradeEventAction(); event.setMessageType(IMessage.Type.ORDER_CLOSE_OK); event.setNextBlockId("If_block_96"); event.setPositionLabel(_Pos_18.getLabel()); event.setFlowId(flow); tradeEventActions.add(event); } } catch (JFException e) { e.printStackTrace(); } } private void OpenatMarket_block_68(Integer flow) { Instrument argument_1 = defaultInstrument; double argument_2 = 8.0; int argument_3 = 1; int argument_4 = 1000; int argument_5 = 1000; String argument_6 = ""; ITick tick = getLastTick(argument_1); IEngine.OrderCommand command = IEngine.OrderCommand.BUY; double stopLoss = tick.getBid() - argument_1.getPipValue() * argument_4; double takeProfit = round(tick.getBid() + argument_1.getPipValue() * argument_5, argument_1); try { String label = getLabel(); _Pos_18 = context.getEngine().submitOrder(label, argument_1, command, argument_2, 0, argument_3, stopLoss, takeProfit, 0, argument_6); } catch (JFException e) { e.printStackTrace(); } } private void If_block_69(Integer flow) { double argument_1 = _P_8; double argument_2 = 10.0; if (argument_1< argument_2) { } else if (argument_1> argument_2) { If_block_70(flow); } else if (argument_1== argument_2) { } } private void If_block_70(Integer flow) { double argument_1 = _P_8; double argument_2 = 15.0; if (argument_1< argument_2) { If_block_72(flow); } else if (argument_1> argument_2) { If_block_71(flow); } else if (argument_1== argument_2) { } } private void If_block_71(Integer flow) { double argument_1 = _P_8; double argument_2 = 55.0; if (argument_1< argument_2) { } else if (argument_1> argument_2) { CloseandCancelPosition_block_67(flow); } else if (argument_1== argument_2) { } } private void If_block_72(Integer flow) { int argument_1 = AllPositions.size(); int argument_2 = 1; if (argument_1< argument_2) { OpenatMarket_block_68(flow); } else if (argument_1> argument_2) { } else if (argument_1== argument_2) { } } private void If_block_73(Integer flow) { int argument_1 = AllPositions.size(); int argument_2 = 1; if (argument_1< argument_2) { OpenatMarket_block_66(flow); } else if (argument_1> argument_2) { } else if (argument_1== argument_2) { } } private void If_block_74(Integer flow) { int argument_1 = AllPositions.size(); int argument_2 = 1; if (argument_1< argument_2) { OpenatMarket_block_60(flow); } else if (argument_1> argument_2) { } else if (argument_1== argument_2) { } } private void If_block_75(Integer flow) { int argument_1 = AllPositions.size(); int argument_2 = 1; if (argument_1< argument_2) { OpenatMarket_block_52(flow); } else if (argument_1> argument_2) { } else if (argument_1== argument_2) { } } private void If_block_76(Integer flow) { int argument_1 = AllPositions.size(); int argument_2 = 1; if (argument_1< argument_2) { OpenatMarket_block_50(flow); } else if (argument_1> argument_2) { } else if (argument_1== argument_2) { } } private void If_block_77(Integer flow) { int argument_1 = AllPositions.size(); int argument_2 = 1; if (argument_1< argument_2) { OpenatMarket_block_42(flow); } else if (argument_1> argument_2) { } else if (argument_1== argument_2) { } } private void If_block_78(Integer flow) { int argument_1 = AllPositions.size(); int argument_2 = 1; if (argument_1< argument_2) { OpenatMarket_block_40(flow); } else if (argument_1> argument_2) { } else if (argument_1== argument_2) { } } private void If_block_79(Integer flow) { int argument_1 = AllPositions.size(); int argument_2 = 1; if (argument_1< argument_2) { OpenatMarket_block_32(flow); } else if (argument_1> argument_2) { } else if (argument_1== argument_2) { } } private void If_block_80(Integer flow) { double argument_1 = _t319; double argument_2 = _ema10; if (argument_1< argument_2) { MultipleAction_block_81(flow); } else if (argument_1> argument_2) { } else if (argument_1== argument_2) { } } private void MultipleAction_block_81(Integer flow) { If_block_85(flow); CalculationExpression_block_21(flow); } private void If_block_82(Integer flow) { double argument_1 = _t320; double argument_2 = _lowBand13; if (argument_1< argument_2) { If_block_91(flow); } else if (argument_1> argument_2) { CloseandCancelPosition_block_89(flow); } else if (argument_1== argument_2) { } } private void If_block_83(Integer flow) { double argument_1 = _t320; double argument_2 = _lowBand12; if (argument_1< argument_2) { If_block_82(flow); } else if (argument_1> argument_2) { CloseandCancelPosition_block_88(flow); } else if (argument_1== argument_2) { } } private void If_block_84(Integer flow) { double argument_1 = _t320; double argument_2 = _lowBand11; if (argument_1< argument_2) { If_block_83(flow); } else if (argument_1> argument_2) { CloseandCancelPosition_block_87(flow); } else if (argument_1== argument_2) { } } private void If_block_85(Integer flow) { double argument_1 = _t320; double argument_2 = _ema10; if (argument_1< argument_2) { If_block_84(flow); } else if (argument_1> argument_2) { CloseandCancelPosition_block_86(flow); } else if (argument_1== argument_2) { } } private void CloseandCancelPosition_block_86(Integer flow) { try { if (_Pos_12 != null && (_Pos_12.getState() == IOrder.State.OPENED||_Pos_12.getState() == IOrder.State.FILLED)){ _Pos_12.close(); } } catch (JFException e) { e.printStackTrace(); } } private void CloseandCancelPosition_block_87(Integer flow) { try { if (_Pos_13 != null && (_Pos_13.getState() == IOrder.State.OPENED||_Pos_13.getState() == IOrder.State.FILLED)){ _Pos_13.close(); } } catch (JFException e) { e.printStackTrace(); } } private void CloseandCancelPosition_block_88(Integer flow) { try { if (_Pos_14 != null && (_Pos_14.getState() == IOrder.State.OPENED||_Pos_14.getState() == IOrder.State.FILLED)){ _Pos_14.close(); } } catch (JFException e) { e.printStackTrace(); } } private void CloseandCancelPosition_block_89(Integer flow) { try { if (_Pos_15 != null && (_Pos_15.getState() == IOrder.State.OPENED||_Pos_15.getState() == IOrder.State.FILLED)){ _Pos_15.close(); } } catch (JFException e) { e.printStackTrace(); } } private void CloseandCancelPosition_block_90(Integer flow) { try { if (_Pos_16 != null && (_Pos_16.getState() == IOrder.State.OPENED||_Pos_16.getState() == IOrder.State.FILLED)){ _Pos_16.close(); } } catch (JFException e) { e.printStackTrace(); } } private void If_block_91(Integer flow) { double argument_1 = _t320; double argument_2 = _lowBand14; if (argument_1< argument_2) { If_block_92(flow); } else if (argument_1> argument_2) { CloseandCancelPosition_block_90(flow); } else if (argument_1== argument_2) { } } private void If_block_92(Integer flow) { double argument_1 = _t320; double argument_2 = _lowBand15; if (argument_1< argument_2) { If_block_95(flow); } else if (argument_1> argument_2) { CloseandCancelPosition_block_93(flow); } else if (argument_1== argument_2) { } } private void CloseandCancelPosition_block_93(Integer flow) { try { if (_Pos_17 != null && (_Pos_17.getState() == IOrder.State.OPENED||_Pos_17.getState() == IOrder.State.FILLED)){ _Pos_17.close(); } } catch (JFException e) { e.printStackTrace(); } } private void CloseandCancelPosition_block_94(Integer flow) { try { if (_Pos_18 != null && (_Pos_18.getState() == IOrder.State.OPENED||_Pos_18.getState() == IOrder.State.FILLED)){ _Pos_18.close(); } } catch (JFException e) { e.printStackTrace(); } } private void If_block_95(Integer flow) { double argument_1 = _t320; double argument_2 = _lowBand16; if (argument_1< argument_2) { } else if (argument_1> argument_2) { CloseandCancelPosition_block_94(flow); } else if (argument_1== argument_2) { } } private void If_block_96(Integer flow) { double argument_1 = _t319; double argument_2 = _lowBand18; if (argument_1< argument_2) { If_block_98(flow); } else if (argument_1> argument_2) { } else if (argument_1== argument_2) { } } private void OpenatMarket_block_97(Integer flow) { Instrument argument_1 = defaultInstrument; double argument_2 = 10.0; int argument_3 = defaultSlippage; int argument_4 = 100; int argument_5 = 100; String argument_6 = ""; ITick tick = getLastTick(argument_1); IEngine.OrderCommand command = IEngine.OrderCommand.BUY; double stopLoss = tick.getBid() - argument_1.getPipValue() * argument_4; double takeProfit = round(tick.getBid() + argument_1.getPipValue() * argument_5, argument_1); try { String label = getLabel(); IOrder order = context.getEngine().submitOrder(label, argument_1, command, argument_2, 0, argument_3, stopLoss, takeProfit, 0, argument_6); } catch (JFException e) { e.printStackTrace(); } } private void If_block_98(Integer flow) { int argument_1 = AllPositions.size(); int argument_2 = 1; if (argument_1< argument_2) { OpenatMarket_block_97(flow); } else if (argument_1> argument_2) { } else if (argument_1== argument_2) { } } class Candle { IBar bar; Period period; Instrument instrument; OfferSide offerSide; public Candle(IBar bar, Period period, Instrument instrument, OfferSide offerSide) { this.bar = bar; this.period = period; this.instrument = instrument; this.offerSide = offerSide; } public Period getPeriod() { return period; } public void setPeriod(Period period) { this.period = period; } public Instrument getInstrument() { return instrument; } public void setInstrument(Instrument instrument) { this.instrument = instrument; } public OfferSide getOfferSide() { return offerSide; } public void setOfferSide(OfferSide offerSide) { this.offerSide = offerSide; } public IBar getBar() { return bar; } public void setBar(IBar bar) { this.bar = bar; } public long getTime() { return bar.getTime(); } public double getOpen() { return bar.getOpen(); } public double getClose() { return bar.getClose(); } public double getLow() { return bar.getLow(); } public double getHigh() { return bar.getHigh(); } public double getVolume() { return bar.getVolume(); } } class Tick { private ITick tick; private Instrument instrument; public Tick(ITick tick, Instrument instrument){ this.instrument = instrument; this.tick = tick; } public Instrument getInstrument(){ return instrument; } public double getAsk(){ return tick.getAsk(); } public double getBid(){ return tick.getBid(); } public double getAskVolume(){ return tick.getAskVolume(); } public double getBidVolume(){ return tick.getBidVolume(); } public long getTime(){ return tick.getTime(); } public ITick getTick(){ return tick; } } protected String getLabel() { String label; label = "IVF" + getCurrentTime(LastTick.getTime()) + generateRandom(10000) + generateRandom(10000); return label; } private String getCurrentTime(long time) { SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW); return sdf.format(time); } private static String generateRandom(int n) { int randomNumber = (int) (Math.random() * n); String answer = "" + randomNumber; if (answer.length() > 3) { answer = answer.substring(0, 4); } return answer; } class TradeEventAction { private IMessage.Type messageType; private String nextBlockId = ""; private String positionLabel = ""; private int flowId = 0; public IMessage.Type getMessageType() { return messageType; } public void setMessageType(IMessage.Type messageType) { this.messageType = messageType; } public String getNextBlockId() { return nextBlockId; } public void setNextBlockId(String nextBlockId) { this.nextBlockId = nextBlockId; } public String getPositionLabel() { return positionLabel; } public void setPositionLabel(String positionLabel) { this.positionLabel = positionLabel; } public int getFlowId() { return flowId; } public void setFlowId(int flowId) { this.flowId = flowId; } } }