package com.dukascopy.visualforex.visualjforex;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMessage.RecipientType;

import com.dukascopy.api.Configurable;
import com.dukascopy.api.Filter;
import com.dukascopy.api.IAccount;
import com.dukascopy.api.IBar;
import com.dukascopy.api.IConsole;
import com.dukascopy.api.IContext;
import com.dukascopy.api.IEngine;
import com.dukascopy.api.IHistory;
import com.dukascopy.api.IIndicators;
import com.dukascopy.api.IMessage;
import com.dukascopy.api.IOrder;
import com.dukascopy.api.IStrategy;
import com.dukascopy.api.ITick;
import com.dukascopy.api.IUserInterface;
import com.dukascopy.api.Instrument;
import com.dukascopy.api.JFException;
import com.dukascopy.api.Library;
import com.dukascopy.api.OfferSide;
import com.dukascopy.api.Period;
import com.dukascopy.api.RequiresFullAccess;
import com.dukascopy.connector.engine.Properties;




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: 12.03.2017 16:45
 */
 
 
 
@RequiresFullAccess
@Library("C:\\Users\nesca\\Dropbox (Personal)\\Strategie Automatizzate\\Procedura Invio mail\\javax.mail.jar")

public class ENGULFING_Ottimizzato_AUDCAD implements IStrategy {

    private CopyOnWriteArrayList<TradeEventAction> tradeEventActions = new CopyOnWriteArrayList<TradeEventAction>();
    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("defaultTakeProfit:")
    public int defaultTakeProfit = 10;
    @Configurable("defaultTradeAmount:")
    public double defaultTradeAmount = 0.001;
    @Configurable("defaultInstrument:")
    public Instrument defaultInstrument = Instrument.AUDCAD;
    @Configurable("defaultSlippage:")
    public int defaultSlippage = 5;
    @Configurable("defaultStopLoss:")
    public int defaultStopLoss = 25;
    @Configurable("defaultPeriod:")
    public Period defaultPeriod = Period.FIFTEEN_MINS;
    List<ISignal> listSignals81 = new ArrayList<ISignal>();
    IDownloadableStrategy strategy81 = null;
    List<ISignal> listSignals90 = new ArrayList<ISignal>();
    IDownloadableStrategy strategy90 = null;
    List<ISignal> listSignals133 = new ArrayList<ISignal>();
    IDownloadableStrategy strategy133 = null;
    List<ISignal> listSignals134 = new ArrayList<ISignal>();
    IDownloadableStrategy strategy134 = null;
    List<ISignal> listSignals161 = new ArrayList<ISignal>();
    IDownloadableStrategy strategy161 = null;
    List<ISignal> listSignals163 = new ArrayList<ISignal>();
    IDownloadableStrategy strategy163 = null;
    List<ISignal> listSignals191 = new ArrayList<ISignal>();
    IDownloadableStrategy strategy191 = null;
    List<ISignal> listSignals192 = new ArrayList<ISignal>();
    IDownloadableStrategy strategy192 = null;
    List<ISignal> listSignals220 = new ArrayList<ISignal>();
    IDownloadableStrategy strategy220 = null;
    List<ISignal> listSignals222 = new ArrayList<ISignal>();
    IDownloadableStrategy strategy222 = null;

    private Candle _Candela_che_abbraccia =  null ;
    private double _Parte_bassa_cand_prec;
    private int _tempVar106 = 2;
    private Tick LastTick =  null ;
    private String AccountCurrency = "";
    private double _Ombra_bassa_cand_che_abbr;
    private Candle _Candela_precedente =  null ;
    private double Leverage;
    private Period _tempVar90 = Period.ONE_HOUR;
    private Period _tempVar92 = Period.DAILY;
    private Period _tempVar91 = Period.FOUR_HOURS;
    private Period _tempVar93 = Period.WEEKLY;
    private double _Livello_min_apertura_sec_cand;
    private double _Vincolo_Range;
    private double _Parte_alta_cand_Prec;
    private int _tempVar285 = 3;
    private int _tempVar284 = 5;
    private int _tempVar287 = 3;
    private int _tempVar286 = 5;
    private Candle LastAskCandle =  null ;
    private double _tempVar281 = 0.92;
    private double _Vincolo_ombre_prec;
    private Candle LastBidCandle =  null ;
    private String AccountId = "";
    private double _Range_candela_precedente;
    private double Equity;
    private double _Range_Candela_che_abbraccia;
    private double _tempVar329 = 2.0;
    private int OverWeekendEndLeverage;
    private double _Ombra_alta_cand_che_abbr;
    private int _tempVar294 = 5;
    private double _tempVar297 = 0.5298;
    private Period _tempVar1310 = Period.FIFTEEN_MINS;
    private List<IOrder> PendingPositions =  null ;
    private int _tempVar258 = 1;
    private double _Porzione_minima_abbraccio;
    private List<IOrder> OpenPositions =  null ;
    private double _RANGE_CAND_CHE_ABBR;
    private double UseofLeverage;
    private IMessage LastTradeEvent =  null ;
    private boolean GlobalAccount;
    private double _Parte_alta_cand_che_abbr;
    private double _Livello_max_apertura_seconda_cand;
    private double _Parte_bassa_Cand_che_abbr;
    private double _Ombra_Bassa_Cand_prec;
    private int MarginCutLevel;
    private List<IOrder> AllPositions =  null ;
    private double _Vincolo_ombre_cand_che_abbr;
    private double _Range_minimo;
    private double _RANGE_CAND_PREC;
    private double _Ombra_alta_cand_prec;


private Session session = null ;
    
    @Configurable("Recipient mail")
   private String[] mailAddress = {"X@gmail.com","Y@gmail.com"};
    
    @Configurable("SMTP Server")
    public String smtpServer = "Q";
    private static final String username = "Z";
    private static final String password = "W";


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

