9911939149 support@algoji.com

Peer Stocks Algo Using TradingView

You may want to optimize your entry conditions based on reference with peer stocks. For example, you may want to BUY HDFCBANK when the price of HDFC bank is in uptrend, AND ALSO the price of ICICIBANK is in uptrend. We will show you how to setup algo trading using such complex conditions, using a very simple strategy.

Strategy Logic

Entries will be taken only when Moving Average Crossover happens. Even though this tutorial uses Moving Average, you can use other indicators like SuperTrend, VWAP, RSI etc.

We will have a buy condition in current stock if candle crosses above moving average and the peer stock is bullish (peer stock is trading above moving average)

We will have a sell condition in current stock if candle crosses below moving average and peer stock is bearish (peer stock trading below moving average)

Explanation of logic with example: Say we have current stock as INFOSYS and peer stock as TCS ,we may want to trade bullish if stock crosses above moving average , For that to we are also checking Peer TCS is in uptrend so that we filter our trades.

STEP 1: Download the peertrading pinsecript algo here

STEP 2: Go to trading view chart of any stock and add this downloaded strategy file to chart via pine editor. Select the strategy and paste it in pine editor, save it and add it to chart.

STEP 3: Once strategy is applied on chart, click on settings to optimize parameters for your own trading.

MA TYPE: Moving average type (Simple moving average, exponential moving average)
Length For moving average for current script: This is MA length for current script
SYMBOL 1: Specify peer symbol for better results (symbol can be obtained from trading view search)
USE SYMBOL 2: This is to use more than one peer
SYMBOL 2: Specify Symbol 2 if needed
RESOLUTION: CHART TIMEFRAME of peer symbol (you can use this to get trend view of peer symbol on specified candle time frame example look for opportunities to buy INFY 3min chart if TCS is bullish in 15 min chart)
MALENGTH For reference scripts: This can be used to specify the ma lenths of reference scripts (Ex :  Say close above MA  is bullish and  Trade bullish if moving average(6) crossover  happens in INFY and TCS is having its price above its moving average(20))
TRADE ONLY INTRADAY: Check this option if trades should be intraday
INTRADAY EXTRY/EXIT SESSION: Specify the session if Intraday is checked
USE TARGET/STOPLOSS: These can be used to have target and stoploss on trades TARGET AND STOPLOSS: Use this to specify target and stoploss in RS.

STEP 4: To create alert click on add alert and put {{strategy.order.comment}} in alert box. That’s all! you are all set for algo trading with APIBridge.