Trading signals

How to use Seetu to generate Collective2 trading signals which get sent to your Collective2 trading strategy.

Example 10. Strategy: Trading signals

        /*
       
         Example: Simple Relative Strength Index strategy + Collective2 trading signals
        
        */
         
        // Collective2 trading system ID
        SetOption("C2TradingSystemId",92923646);   
      
        // If you want it, you can get "Buying Power" of the above system
        C2BuyPower = GetOption("C2BuyPower");   
      
        // Trading system logic
      
        // Calculate and save Relative Strength Index
        Rsi_Value = CalcRSI();  
      
        // Buy if RSI_Value crosses above 30
        Buy = Cross( Rsi_Value, 30 ); 
      
        // Sell if RSI_Value falls under 70
        Sell = Cross( 70, Rsi_Value );
        
        // Remove surplus trade signals to have less rows in Scan and Exploration
        Buy = ExRem(Buy,Sell);
        Sell = ExRem(Sell,Buy);
      
        // Delay trades to the next bar.
        SetTradeDelays( 1, 1, 0, 0 );
      
        // Round a number of shares to 100. 
        SetOption("RoundLotSize",100);
      
        // Use Open as buy and sell prices 
        BuyPrice = SellPrice = Open; 
      
        // trade size: 25% of current portfolio equity
        SetPositionSize( 25, spsPercentOfEquity );
      
        // Prepare signals for Collective2. Signal are generated in "Exploration".
      
        // We show you several variants in this code:
      
        // 1. This variant shows just last trading signals (if any).
        // It also demonstrates automatic stop loss and profit target signals.
      
        C2TradingSignal(sigBTO, priceType = priceLimit, stopLoss = BuyPrice * 0.9, profitTarget = BuyPrice * 1.1); 
      
      
        // 2. This variant shows all generated BTO signals.
      
        // C2TradingSignal(sigBTO, sigfilter = Buy); 
      
      
        /*
        // 3. This variant shows a general pattern how to show several last trading signals. 
        // Say we want to see last two signals.
        // Prepare cumulative sum of Buy signals
        cumulativeBuySignals = cum(buy);
        // Get bars where cumulative sum of Buy signals is greater than the latest value minus 2 
        signalFilter = cumulativeBuySignals > lastvalue(cumulativeBuySignals) - 2;
        // Use this filter 
        C2TradingSignal(sigBTO, sigfilter = signalFilter ); 
        */
      
        /*
        // 4. This variant generates conditional signals.
        // Say we want to buy 100 stocks and add another 50 to position if the BuyPrice price falls 10% 
        C2TradingSignal(sigBTO, Amount = 100, Price = BuyPrice * 0.9, priceType = priceLimit, profitTarget = BuyPrice * 1.1); 
        // Conditional signals for BTO signals
        C2TradingSignalCond(sigBTO, sigBTO, Amount = 50, Price = BuyPrice * 0.8, priceType = priceLimit);
        */
      
        // Exploration columns
        // Show just Buy signals in Exploration
        Filter = Buy;
        AddColumn(Rsi_Value, "RSI");
        AddColumn(Open, "Open");