        HashMap<String, Object> map81 = new HashMap<String, Object>();
        map81.put("Sound Signal:", "RING");
        map81.put("Beep on Testing:", true);
        strategy81 = context.getDownloadableStrategies().init("11000","Sound Alert", context, IDownloadableStrategy.ComponentType.BLOCK_STRATEGY, IEngine.StrategyMode.SIGNALS, map81);
        HashMap<String, Object> map90 = new HashMap<String, Object>();
        map90.put("Sound Signal:", "RING");
        map90.put("Beep on Testing:", true);
        strategy90 = context.getDownloadableStrategies().init("11000","Sound Alert", context, IDownloadableStrategy.ComponentType.BLOCK_STRATEGY, IEngine.StrategyMode.SIGNALS, map90);
        HashMap<String, Object> map133 = new HashMap<String, Object>();
        map133.put("Sound Signal:", "RING");
        map133.put("Beep on Testing:", true);
        strategy133 = context.getDownloadableStrategies().init("11000","Sound Alert", context, IDownloadableStrategy.ComponentType.BLOCK_STRATEGY, IEngine.StrategyMode.SIGNALS, map133);
        HashMap<String, Object> map134 = new HashMap<String, Object>();
        map134.put("Sound Signal:", "RING");
        map134.put("Beep on Testing:", true);
        strategy134 = context.getDownloadableStrategies().init("11000","Sound Alert", context, IDownloadableStrategy.ComponentType.BLOCK_STRATEGY, IEngine.StrategyMode.SIGNALS, map134);
        HashMap<String, Object> map161 = new HashMap<String, Object>();
        map161.put("Sound Signal:", "RING");
        map161.put("Beep on Testing:", true);
        strategy161 = context.getDownloadableStrategies().init("11000","Sound Alert", context, IDownloadableStrategy.ComponentType.BLOCK_STRATEGY, IEngine.StrategyMode.SIGNALS, map161);
        HashMap<String, Object> map163 = new HashMap<String, Object>();
        map163.put("Sound Signal:", "RING");
        map163.put("Beep on Testing:", true);
        strategy163 = context.getDownloadableStrategies().init("11000","Sound Alert", context, IDownloadableStrategy.ComponentType.BLOCK_STRATEGY, IEngine.StrategyMode.SIGNALS, map163);
        HashMap<String, Object> map191 = new HashMap<String, Object>();
        map191.put("Sound Signal:", "RING");
        map191.put("Beep on Testing:", true);
        strategy191 = context.getDownloadableStrategies().init("11000","Sound Alert", context, IDownloadableStrategy.ComponentType.BLOCK_STRATEGY, IEngine.StrategyMode.SIGNALS, map191);
        HashMap<String, Object> map192 = new HashMap<String, Object>();
        map192.put("Sound Signal:", "RING");
        map192.put("Beep on Testing:", true);
        strategy192 = context.getDownloadableStrategies().init("11000","Sound Alert", context, IDownloadableStrategy.ComponentType.BLOCK_STRATEGY, IEngine.StrategyMode.SIGNALS, map192);
        HashMap<String, Object> map220 = new HashMap<String, Object>();
        map220.put("Sound Signal:", "RING");
        map220.put("Beep on Testing:", true);
        strategy220 = context.getDownloadableStrategies().init("11000","Sound Alert", context, IDownloadableStrategy.ComponentType.BLOCK_STRATEGY, IEngine.StrategyMode.SIGNALS, map220);
        HashMap<String, Object> map222 = new HashMap<String, Object>();
        map222.put("Sound Signal:", "RING");
        map222.put("Beep on Testing:", true);
        strategy222 = context.getDownloadableStrategies().init("11000","Sound Alert", context, IDownloadableStrategy.ComponentType.BLOCK_STRATEGY, IEngine.StrategyMode.SIGNALS, map222);
        subscriptionInstrumentCheck(Instrument.fromString("AUD/CAD"));

    }

    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<IOrder> listMarket = new ArrayList<IOrder>();
            for (IOrder order: AllPositions) {
                if (order.getState().equals(IOrder.State.FILLED)){
                    listMarket.add(order);
                }
            }
            List<IOrder> listPending = new ArrayList<IOrder>();
            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);


    }

    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);
            If_block_10(1);

    }

    public void subscriptionInstrumentCheck(Instrument instrument) {
        try {
              if (!context.getSubscribedInstruments().contains(instrument)) {
                  Set<Instrument> instruments = new HashSet<Instrument>();
                  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 If_block_10(Integer flow) {
        Instrument argument_1 = defaultInstrument;
        Instrument argument_2 = LastBidCandle.getInstrument();
        if (argument_1 == null && argument_2 !=null || (argument_1!= null && !argument_1.equals(argument_2))) {
        }
        else if (argument_1!= null && argument_1.equals(argument_2)) {
            MultipleAction_block_11(flow);
        }
    }

    private  void MultipleAction_block_11(Integer flow) {
        If_block_12(flow);
        If_block_13(flow);
        If_block_14(flow);
        If_block_15(flow);
        If_block_16(flow);
    }

    private  void If_block_12(Integer flow) {
        Period argument_1 = LastAskCandle.getPeriod();
        Period argument_2 = _tempVar1310;
        if (argument_1 == null && argument_2 !=null || (argument_1!= null && !argument_1.equals(argument_2))) {
        }
        else if (argument_1!= null && argument_1.equals(argument_2)) {
            GetHistoricalCandle_block_24(flow);
        }
    }

    private  void If_block_13(Integer flow) {
        Period argument_1 = LastAskCandle.getPeriod();
        Period argument_2 = _tempVar90;
        if (argument_1 == null && argument_2 !=null || (argument_1!= null && !argument_1.equals(argument_2))) {
        }
        else if (argument_1!= null && argument_1.equals(argument_2)) {
            GetHistoricalCandle_block_25(flow);
        }
    }

    private  void If_block_14(Integer flow) {
        Period argument_1 = LastAskCandle.getPeriod();
        Period argument_2 = _tempVar91;
        if (argument_1 == null && argument_2 !=null || (argument_1!= null && !argument_1.equals(argument_2))) {
        }
        else if (argument_1!= null && argument_1.equals(argument_2)) {
            GetHistoricalCandle_block_26(flow);
        }
    }

    private  void If_block_15(Integer flow) {
        Period argument_1 = LastAskCandle.getPeriod();
        Period argument_2 = _tempVar92;
        if (argument_1 == null && argument_2 !=null || (argument_1!= null && !argument_1.equals(argument_2))) {
        }
        else if (argument_1!= null && argument_1.equals(argument_2)) {
            GetHistoricalCandle_block_27(flow);
        }
    }

    private  void If_block_16(Integer flow) {
        Period argument_1 = LastAskCandle.getPeriod();
        Period argument_2 = _tempVar93;
        if (argument_1 == null && argument_2 !=null || (argument_1!= null && !argument_1.equals(argument_2))) {
        }
        else if (argument_1!= null && argument_1.equals(argument_2)) {
            GetHistoricalCandle_block_28(flow);
        }
    }

    private  void GetHistoricalCandle_block_24(Integer flow) {
        Instrument argument_1 = defaultInstrument;
        Period argument_2 = _tempVar1310;
        OfferSide argument_3 = OfferSide.BID;
        int argument_4 = _tempVar106;
            subscriptionInstrumentCheck(argument_1);
         
        try {
            IBar tempBar = history.getBar(argument_1, argument_2, argument_3, argument_4); 
            _Candela_precedente = new Candle(tempBar, argument_2, argument_1, argument_3); 
        } catch (JFException e) {
            e.printStackTrace();
        }
        GetHistoricalCandle_block_29(flow);
    }

    private  void GetHistoricalCandle_block_25(Integer flow) {
        Instrument argument_1 = defaultInstrument;
        Period argument_2 = _tempVar90;
        OfferSide argument_3 = OfferSide.BID;
        int argument_4 = _tempVar106;
            subscriptionInstrumentCheck(argument_1);
         
        try {
            IBar tempBar = history.getBar(argument_1, argument_2, argument_3, argument_4); 
            _Candela_precedente = new Candle(tempBar, argument_2, argument_1, argument_3); 
        } catch (JFException e) {
            e.printStackTrace();
        }
        GetHistoricalCandle_block_30(flow);
    }

    private  void GetHistoricalCandle_block_26(Integer flow) {
        Instrument argument_1 = defaultInstrument;
        Period argument_2 = Period.FOUR_HOURS;
        OfferSide argument_3 = OfferSide.BID;
        int argument_4 = _tempVar106;
            subscriptionInstrumentCheck(argument_1);
         
        try {
            IBar tempBar = history.getBar(argument_1, argument_2, argument_3, argument_4); 
            _Candela_precedente = new Candle(tempBar, argument_2, argument_1, argument_3); 
        } catch (JFException e) {
            e.printStackTrace();
        }
        GetHistoricalCandle_block_31(flow);
    }

    private  void GetHistoricalCandle_block_27(Integer flow) {
        Instrument argument_1 = defaultInstrument;
        Period argument_2 = _tempVar92;
        OfferSide argument_3 = OfferSide.BID;
        int argument_4 = _tempVar106;
            subscriptionInstrumentCheck(argument_1);
         
        try {
            IBar tempBar = history.getBar(argument_1, argument_2, argument_3, argument_4); 
            _Candela_precedente = new Candle(tempBar, argument_2, argument_1, argument_3); 
        } catch (JFException e) {
            e.printStackTrace();
        }
        GetHistoricalCandle_block_32(flow);
    }

    private  void GetHistoricalCandle_block_28(Integer flow) {
        Instrument argument_1 = defaultInstrument;
        Period argument_2 = _tempVar93;
        OfferSide argument_3 = OfferSide.BID;
        int argument_4 = _tempVar106;
            subscriptionInstrumentCheck(argument_1);
         
        try {
            IBar tempBar = history.getBar(argument_1, argument_2, argument_3, argument_4); 
            _Candela_precedente = new Candle(tempBar, argument_2, argument_1, argument_3); 
        } catch (JFException e) {
            e.printStackTrace();
        }
        GetHistoricalCandle_block_33(flow);
    }

    private  void GetHistoricalCandle_block_29(Integer flow) {
        Instrument argument_1 = defaultInstrument;
        Period argument_2 = _tempVar1310;
        OfferSide argument_3 = OfferSide.BID;
        int argument_4 = _tempVar258;
            subscriptionInstrumentCheck(argument_1);
         
        try {
            IBar tempBar = history.getBar(argument_1, argument_2, argument_3, argument_4); 
            _Candela_che_abbraccia = new Candle(tempBar, argument_2, argument_1, argument_3); 
        } catch (JFException e) {
            e.printStackTrace();
        }
        CalculationExpression_block_50(flow);
    }

    private  void GetHistoricalCandle_block_30(Integer flow) {
        Instrument argument_1 = defaultInstrument;
        Period argument_2 = _tempVar90;
        OfferSide argument_3 = OfferSide.BID;
        int argument_4 = _tempVar258;
            subscriptionInstrumentCheck(argument_1);
         
        try {
            IBar tempBar = history.getBar(argument_1, argument_2, argument_3, argument_4); 
            _Candela_che_abbraccia = new Candle(tempBar, argument_2, argument_1, argument_3); 
        } catch (JFException e) {
            e.printStackTrace();
        }
        CalculationExpression_block_102(flow);
    }

    private  void GetHistoricalCandle_block_31(Integer flow) {
        Instrument argument_1 = defaultInstrument;
        Period argument_2 = _tempVar91;
        OfferSide argument_3 = OfferSide.BID;
        int argument_4 = _tempVar258;
            subscriptionInstrumentCheck(argument_1);
         
        try {
            IBar tempBar = history.getBar(argument_1, argument_2, argument_3, argument_4); 
            _Candela_che_abbraccia = new Candle(tempBar, argument_2, argument_1, argument_3); 
        } catch (JFException e) {
            e.printStackTrace();
        }
        CalculationExpression_block_135(flow);
    }

    private  void GetHistoricalCandle_block_32(Integer flow) {
        Instrument argument_1 = defaultInstrument;
        Period argument_2 = _tempVar92;
        OfferSide argument_3 = OfferSide.BID;
        int argument_4 = _tempVar258;
            subscriptionInstrumentCheck(argument_1);
         
        try {
            IBar tempBar = history.getBar(argument_1, argument_2, argument_3, argument_4); 
            _Candela_che_abbraccia = new Candle(tempBar, argument_2, argument_1, argument_3); 
        } catch (JFException e) {
            e.printStackTrace();
        }
        CalculationExpression_block_170(flow);
    }

    private  void GetHistoricalCandle_block_33(Integer flow) {
        Instrument argument_1 = defaultInstrument;
        Period argument_2 = _tempVar93;
        OfferSide argument_3 = OfferSide.BID;
        int argument_4 = _tempVar258;
            subscriptionInstrumentCheck(argument_1);
         
        try {
            IBar tempBar = history.getBar(argument_1, argument_2, argument_3, argument_4); 
            _Candela_che_abbraccia = new Candle(tempBar, argument_2, argument_1, argument_3); 
        } catch (JFException e) {
            e.printStackTrace();
        }
        CalculationExpression_block_203(flow);
    }

    private void CalculationExpression_block_50(Integer flow) {
        _Parte_alta_cand_Prec = Math.max(_Candela_precedente.getClose(),_Candela_precedente.getOpen());
        CalculationExpression_block_51(flow);
    }

    private void CalculationExpression_block_51(Integer flow) {
        _Parte_bassa_cand_prec = Math.min(_Candela_precedente.getClose(),_Candela_precedente.getOpen());
        CalculationExpression_block_52(flow);
    }

    private void CalculationExpression_block_52(Integer flow) {
        _Parte_alta_cand_che_abbr = Math.max(_Candela_che_abbraccia.getOpen(),_Candela_che_abbraccia.getClose());
        CalculationExpression_block_53(flow);
    }

    private void CalculationExpression_block_53(Integer flow) {
        _Parte_bassa_Cand_che_abbr = Math.min(_Candela_che_abbraccia.getOpen(),_Candela_che_abbraccia.getClose());
        Calculation_block_54(flow);
    }

    private void Calculation_block_54(Integer flow) {
        double argument_1 = _Candela_precedente.getHigh();
        double argument_2 = _Parte_alta_cand_Prec;
        _Ombra_alta_cand_prec = argument_1 - argument_2;
        Calculation_block_55(flow);
    }

    private void Calculation_block_55(Integer flow) {
        double argument_1 = _Parte_bassa_cand_prec;
        double argument_2 = _Candela_precedente.getLow();
        _Ombra_Bassa_Cand_prec = argument_1 - argument_2;
        Calculation_block_56(flow);
    }

    private void Calculation_block_56(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getHigh();
        double argument_2 = _Parte_alta_cand_che_abbr;
        _Ombra_alta_cand_che_abbr = argument_1 - argument_2;
        Calculation_block_57(flow);
    }

    private void Calculation_block_57(Integer flow) {
        double argument_1 = _Parte_bassa_Cand_che_abbr;
        double argument_2 = _Candela_che_abbraccia.getLow();
        _Ombra_bassa_cand_che_abbr = argument_1 - argument_2;
        Calculation_block_58(flow);
    }

    private void Calculation_block_58(Integer flow) {
        double argument_1 = _Parte_alta_cand_Prec;
        double argument_2 = _Parte_bassa_cand_prec;
        _RANGE_CAND_PREC = argument_1 - argument_2;
        Calculation_block_59(flow);
    }

    private void Calculation_block_59(Integer flow) {
        double argument_1 = _Parte_alta_cand_che_abbr;
        double argument_2 = _Parte_bassa_Cand_che_abbr;
        _RANGE_CAND_CHE_ABBR = argument_1 - argument_2;
        Calculation_block_60(flow);
    }

    private void Calculation_block_60(Integer flow) {
        double argument_1 = _RANGE_CAND_PREC;
        double argument_2 = _tempVar329;
        _Vincolo_ombre_prec = argument_1 / argument_2;
        Calculation_block_61(flow);
    }

    private void Calculation_block_61(Integer flow) {
        double argument_1 = _RANGE_CAND_CHE_ABBR;
        double argument_2 = _tempVar329;
        _Vincolo_ombre_cand_che_abbr = argument_1 / argument_2;
        If_block_62(flow);
    }

    private  void If_block_62(Integer flow) {
        double argument_1 = _Ombra_alta_cand_prec;
        double argument_2 = _Vincolo_ombre_prec;
        if (argument_1< argument_2) {
            If_block_63(flow);
        }
        else if (argument_1> argument_2) {
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_63(Integer flow) {
        double argument_1 = _Ombra_Bassa_Cand_prec;
        double argument_2 = _Vincolo_ombre_prec;
        if (argument_1< argument_2) {
            If_block_64(flow);
        }
        else if (argument_1> argument_2) {
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_64(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getHigh();
        double argument_2 = _Candela_precedente.getHigh();
        if (argument_1< argument_2) {
        }
        else if (argument_1> argument_2) {
            If_block_65(flow);
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_65(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getLow();
        double argument_2 = _Candela_precedente.getLow();
        if (argument_1< argument_2) {
            If_block_66(flow);
        }
        else if (argument_1> argument_2) {
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_66(Integer flow) {
        double argument_1 = _Candela_precedente.getClose();
        double argument_2 = _Candela_precedente.getOpen();
        if (argument_1< argument_2) {
            If_block_67(flow);
        }
        else if (argument_1> argument_2) {
            If_block_68(flow);
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_67(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getClose();
        double argument_2 = _Candela_che_abbraccia.getOpen();
        if (argument_1< argument_2) {
        }
        else if (argument_1> argument_2) {
            Calculation_block_72(flow);
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_68(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getOpen();
        double argument_2 = _Candela_che_abbraccia.getClose();
        if (argument_1< argument_2) {
        }
        else if (argument_1> argument_2) {
            Calculation_block_69(flow);
        }
        else if (argument_1== argument_2) {
        }
    }

    private void Calculation_block_69(Integer flow) {
        double argument_1 = _Candela_precedente.getClose();
        double argument_2 = _Candela_precedente.getOpen();
        _Range_candela_precedente = argument_1 - argument_2;
        Calculation_block_70(flow);
    }

    private void Calculation_block_70(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getOpen();
        double argument_2 = _Candela_che_abbraccia.getClose();
        _Range_Candela_che_abbraccia = argument_1 - argument_2;
        If_block_87(flow);
    }

    private void Calculation_block_71(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getClose();
        double argument_2 = _Candela_che_abbraccia.getOpen();
        _Range_Candela_che_abbraccia = argument_1 - argument_2;
        If_block_95(flow);
    }

    private void Calculation_block_72(Integer flow) {
        double argument_1 = _Candela_precedente.getOpen();
        double argument_2 = _Candela_precedente.getClose();
        _Range_candela_precedente = argument_1 - argument_2;
        Calculation_block_71(flow);
    }

    private  void SoundAlert_block_81(Integer flow) {
        try {
            List<ISignal> signals81 = null;
            switch (flow) {
                case 0:
                    signals81 = strategy81.onTick(LastTick.getInstrument(), LastTick.getTick());
                    break;
                case 1:
                    signals81 = strategy81.onBar(LastAskCandle.getInstrument(), LastAskCandle.getPeriod(), LastAskCandle.getBar(), LastBidCandle.getBar());
                    break;
                case 2:
                    signals81 = strategy81.onMessage(LastTradeEvent);
                    break;
                default:
                    signals81 = strategy81.onTick(LastTick.getInstrument(), LastTick.getTick());
                    break;
            }
        } catch (JFException e) {
            e.printStackTrace();
        }
        try {
                               //Invio email di prova 
                sendMail("Engulfing Rialzista AUD/CAD tf 15Min", "Formazione di un Engulfing rialzista su TF 15 Min, strumento AUD/CAD testata il 01/04/2017, New_engulfing dropbox cartella strategie automatizzate. Senza indicazioni di sell o buy, la strategia inserisce la procedura di invio delle mail dopo il sound relativo alle condizioni. Parametri del candelone: 2 (1.2 settimanale) volte range medio_7 . Questa formazione non è stata filtrata con altri indicatori.  " +" \n Buon Trading");
          
        } catch (Exception e) {
            // TODO Auto-generated catch block
            System.err.print("Error send email during order Engulfing Rialzista AUD/CAD tf 15Min:" + e.getMessage());
            e.printStackTrace();
        }
    }

    private  void If_block_87(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getClose();
        double argument_2 = _Candela_precedente.getOpen();
        if (argument_1< argument_2) {
            If_block_91(flow);
        }
        else if (argument_1> argument_2) {
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void SoundAlert_block_90(Integer flow) {
        try {
            List<ISignal> signals90 = null;
            switch (flow) {
                case 0:
                    signals90 = strategy90.onTick(LastTick.getInstrument(), LastTick.getTick());
                    break;
                case 1:
                    signals90 = strategy90.onBar(LastAskCandle.getInstrument(), LastAskCandle.getPeriod(), LastAskCandle.getBar(), LastBidCandle.getBar());
                    break;
                case 2:
                    signals90 = strategy90.onMessage(LastTradeEvent);
                    break;
                default:
                    signals90 = strategy90.onTick(LastTick.getInstrument(), LastTick.getTick());
                    break;
            }
        } catch (JFException e) {
            e.printStackTrace();
        }
         try {
                               //Invio email di prova 
                sendMail("Engulfing Ribassista AUD/CAD tf 15Min", "Formazione di un ENGULFING Ribassista su TF 15 Min, AUD/CAD testata il 01/04/2017, ENGULFING_XYZABC dropbox cartella strategie automatizzate. Senza indicazioni di sell o buy, la strategia inserisce la procedura di invio delle mail dopo il sound relativo alle condizioni. Parametri del candelone: 2 (1.2 settimanale) volte range medio_7 . Questa formazione non è stata filtrata con altri indicatori.  " +" \n Buon Trading");
          
        } catch (Exception e) {
            // TODO Auto-generated catch block
            System.err.print("Error send email during order ENGULFING Ribassista AUD/CAD tf 15Min:" + e.getMessage());
            e.printStackTrace();
        }
        
    }

    private  void If_block_91(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getOpen();
        double argument_2 = _Candela_precedente.getClose();
        if (argument_1< argument_2) {
        }
        else if (argument_1> argument_2) {
            Calculation_block_93(flow);
        }
        else if (argument_1== argument_2) {
            Calculation_block_93(flow);
        }
    }

    private void Calculation_block_93(Integer flow) {
        double argument_1 = _Range_Candela_che_abbraccia;
        double argument_2 = 0.7;
        _Vincolo_Range = argument_1 * argument_2;
        If_block_94(flow);
    }

    private  void If_block_94(Integer flow) {
        double argument_1 = _Range_candela_precedente;
        double argument_2 = _Vincolo_Range;
        if (argument_1< argument_2) {
            SoundAlert_block_90(flow);
        }
        else if (argument_1> argument_2) {
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_95(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getClose();
        double argument_2 = _Candela_precedente.getOpen();
        if (argument_1< argument_2) {
        }
        else if (argument_1> argument_2) {
            If_block_96(flow);
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_96(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getOpen();
        double argument_2 = _Candela_precedente.getClose();
        if (argument_1< argument_2) {
            Calculation_block_97(flow);
        }
        else if (argument_1> argument_2) {
        }
        else if (argument_1== argument_2) {
            Calculation_block_97(flow);
        }
    }

    private void Calculation_block_97(Integer flow) {
        double argument_1 = _Range_Candela_che_abbraccia;
        double argument_2 = 0.7;
        _Vincolo_Range = argument_1 * argument_2;
        If_block_98(flow);
    }

    private  void If_block_98(Integer flow) {
        double argument_1 = _Range_candela_precedente;
        double argument_2 = _Vincolo_Range;
        if (argument_1< argument_2) {
            SoundAlert_block_81(flow);
        }
        else if (argument_1> argument_2) {
        }
        else if (argument_1== argument_2) {
        }
    }

    private void CalculationExpression_block_102(Integer flow) {
        _Parte_alta_cand_Prec = Math.max(_Candela_precedente.getClose(),_Candela_precedente.getOpen());
        CalculationExpression_block_103(flow);
    }

    private void CalculationExpression_block_103(Integer flow) {
        _Parte_bassa_cand_prec = Math.min(_Candela_precedente.getClose(),_Candela_precedente.getOpen());
        CalculationExpression_block_104(flow);
    }

    private void CalculationExpression_block_104(Integer flow) {
        _Parte_alta_cand_che_abbr = Math.max(_Candela_che_abbraccia.getOpen(),_Candela_che_abbraccia.getClose());
        CalculationExpression_block_105(flow);
    }

    private void CalculationExpression_block_105(Integer flow) {
        _Parte_bassa_Cand_che_abbr = Math.min(_Candela_che_abbraccia.getOpen(),_Candela_che_abbraccia.getClose());
        Calculation_block_106(flow);
    }

    private void Calculation_block_106(Integer flow) {
        double argument_1 = _Candela_precedente.getHigh();
        double argument_2 = _Parte_alta_cand_Prec;
        _Ombra_alta_cand_prec = argument_1 - argument_2;
        Calculation_block_107(flow);
    }

    private void Calculation_block_107(Integer flow) {
        double argument_1 = _Parte_bassa_cand_prec;
        double argument_2 = _Candela_precedente.getLow();
        _Ombra_Bassa_Cand_prec = argument_1 - argument_2;
        Calculation_block_108(flow);
    }

    private void Calculation_block_108(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getHigh();
        double argument_2 = _Parte_alta_cand_che_abbr;
        _Ombra_alta_cand_che_abbr = argument_1 - argument_2;
        Calculation_block_109(flow);
    }

    private void Calculation_block_109(Integer flow) {
        double argument_1 = _Parte_bassa_Cand_che_abbr;
        double argument_2 = _Candela_che_abbraccia.getLow();
        _Ombra_bassa_cand_che_abbr = argument_1 - argument_2;
        Calculation_block_110(flow);
    }

    private void Calculation_block_110(Integer flow) {
        double argument_1 = _Parte_alta_cand_Prec;
        double argument_2 = _Parte_bassa_cand_prec;
        _RANGE_CAND_PREC = argument_1 - argument_2;
        Calculation_block_111(flow);
    }

    private void Calculation_block_111(Integer flow) {
        double argument_1 = _Parte_alta_cand_che_abbr;
        double argument_2 = _Parte_bassa_Cand_che_abbr;
        _RANGE_CAND_CHE_ABBR = argument_1 - argument_2;
        Calculation_block_112(flow);
    }

    private void Calculation_block_112(Integer flow) {
        double argument_1 = _RANGE_CAND_PREC;
        double argument_2 = _tempVar329;
        _Vincolo_ombre_prec = argument_1 / argument_2;
        Calculation_block_113(flow);
    }

    private void Calculation_block_113(Integer flow) {
        double argument_1 = _RANGE_CAND_CHE_ABBR;
        double argument_2 = _tempVar329;
        _Vincolo_ombre_cand_che_abbr = argument_1 / argument_2;
        If_block_114(flow);
    }

    private  void If_block_114(Integer flow) {
        double argument_1 = _Ombra_alta_cand_prec;
        double argument_2 = _Vincolo_ombre_prec;
        if (argument_1< argument_2) {
            If_block_115(flow);
        }
        else if (argument_1> argument_2) {
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_115(Integer flow) {
        double argument_1 = _Ombra_Bassa_Cand_prec;
        double argument_2 = _Vincolo_ombre_prec;
        if (argument_1< argument_2) {
            If_block_116(flow);
        }
        else if (argument_1> argument_2) {
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_116(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getHigh();
        double argument_2 = _Candela_precedente.getHigh();
        if (argument_1< argument_2) {
        }
        else if (argument_1> argument_2) {
            If_block_117(flow);
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_117(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getLow();
        double argument_2 = _Parte_alta_cand_che_abbr;
        if (argument_1< argument_2) {
            If_block_118(flow);
        }
        else if (argument_1> argument_2) {
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_118(Integer flow) {
        double argument_1 = _Candela_precedente.getClose();
        double argument_2 = _Candela_precedente.getOpen();
        if (argument_1< argument_2) {
            If_block_119(flow);
        }
        else if (argument_1> argument_2) {
            If_block_120(flow);
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_119(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getClose();
        double argument_2 = _Candela_che_abbraccia.getOpen();
        if (argument_1< argument_2) {
        }
        else if (argument_1> argument_2) {
            Calculation_block_122(flow);
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_120(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getOpen();
        double argument_2 = _Candela_che_abbraccia.getClose();
        if (argument_1< argument_2) {
        }
        else if (argument_1> argument_2) {
            Calculation_block_121(flow);
        }
        else if (argument_1== argument_2) {
        }
    }

    private void Calculation_block_121(Integer flow) {
        double argument_1 = _Candela_precedente.getClose();
        double argument_2 = _Candela_precedente.getOpen();
        _Range_candela_precedente = argument_1 - argument_2;
        Calculation_block_124(flow);
    }

    private void Calculation_block_122(Integer flow) {
        double argument_1 = _Candela_precedente.getOpen();
        double argument_2 = _Candela_precedente.getClose();
        _Range_candela_precedente = argument_1 - argument_2;
        Calculation_block_123(flow);
    }

    private void Calculation_block_123(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getClose();
        double argument_2 = _Candela_che_abbraccia.getOpen();
        _Range_Candela_che_abbraccia = argument_1 - argument_2;
        If_block_126(flow);
    }

    private void Calculation_block_124(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getOpen();
        double argument_2 = _Candela_che_abbraccia.getClose();
        _Range_Candela_che_abbraccia = argument_1 - argument_2;
        If_block_125(flow);
    }

    private  void If_block_125(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getClose();
        double argument_2 = _Candela_precedente.getOpen();
        if (argument_1< argument_2) {
            If_block_128(flow);
        }
        else if (argument_1> argument_2) {
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_126(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getClose();
        double argument_2 = _Candela_precedente.getOpen();
        if (argument_1< argument_2) {
        }
        else if (argument_1> argument_2) {
            If_block_127(flow);
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_127(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getOpen();
        double argument_2 = _Candela_precedente.getClose();
        if (argument_1< argument_2) {
            Calculation_block_130(flow);
        }
        else if (argument_1> argument_2) {
        }
        else if (argument_1== argument_2) {
            Calculation_block_130(flow);
        }
    }

    private  void If_block_128(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getOpen();
        double argument_2 = _Candela_precedente.getClose();
        if (argument_1< argument_2) {
        }
        else if (argument_1> argument_2) {
            Calculation_block_129(flow);
        }
        else if (argument_1== argument_2) {
            Calculation_block_129(flow);
        }
    }

    private void Calculation_block_129(Integer flow) {
        double argument_1 = _Range_Candela_che_abbraccia;
        double argument_2 = 0.8;
        _Vincolo_Range = argument_1 * argument_2;
        If_block_132(flow);
    }

    private void Calculation_block_130(Integer flow) {
        double argument_1 = _Range_Candela_che_abbraccia;
        double argument_2 = 0.8;
        _Vincolo_Range = argument_1 * argument_2;
        If_block_131(flow);
    }

    private  void If_block_131(Integer flow) {
        double argument_1 = _Range_candela_precedente;
        double argument_2 = _Vincolo_Range;
        if (argument_1< argument_2) {
            SoundAlert_block_134(flow);
        }
        else if (argument_1> argument_2) {
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_132(Integer flow) {
        double argument_1 = _Range_candela_precedente;
        double argument_2 = _Vincolo_Range;
        if (argument_1< argument_2) {
            SoundAlert_block_133(flow);
        }
        else if (argument_1> argument_2) {
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void SoundAlert_block_133(Integer flow) {
        try {
            List<ISignal> signals133 = null;
            switch (flow) {
                case 0:
                    signals133 = strategy133.onTick(LastTick.getInstrument(), LastTick.getTick());
                    break;
                case 1:
                    signals133 = strategy133.onBar(LastAskCandle.getInstrument(), LastAskCandle.getPeriod(), LastAskCandle.getBar(), LastBidCandle.getBar());
                    break;
                case 2:
                    signals133 = strategy133.onMessage(LastTradeEvent);
                    break;
                default:
                    signals133 = strategy133.onTick(LastTick.getInstrument(), LastTick.getTick());
                    break;
            }
        } catch (JFException e) {
            e.printStackTrace();
        }
         try {
                               //Invio email di prova 
                sendMail("Engulfing Rialzista AUD/CAD tf 1H", "Formazione di un ENGULFING Rialzista su TF 1H, AUD/CAD testata il 01/04/2017, ENGULFING_XYZABC dropbox cartella strategie automatizzate. Senza indicazioni di sell o buy, la strategia inserisce la procedura di invio delle mail dopo il sound relativo alle condizioni. Parametri del candelone: 2 (1.2 settimanale) volte range medio_7 . Questa formazione non è stata filtrata con altri indicatori.  " +" \n Buon Trading");
          
        } catch (Exception e) {
            // TODO Auto-generated catch block
            System.err.print("Error send email during order ENGULFING Rialzista AUD/CAD tf 1H:" + e.getMessage());
            e.printStackTrace();
        }
    }

    private  void SoundAlert_block_134(Integer flow) {
        try {
            List<ISignal> signals134 = null;
            switch (flow) {
                case 0:
                    signals134 = strategy134.onTick(LastTick.getInstrument(), LastTick.getTick());
                    break;
                case 1:
                    signals134 = strategy134.onBar(LastAskCandle.getInstrument(), LastAskCandle.getPeriod(), LastAskCandle.getBar(), LastBidCandle.getBar());
                    break;
                case 2:
                    signals134 = strategy134.onMessage(LastTradeEvent);
                    break;
                default:
                    signals134 = strategy134.onTick(LastTick.getInstrument(), LastTick.getTick());
                    break;
            }
        } catch (JFException e) {
            e.printStackTrace();
        }
         try {
                               //Invio email di prova 
                sendMail("Engulfing Ribassista AUD/CAD tf 1H", "Formazione di un ENGULFING Ribassista su TF 1H, AUD/CAD testata il 01/04/2017, ENGULFING_XYZABC dropbox cartella strategie automatizzate. Senza indicazioni di sell o buy, la strategia inserisce la procedura di invio delle mail dopo il sound relativo alle condizioni. Parametri del candelone: 2 (1.2 settimanale) volte range medio_7 . Questa formazione non è stata filtrata con altri indicatori.  " +" \n Buon Trading");
          
        } catch (Exception e) {
            // TODO Auto-generated catch block
            System.err.print("Error send email during order ENGULFING Ribassista AUD/CAD tf 1H:" + e.getMessage());
            e.printStackTrace();
        }
        
    }

    private void CalculationExpression_block_135(Integer flow) {
        _Parte_alta_cand_Prec = Math.max(_Candela_precedente.getClose(),_Candela_precedente.getOpen());
        CalculationExpression_block_136(flow);
    }

    private void CalculationExpression_block_136(Integer flow) {
        _Parte_bassa_cand_prec = Math.min(_Candela_precedente.getClose(),_Candela_precedente.getOpen());
        CalculationExpression_block_137(flow);
    }

    private void CalculationExpression_block_137(Integer flow) {
        _Parte_alta_cand_che_abbr = Math.max(_Candela_che_abbraccia.getOpen(),_Candela_che_abbraccia.getClose());
        CalculationExpression_block_138(flow);
    }

    private void CalculationExpression_block_138(Integer flow) {
        _Parte_bassa_Cand_che_abbr = Math.min(_Candela_che_abbraccia.getOpen(),_Candela_che_abbraccia.getClose());
        Calculation_block_139(flow);
    }

    private void Calculation_block_139(Integer flow) {
        double argument_1 = _Candela_precedente.getHigh();
        double argument_2 = _Parte_alta_cand_Prec;
        _Ombra_alta_cand_prec = argument_1 - argument_2;
        Calculation_block_140(flow);
    }

    private void Calculation_block_140(Integer flow) {
        double argument_1 = _Parte_bassa_cand_prec;
        double argument_2 = _Candela_precedente.getLow();
        _Ombra_Bassa_Cand_prec = argument_1 - argument_2;
        Calculation_block_141(flow);
    }

    private void Calculation_block_141(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getHigh();
        double argument_2 = _Parte_alta_cand_che_abbr;
        _Ombra_alta_cand_che_abbr = argument_1 - argument_2;
        Calculation_block_142(flow);
    }

    private void Calculation_block_142(Integer flow) {
        double argument_1 = _Parte_bassa_Cand_che_abbr;
        double argument_2 = _Candela_che_abbraccia.getLow();
        _Ombra_bassa_cand_che_abbr = argument_1 - argument_2;
        Calculation_block_143(flow);
    }

    private void Calculation_block_143(Integer flow) {
        double argument_1 = _Parte_alta_cand_Prec;
        double argument_2 = _Parte_bassa_cand_prec;
        _RANGE_CAND_PREC = argument_1 - argument_2;
        Calculation_block_144(flow);
    }

    private void Calculation_block_144(Integer flow) {
        double argument_1 = _Parte_alta_cand_che_abbr;
        double argument_2 = _Parte_bassa_Cand_che_abbr;
        _RANGE_CAND_CHE_ABBR = argument_1 - argument_2;
        Calculation_block_145(flow);
    }

    private void Calculation_block_145(Integer flow) {
        double argument_1 = _RANGE_CAND_PREC;
        double argument_2 = _tempVar329;
        _Vincolo_ombre_prec = argument_1 / argument_2;
        Calculation_block_146(flow);
    }

    private void Calculation_block_146(Integer flow) {
        double argument_1 = _RANGE_CAND_CHE_ABBR;
        double argument_2 = _tempVar329;
        _Vincolo_ombre_cand_che_abbr = argument_1 / argument_2;
        If_block_147(flow);
    }

    private  void If_block_147(Integer flow) {
        double argument_1 = _Ombra_alta_cand_prec;
        double argument_2 = _Vincolo_ombre_prec;
        if (argument_1< argument_2) {
            If_block_148(flow);
        }
        else if (argument_1> argument_2) {
            If_block_148(flow);
        }
        else if (argument_1== argument_2) {
            If_block_148(flow);
        }
    }

    private  void If_block_148(Integer flow) {
        double argument_1 = _Ombra_Bassa_Cand_prec;
        double argument_2 = _Vincolo_ombre_prec;
        if (argument_1< argument_2) {
            If_block_149(flow);
        }
        else if (argument_1> argument_2) {
            If_block_149(flow);
        }
        else if (argument_1== argument_2) {
            If_block_149(flow);
        }
    }

    private  void If_block_149(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getHigh();
        double argument_2 = _Candela_precedente.getHigh();
        if (argument_1< argument_2) {
        }
        else if (argument_1> argument_2) {
            If_block_150(flow);
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_150(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getLow();
        double argument_2 = _Candela_precedente.getLow();
        if (argument_1< argument_2) {
            If_block_153(flow);
        }
        else if (argument_1> argument_2) {
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_151(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getOpen();
        double argument_2 = _Candela_precedente.getClose();
        if (argument_1< argument_2) {
            Calculation_block_152(flow);
        }
        else if (argument_1> argument_2) {
        }
        else if (argument_1== argument_2) {
            Calculation_block_152(flow);
        }
    }

    private void Calculation_block_152(Integer flow) {
        double argument_1 = _Range_Candela_che_abbraccia;
        double argument_2 = 0.8;
        _Vincolo_Range = argument_1 * argument_2;
        If_block_160(flow);
    }

    private  void If_block_153(Integer flow) {
        double argument_1 = _Candela_precedente.getClose();
        double argument_2 = _Candela_precedente.getOpen();
        if (argument_1< argument_2) {
            If_block_154(flow);
        }
        else if (argument_1> argument_2) {
            If_block_155(flow);
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_154(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getClose();
        double argument_2 = _Candela_che_abbraccia.getOpen();
        if (argument_1< argument_2) {
        }
        else if (argument_1> argument_2) {
            Calculation_block_159(flow);
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_155(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getOpen();
        double argument_2 = _Candela_che_abbraccia.getClose();
        if (argument_1< argument_2) {
        }
        else if (argument_1> argument_2) {
            Calculation_block_156(flow);
        }
        else if (argument_1== argument_2) {
        }
    }

    private void Calculation_block_156(Integer flow) {
        double argument_1 = _Candela_precedente.getClose();
        double argument_2 = _Candela_precedente.getOpen();
        _Range_candela_precedente = argument_1 - argument_2;
        Calculation_block_157(flow);
    }

    private void Calculation_block_157(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getOpen();
        double argument_2 = _Candela_che_abbraccia.getClose();
        _Range_Candela_che_abbraccia = argument_1 - argument_2;
        If_block_162(flow);
    }

    private void Calculation_block_158(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getClose();
        double argument_2 = _Candela_che_abbraccia.getOpen();
        _Range_Candela_che_abbraccia = argument_1 - argument_2;
        If_block_167(flow);
    }

    private void Calculation_block_159(Integer flow) {
        double argument_1 = _Candela_precedente.getOpen();
        double argument_2 = _Candela_precedente.getClose();
        _Range_candela_precedente = argument_1 - argument_2;
        Calculation_block_158(flow);
    }

    private  void If_block_160(Integer flow) {
        double argument_1 = _Range_candela_precedente;
        double argument_2 = _Vincolo_Range;
        if (argument_1< argument_2) {
            SoundAlert_block_161(flow);
        }
        else if (argument_1> argument_2) {
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void SoundAlert_block_161(Integer flow) {
        try {
            List<ISignal> signals161 = null;
            switch (flow) {
                case 0:
                    signals161 = strategy161.onTick(LastTick.getInstrument(), LastTick.getTick());
                    break;
                case 1:
                    signals161 = strategy161.onBar(LastAskCandle.getInstrument(), LastAskCandle.getPeriod(), LastAskCandle.getBar(), LastBidCandle.getBar());
                    break;
                case 2:
                    signals161 = strategy161.onMessage(LastTradeEvent);
                    break;
                default:
                    signals161 = strategy161.onTick(LastTick.getInstrument(), LastTick.getTick());
                    break;
            }
        } catch (JFException e) {
            e.printStackTrace();
        }
         try {
                               //Invio email di prova 
                sendMail("Engulfing Rialzista AUD/CAD tf 4H", "Formazione di un ENGULFING Rialzista su TF 4H, AUD/CAD testata il 01/04/2017, ENGULFING_XYZABC dropbox cartella strategie automatizzate. Senza indicazioni di sell o buy, la strategia inserisce la procedura di invio delle mail dopo il sound relativo alle condizioni. Parametri del candelone: 2 (1.2 settimanale) volte range medio_7 . Questa formazione non è stata filtrata con altri indicatori.  " +" \n Buon Trading");
          
        } catch (Exception e) {
            // TODO Auto-generated catch block
            System.err.print("Error send email during order ENGULFING Rialzista AUD/CAD tf 4H:" + e.getMessage());
            e.printStackTrace();
        }
    }

    private  void If_block_162(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getClose();
        double argument_2 = _Candela_precedente.getOpen();
        if (argument_1< argument_2) {
            If_block_164(flow);
        }
        else if (argument_1> argument_2) {
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void SoundAlert_block_163(Integer flow) {
        try {
            List<ISignal> signals163 = null;
            switch (flow) {
                case 0:
                    signals163 = strategy163.onTick(LastTick.getInstrument(), LastTick.getTick());
                    break;
                case 1:
                    signals163 = strategy163.onBar(LastAskCandle.getInstrument(), LastAskCandle.getPeriod(), LastAskCandle.getBar(), LastBidCandle.getBar());
                    break;
                case 2:
                    signals163 = strategy163.onMessage(LastTradeEvent);
                    break;
                default:
                    signals163 = strategy163.onTick(LastTick.getInstrument(), LastTick.getTick());
                    break;
            }
        } catch (JFException e) {
            e.printStackTrace();
        }
         try {
                               //Invio email di prova 
                sendMail("Engulfing Ribassista AUD/CAD tf 4H", "Formazione di un ENGULFING Ribassista su TF 4H, AUD/CAD testata il 01/04/2017, ENGULFING_XYZABC dropbox cartella strategie automatizzate. Senza indicazioni di sell o buy, la strategia inserisce la procedura di invio delle mail dopo il sound relativo alle condizioni. Parametri del candelone: 2 (1.2 settimanale) volte range medio_7 . Questa formazione non è stata filtrata con altri indicatori.  " +" \n Buon Trading");
          
        } catch (Exception e) {
            // TODO Auto-generated catch block
            System.err.print("Error send email during order ENGULFING Ribassista AUD/CAD tf 4H:" + e.getMessage());
            e.printStackTrace();
        }
    }

    private  void If_block_164(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getOpen();
        double argument_2 = _Candela_precedente.getClose();
        if (argument_1< argument_2) {
        }
        else if (argument_1> argument_2) {
            Calculation_block_165(flow);
        }
        else if (argument_1== argument_2) {
            Calculation_block_165(flow);
        }
    }

    private void Calculation_block_165(Integer flow) {
        double argument_1 = _Range_Candela_che_abbraccia;
        double argument_2 = 0.8;
        _Vincolo_Range = argument_1 * argument_2;
        If_block_166(flow);
    }

    private  void If_block_166(Integer flow) {
        double argument_1 = _Range_candela_precedente;
        double argument_2 = _Vincolo_Range;
        if (argument_1< argument_2) {
            SoundAlert_block_163(flow);
        }
        else if (argument_1> argument_2) {
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_167(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getClose();
        double argument_2 = _Candela_precedente.getOpen();
        if (argument_1< argument_2) {
        }
        else if (argument_1> argument_2) {
            If_block_151(flow);
        }
        else if (argument_1== argument_2) {
        }
    }

    private void CalculationExpression_block_170(Integer flow) {
        _Parte_alta_cand_Prec = Math.max(_Candela_precedente.getClose(),_Candela_precedente.getOpen());
        CalculationExpression_block_171(flow);
    }

    private void CalculationExpression_block_171(Integer flow) {
        _Parte_bassa_cand_prec = Math.min(_Candela_precedente.getClose(),_Candela_precedente.getOpen());
        CalculationExpression_block_172(flow);
    }

    private void CalculationExpression_block_172(Integer flow) {
        _Parte_alta_cand_che_abbr = Math.max(_Candela_che_abbraccia.getOpen(),_Candela_che_abbraccia.getClose());
        CalculationExpression_block_173(flow);
    }

    private void CalculationExpression_block_173(Integer flow) {
        _Parte_bassa_Cand_che_abbr = Math.min(_Candela_che_abbraccia.getOpen(),_Candela_che_abbraccia.getClose());
        Calculation_block_174(flow);
    }

    private void Calculation_block_174(Integer flow) {
        double argument_1 = _Candela_precedente.getHigh();
        double argument_2 = _Parte_alta_cand_Prec;
        _Ombra_alta_cand_prec = argument_1 - argument_2;
        Calculation_block_175(flow);
    }

    private void Calculation_block_175(Integer flow) {
        double argument_1 = _Parte_bassa_cand_prec;
        double argument_2 = _Candela_precedente.getLow();
        _Ombra_Bassa_Cand_prec = argument_1 - argument_2;
        Calculation_block_176(flow);
    }

    private void Calculation_block_176(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getHigh();
        double argument_2 = _Parte_alta_cand_che_abbr;
        _Ombra_alta_cand_che_abbr = argument_1 - argument_2;
        Calculation_block_177(flow);
    }

    private void Calculation_block_177(Integer flow) {
        double argument_1 = _Parte_bassa_Cand_che_abbr;
        double argument_2 = _Candela_che_abbraccia.getLow();
        _Ombra_bassa_cand_che_abbr = argument_1 - argument_2;
        Calculation_block_178(flow);
    }

    private void Calculation_block_178(Integer flow) {
        double argument_1 = _Parte_alta_cand_Prec;
        double argument_2 = _Parte_bassa_cand_prec;
        _RANGE_CAND_PREC = argument_1 - argument_2;
        Calculation_block_179(flow);
    }

    private void Calculation_block_179(Integer flow) {
        double argument_1 = _Parte_alta_cand_che_abbr;
        double argument_2 = _Parte_bassa_Cand_che_abbr;
        _RANGE_CAND_CHE_ABBR = argument_1 - argument_2;
        Calculation_block_180(flow);
    }

    private void Calculation_block_180(Integer flow) {
        double argument_1 = _RANGE_CAND_PREC;
        double argument_2 = _tempVar329;
        _Vincolo_ombre_prec = argument_1 / argument_2;
        Calculation_block_181(flow);
    }

    private void Calculation_block_181(Integer flow) {
        double argument_1 = _RANGE_CAND_CHE_ABBR;
        double argument_2 = _tempVar329;
        _Vincolo_ombre_cand_che_abbr = argument_1 / argument_2;
        If_block_182(flow);
    }

    private  void If_block_182(Integer flow) {
        double argument_1 = _Ombra_alta_cand_prec;
        double argument_2 = _Vincolo_ombre_prec;
        if (argument_1< argument_2) {
            If_block_183(flow);
        }
        else if (argument_1> argument_2) {
            If_block_183(flow);
        }
        else if (argument_1== argument_2) {
            If_block_183(flow);
        }
    }

    private  void If_block_183(Integer flow) {
        double argument_1 = _Ombra_Bassa_Cand_prec;
        double argument_2 = _Vincolo_ombre_prec;
        if (argument_1< argument_2) {
            If_block_184(flow);
        }
        else if (argument_1> argument_2) {
            If_block_184(flow);
        }
        else if (argument_1== argument_2) {
            If_block_184(flow);
        }
    }

    private  void If_block_184(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getHigh();
        double argument_2 = _Candela_precedente.getHigh();
        if (argument_1< argument_2) {
        }
        else if (argument_1> argument_2) {
            If_block_185(flow);
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_185(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getLow();
        double argument_2 = _Candela_precedente.getLow();
        if (argument_1< argument_2) {
            If_block_193(flow);
        }
        else if (argument_1> argument_2) {
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_186(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getOpen();
        double argument_2 = _Candela_precedente.getClose();
        if (argument_1< argument_2) {
        }
        else if (argument_1> argument_2) {
            Calculation_block_187(flow);
        }
        else if (argument_1== argument_2) {
            Calculation_block_187(flow);
        }
    }

    private void Calculation_block_187(Integer flow) {
        double argument_1 = _Range_Candela_che_abbraccia;
        double argument_2 = _tempVar281;
        _Vincolo_Range = argument_1 * argument_2;
        If_block_190(flow);
    }

    private void Calculation_block_188(Integer flow) {
        double argument_1 = _Range_Candela_che_abbraccia;
        double argument_2 = _tempVar281;
        _Vincolo_Range = argument_1 * argument_2;
        If_block_189(flow);
    }

    private  void If_block_189(Integer flow) {
        double argument_1 = _Range_candela_precedente;
        double argument_2 = _Vincolo_Range;
        if (argument_1< argument_2) {
            SoundAlert_block_192(flow);
        }
        else if (argument_1> argument_2) {
            SoundAlert_block_192(flow);
        }
        else if (argument_1== argument_2) {
            SoundAlert_block_192(flow);
        }
    }

    private  void If_block_190(Integer flow) {
        double argument_1 = _Range_candela_precedente;
        double argument_2 = _Vincolo_Range;
        if (argument_1< argument_2) {
            SoundAlert_block_191(flow);
        }
        else if (argument_1> argument_2) {
            SoundAlert_block_191(flow);
        }
        else if (argument_1== argument_2) {
            SoundAlert_block_191(flow);
        }
    }

    private  void SoundAlert_block_191(Integer flow) {
        try {
            List<ISignal> signals191 = null;
            switch (flow) {
                case 0:
                    signals191 = strategy191.onTick(LastTick.getInstrument(), LastTick.getTick());
                    break;
                case 1:
                    signals191 = strategy191.onBar(LastAskCandle.getInstrument(), LastAskCandle.getPeriod(), LastAskCandle.getBar(), LastBidCandle.getBar());
                    break;
                case 2:
                    signals191 = strategy191.onMessage(LastTradeEvent);
                    break;
                default:
                    signals191 = strategy191.onTick(LastTick.getInstrument(), LastTick.getTick());
                    break;
            }
        } catch (JFException e) {
            e.printStackTrace();
        }
         try {
                               //Invio email di prova 
                sendMail("Engulfing Rialzista AUD/CAD tf 1D", "Formazione di un ENGULFING Rialzista su TF 1D, AUD/CAD testata il 01/04/2017, ENGULFING_XYZABC dropbox cartella strategie automatizzate. Senza indicazioni di sell o buy, la strategia inserisce la procedura di invio delle mail dopo il sound relativo alle condizioni. Parametri del candelone: 2 (1.2 settimanale) volte range medio_7 . Questa formazione non è stata filtrata con altri indicatori.  " +" \n Buon Trading");
          
        } catch (Exception e) {
            // TODO Auto-generated catch block
            System.err.print("Error send email during order ENGULFING Rialzista AUD/CAD tf 1D:" + e.getMessage());
            e.printStackTrace();
        }
    }

    private  void SoundAlert_block_192(Integer flow) {
        try {
            List<ISignal> signals192 = null;
            switch (flow) {
                case 0:
                    signals192 = strategy192.onTick(LastTick.getInstrument(), LastTick.getTick());
                    break;
                case 1:
                    signals192 = strategy192.onBar(LastAskCandle.getInstrument(), LastAskCandle.getPeriod(), LastAskCandle.getBar(), LastBidCandle.getBar());
                    break;
                case 2:
                    signals192 = strategy192.onMessage(LastTradeEvent);
                    break;
                default:
                    signals192 = strategy192.onTick(LastTick.getInstrument(), LastTick.getTick());
                    break;
            }
        } catch (JFException e) {
            e.printStackTrace();
        }
        try {
                               //Invio email di prova 
                sendMail("Engulfing Ribassista AUD/CAD tf 1D", "Formazione di un ENGULFING Ribassista su TF 1D, AUD/CAD testata il 01/04/2017, ENGULFING_XYZABC dropbox cartella strategie automatizzate. Senza indicazioni di sell o buy, la strategia inserisce la procedura di invio delle mail dopo il sound relativo alle condizioni. Parametri del candelone: 2 (1.2 settimanale) volte range medio_7 . Questa formazione non è stata filtrata con altri indicatori.  " +" \n Buon Trading");
          
        } catch (Exception e) {
            // TODO Auto-generated catch block
            System.err.print("Error send email during order ENGULFING Ribassista AUD/CAD tf 1D:" + e.getMessage());
            e.printStackTrace();
        }
    }

    private  void If_block_193(Integer flow) {
        double argument_1 = _Candela_precedente.getClose();
        double argument_2 = _Candela_precedente.getOpen();
        if (argument_1< argument_2) {
            If_block_194(flow);
        }
        else if (argument_1> argument_2) {
            If_block_195(flow);
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_194(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getClose();
        double argument_2 = _Candela_che_abbraccia.getOpen();
        if (argument_1< argument_2) {
        }
        else if (argument_1> argument_2) {
            Calculation_block_197(flow);
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_195(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getOpen();
        double argument_2 = _Candela_che_abbraccia.getClose();
        if (argument_1< argument_2) {
        }
        else if (argument_1> argument_2) {
            Calculation_block_196(flow);
        }
        else if (argument_1== argument_2) {
        }
    }

    private void Calculation_block_196(Integer flow) {
        double argument_1 = _Candela_precedente.getClose();
        double argument_2 = _Candela_precedente.getOpen();
        _Range_candela_precedente = argument_1 - argument_2;
        Calculation_block_199(flow);
    }

    private void Calculation_block_197(Integer flow) {
        double argument_1 = _Candela_precedente.getOpen();
        double argument_2 = _Candela_precedente.getClose();
        _Range_candela_precedente = argument_1 - argument_2;
        Calculation_block_198(flow);
    }

    private void Calculation_block_198(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getClose();
        double argument_2 = _Candela_che_abbraccia.getOpen();
        _Range_Candela_che_abbraccia = argument_1 - argument_2;
        If_block_201(flow);
    }

    private void Calculation_block_199(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getOpen();
        double argument_2 = _Candela_che_abbraccia.getClose();
        _Range_Candela_che_abbraccia = argument_1 - argument_2;
        If_block_200(flow);
    }

    private  void If_block_200(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getClose();
        double argument_2 = _Candela_precedente.getOpen();
        if (argument_1< argument_2) {
            If_block_186(flow);
        }
        else if (argument_1> argument_2) {
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_201(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getClose();
        double argument_2 = _Candela_precedente.getOpen();
        if (argument_1< argument_2) {
        }
        else if (argument_1> argument_2) {
            If_block_202(flow);
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_202(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getOpen();
        double argument_2 = _Candela_precedente.getClose();
        if (argument_1< argument_2) {
            Calculation_block_188(flow);
        }
        else if (argument_1> argument_2) {
        }
        else if (argument_1== argument_2) {
            Calculation_block_188(flow);
        }
    }

    private void CalculationExpression_block_203(Integer flow) {
        _Parte_alta_cand_Prec = Math.max(_Candela_precedente.getClose(),_Candela_precedente.getOpen());
        CalculationExpression_block_204(flow);
    }

    private void CalculationExpression_block_204(Integer flow) {
        _Parte_bassa_cand_prec = Math.min(_Candela_precedente.getClose(),_Candela_precedente.getOpen());
        CalculationExpression_block_205(flow);
    }

    private void CalculationExpression_block_205(Integer flow) {
        _Parte_alta_cand_che_abbr = Math.max(_Candela_che_abbraccia.getOpen(),_Candela_che_abbraccia.getClose());
        CalculationExpression_block_206(flow);
    }

    private void CalculationExpression_block_206(Integer flow) {
        _Parte_bassa_Cand_che_abbr = Math.min(_Candela_che_abbraccia.getOpen(),_Candela_che_abbraccia.getClose());
        Calculation_block_207(flow);
    }

    private void Calculation_block_207(Integer flow) {
        double argument_1 = _Candela_precedente.getHigh();
        double argument_2 = _Parte_alta_cand_Prec;
        _Ombra_alta_cand_prec = argument_1 - argument_2;
        Calculation_block_208(flow);
    }

    private void Calculation_block_208(Integer flow) {
        double argument_1 = _Parte_bassa_cand_prec;
        double argument_2 = _Candela_precedente.getLow();
        _Ombra_Bassa_Cand_prec = argument_1 - argument_2;
        Calculation_block_209(flow);
    }

    private void Calculation_block_209(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getHigh();
        double argument_2 = _Parte_alta_cand_che_abbr;
        _Ombra_alta_cand_che_abbr = argument_1 - argument_2;
        Calculation_block_210(flow);
    }

    private void Calculation_block_210(Integer flow) {
        double argument_1 = _Parte_bassa_Cand_che_abbr;
        double argument_2 = _Candela_che_abbraccia.getLow();
        _Ombra_bassa_cand_che_abbr = argument_1 - argument_2;
        Calculation_block_211(flow);
    }

    private void Calculation_block_211(Integer flow) {
        double argument_1 = _Parte_alta_cand_Prec;
        double argument_2 = _Parte_bassa_cand_prec;
        _RANGE_CAND_PREC = argument_1 - argument_2;
        Calculation_block_212(flow);
    }

    private void Calculation_block_212(Integer flow) {
        double argument_1 = _Parte_alta_cand_che_abbr;
        double argument_2 = _Parte_bassa_Cand_che_abbr;
        _RANGE_CAND_CHE_ABBR = argument_1 - argument_2;
        Calculation_block_213(flow);
    }

    private void Calculation_block_213(Integer flow) {
        double argument_1 = _RANGE_CAND_PREC;
        double argument_2 = _tempVar329;
        _Vincolo_ombre_prec = argument_1 / argument_2;
        Calculation_block_214(flow);
    }

    private void Calculation_block_214(Integer flow) {
        double argument_1 = _RANGE_CAND_CHE_ABBR;
        double argument_2 = _tempVar329;
        _Vincolo_ombre_cand_che_abbr = argument_1 / argument_2;
        If_block_215(flow);
    }

    private  void If_block_215(Integer flow) {
        double argument_1 = _Ombra_alta_cand_prec;
        double argument_2 = _Vincolo_ombre_prec;
        if (argument_1< argument_2) {
            If_block_216(flow);
        }
        else if (argument_1> argument_2) {
            If_block_216(flow);
        }
        else if (argument_1== argument_2) {
            If_block_216(flow);
        }
    }

    private  void If_block_216(Integer flow) {
        double argument_1 = _Ombra_Bassa_Cand_prec;
        double argument_2 = _Vincolo_ombre_prec;
        if (argument_1< argument_2) {
            If_block_217(flow);
        }
        else if (argument_1> argument_2) {
            If_block_217(flow);
        }
        else if (argument_1== argument_2) {
            If_block_217(flow);
        }
    }

    private  void If_block_217(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getHigh();
        double argument_2 = _Candela_precedente.getHigh();
        if (argument_1< argument_2) {
            If_block_218(flow);
        }
        else if (argument_1> argument_2) {
            If_block_218(flow);
        }
        else if (argument_1== argument_2) {
            If_block_218(flow);
        }
    }

    private  void If_block_218(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getLow();
        double argument_2 = _Candela_precedente.getLow();
        if (argument_1< argument_2) {
            If_block_229(flow);
        }
        else if (argument_1> argument_2) {
            If_block_229(flow);
        }
        else if (argument_1== argument_2) {
            If_block_229(flow);
        }
    }

    private  void If_block_219(Integer flow) {
        double argument_1 = _Range_candela_precedente;
        double argument_2 = _Vincolo_Range;
        if (argument_1< argument_2) {
            SoundAlert_block_220(flow);
        }
        else if (argument_1> argument_2) {
            SoundAlert_block_220(flow);
        }
        else if (argument_1== argument_2) {
            SoundAlert_block_220(flow);
        }
    }

    private  void SoundAlert_block_220(Integer flow) {
        try {
            List<ISignal> signals220 = null;
            switch (flow) {
                case 0:
                    signals220 = strategy220.onTick(LastTick.getInstrument(), LastTick.getTick());
                    break;
                case 1:
                    signals220 = strategy220.onBar(LastAskCandle.getInstrument(), LastAskCandle.getPeriod(), LastAskCandle.getBar(), LastBidCandle.getBar());
                    break;
                case 2:
                    signals220 = strategy220.onMessage(LastTradeEvent);
                    break;
                default:
                    signals220 = strategy220.onTick(LastTick.getInstrument(), LastTick.getTick());
                    break;
            }
        } catch (JFException e) {
            e.printStackTrace();
        }
       try {
                               //Invio email di prova 
                sendMail("Engulfing Rialzista AUD/CAD tf 1W", "Formazione di un ENGULFING Rialzista su TF 1W, AUD/CAD testata il 01/04/2017, ENGULFING_XYZABC dropbox cartella strategie automatizzate. Senza indicazioni di sell o buy, la strategia inserisce la procedura di invio delle mail dopo il sound relativo alle condizioni. Parametri del candelone: 2 (1.2 settimanale) volte range medio_7 . Questa formazione non è stata filtrata con altri indicatori.  " +" \n Buon Trading");
          
        } catch (Exception e) {
            // TODO Auto-generated catch block
            System.err.print("Error send email during order ENGULFING Rialzista AUD/CAD tf 1W:" + e.getMessage());
            e.printStackTrace();
        } 
        
      
        
    }

    private  void If_block_221(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getClose();
        double argument_2 = _Candela_precedente.getOpen();
        if (argument_1< argument_2) {
            If_block_223(flow);
        }
        else if (argument_1> argument_2) {
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void SoundAlert_block_222(Integer flow) {
        try {
            List<ISignal> signals222 = null;
            switch (flow) {
                case 0:
                    signals222 = strategy222.onTick(LastTick.getInstrument(), LastTick.getTick());
                    break;
                case 1:
                    signals222 = strategy222.onBar(LastAskCandle.getInstrument(), LastAskCandle.getPeriod(), LastAskCandle.getBar(), LastBidCandle.getBar());
                    break;
                case 2:
                    signals222 = strategy222.onMessage(LastTradeEvent);
                    break;
                default:
                    signals222 = strategy222.onTick(LastTick.getInstrument(), LastTick.getTick());
                    break;
            }
        } catch (JFException e) {
            e.printStackTrace();
        }
        try {
                               //Invio email di prova 
                sendMail("Engulfing Ribassista AUD/CAD tf 1W", "Formazione di un ENGULFING Ribassista su TF 1W, AUD/CAD testata il 01/04/2017, ENGULFING_XYZABC dropbox cartella strategie automatizzate. Senza indicazioni di sell o buy, la strategia inserisce la procedura di invio delle mail dopo il sound relativo alle condizioni. Parametri del candelone: 2 (1.2 settimanale) volte range medio_7 . Questa formazione non è stata filtrata con altri indicatori.  " +" \n Buon Trading");
          
        } catch (Exception e) {
            // TODO Auto-generated catch block
            System.err.print("Error send email during order ENGULFING Ribassista AUD/CAD tf 1W:" + e.getMessage());
            e.printStackTrace();
        }
    }

    private  void If_block_223(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getOpen();
        double argument_2 = _Candela_precedente.getClose();
        if (argument_1< argument_2) {
        }
        else if (argument_1> argument_2) {
            Calculation_block_224(flow);
        }
        else if (argument_1== argument_2) {
            Calculation_block_224(flow);
        }
    }

    private void Calculation_block_224(Integer flow) {
        double argument_1 = _Range_Candela_che_abbraccia;
        double argument_2 = _tempVar281;
        _Vincolo_Range = argument_1 * argument_2;
        If_block_225(flow);
    }

    private  void If_block_225(Integer flow) {
        double argument_1 = _Range_candela_precedente;
        double argument_2 = _Vincolo_Range;
        if (argument_1< argument_2) {
            SoundAlert_block_222(flow);
        }
        else if (argument_1> argument_2) {
            SoundAlert_block_222(flow);
        }
        else if (argument_1== argument_2) {
            SoundAlert_block_222(flow);
        }
    }

    private  void If_block_226(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getClose();
        double argument_2 = _Candela_precedente.getOpen();
        if (argument_1< argument_2) {
        }
        else if (argument_1> argument_2) {
            If_block_227(flow);
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_227(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getOpen();
        double argument_2 = _Candela_precedente.getClose();
        if (argument_1< argument_2) {
            Calculation_block_228(flow);
        }
        else if (argument_1> argument_2) {
        }
        else if (argument_1== argument_2) {
            Calculation_block_228(flow);
        }
    }

    private void Calculation_block_228(Integer flow) {
        double argument_1 = _Range_Candela_che_abbraccia;
        double argument_2 = _tempVar281;
        _Vincolo_Range = argument_1 * argument_2;
        If_block_219(flow);
    }

    private  void If_block_229(Integer flow) {
        double argument_1 = _Candela_precedente.getClose();
        double argument_2 = _Candela_precedente.getOpen();
        if (argument_1< argument_2) {
            If_block_230(flow);
        }
        else if (argument_1> argument_2) {
            If_block_231(flow);
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_230(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getClose();
        double argument_2 = _Candela_che_abbraccia.getOpen();
        if (argument_1< argument_2) {
        }
        else if (argument_1> argument_2) {
            Calculation_block_235(flow);
        }
        else if (argument_1== argument_2) {
        }
    }

    private  void If_block_231(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getOpen();
        double argument_2 = _Candela_che_abbraccia.getClose();
        if (argument_1< argument_2) {
        }
        else if (argument_1> argument_2) {
            Calculation_block_232(flow);
        }
        else if (argument_1== argument_2) {
        }
    }

    private void Calculation_block_232(Integer flow) {
        double argument_1 = _Candela_precedente.getClose();
        double argument_2 = _Candela_precedente.getOpen();
        _Range_candela_precedente = argument_1 - argument_2;
        Calculation_block_233(flow);
    }

    private void Calculation_block_233(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getOpen();
        double argument_2 = _Candela_che_abbraccia.getClose();
        _Range_Candela_che_abbraccia = argument_1 - argument_2;
        If_block_221(flow);
    }

    private void Calculation_block_234(Integer flow) {
        double argument_1 = _Candela_che_abbraccia.getClose();
        double argument_2 = _Candela_che_abbraccia.getOpen();
        _Range_Candela_che_abbraccia = argument_1 - argument_2;
        If_block_226(flow);
    }

    private void Calculation_block_235(Integer flow) {
        double argument_1 = _Candela_precedente.getOpen();
        double argument_2 = _Candela_precedente.getClose();
        _Range_candela_precedente = argument_1 - argument_2;
        Calculation_block_234(flow);
    }


private boolean sendMail(String subj,String text) throws Exception {
        Message msg = setSmtpMsg(subj, text);
        Transport.send(msg);
        return true;
    }

    private Message setSmtpMsg(String subj, String text)
            throws MessagingException, AddressException {
        
        if(session == null )
          session = setSession();

        Message msg = new MimeMessage(session);
        msg.setFrom(new InternetAddress("CAB@gmail.com"));
        InternetAddress[] address  = new InternetAddress[mailAddress.length];
        for (int i = 0; i < mailAddress.length; i++) {
            address[i] = new InternetAddress(mailAddress[i]);
        }
 
        msg.setRecipients(javax.mail.Message.RecipientType.TO, address);
        msg.setSubject(subj);
        msg.setText(text);
        return msg;
    }

    static final Session setSession() {
        Properties props = new Properties();
      //  props.setProperty("mail.smtp.host", smtpServer);
        
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.starttls.enable", "true");
        props.put("mail.smtp.host", "in-v3.mailjet.com");
        props.put("mail.smtp.socketFactory.port", "465");
        props.put("mail.smtp.socketFactory.class",
                "javax.net.ssl.SSLSocketFactory");
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.port", "465");
        
//        props.put("mail.smtp.host", "mail.strecof.com");
//        props.put("mail.smtp.socketFactory.port", "465");
//        props.put("mail.smtp.socketFactory.class",
//                "javax.net.ssl.SSLSocketFactory");
//        props.put("mail.smtp.auth", "true");
//        props.put("mail.smtp.port", "465");

        Session session = Session.getInstance(props,
          new javax.mail.Authenticator() {
            @Override
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(username, password);
            }
          });
        return session;
    }




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