HPotter

MultiTradingSystem

This is example to show how you can combine two and more strategies for get
a cumulative signal. Result signal will return 1 if two (or more) strategies
is long, -1 if all strategies is short and 0 if signals of strategies is not equal.

First strategy
Chaikin's Volatility indicator compares the spread between a security's
high and low prices. It quantifies volatility as a widening of the range
between the high and the low price.
You can use in the xPrice1 and xPrice2 any series: Open, High, Low, Close, HL2,
HLC3, OHLC4 and ect...

Secon strategy
The Moving Average Crossover trading strategy is possibly the most popular
trading strategy in the world of trading. First of them were written in the
middle of XX century, when commodities trading strategies became popular.
This strategy is a good example of so-called traditional strategies.
Traditional strategies are always long or short. That means they are never
out of the market. The concept of having a strategy that is always long or
short may be scary, particularly in today’s market where you don’t know what
is going to happen as far as risk on any one market. But a lot of traders
believe that the concept is still valid, especially for those of traders who
do their own research or their own discretionary trading.
This version uses crossover of moving average and its exponential moving average.

สคริปต์โอเพนซอร์ซ

ด้วยจิตวิญญาณของ TradingView อย่างแท้จริง ผู้เขียนสคริปต์นี้ได้เผยแพร่เป็นโอเพนซอร์ส เพื่อให้ผู้ค้าสามารถเข้าใจและตรวจสอบได้ ไชโยให้กับผู้เขียน! คุณสามารถใช้ได้ฟรี แต่การใช้รหัสนี้ซ้ำในสิ่งพิมพ์อยู่ภายใต้กฎระเบียบการใช้งาน คุณสามารถตั้งเป็นรายการโปรดเพื่อใช้บนชาร์ตได้

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมที่ เงื่อนไขการใช้บริการ

ต้องการที่จะใช้สคริปต์นี้บนชาร์ตใช่ไหม?
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 21/11/2014
//This is example to show you how  can combine two and more strategies for get 
// a cumulative signal. Result signal will return 1 if two (or more) strategies 
// is long, -1 if all strategies is short and 0 if signals of strategies is not equal.
//
// First strategy
// Chaikin's Volatility indicator compares the spread between a security's
// high and low prices. It quantifies volatility as a widening of the range
// between the high and the low price.
// You can use in the xPrice1 and xPrice2 any series: Open, High, Low, Close, HL2,
// HLC3, OHLC4 and ect...
//
// Secon strategy
// The Moving Average Crossover trading strategy is possibly the most popular
// trading strategy in the world of trading. First of them were written in the
// middle of XX century, when commodities trading strategies became popular.
// This strategy is a good example of so-called traditional strategies. 
// Traditional strategies are always long or short. That means they are never 
// out of the market. The concept of having a strategy that is always long or 
// short may be scary, particularly in today’s market where you don’t know what 
// is going to happen as far as risk on any one market. But a lot of traders 
// believe that the concept is still valid, especially for those of traders who 
// do their own research or their own discretionary trading. 
// This version uses crossover of moving average and its exponential moving average. 
///////////////////////////////////////////////////////////
//Function for First strategy
//Strategy return 1 if long and -1 if short and 0 if prev value or flat
ChaikinVolStr(Length, ROCLength, Trigger) =>
    xPrice1 = high
    xPrice2 = low
    xPrice = xPrice1 - xPrice2
    xROC_EMA = roc(ema(xPrice, Length), ROCLength)
    iff(xROC_EMA < Trigger, 1,
    	iff(xROC_EMA > Trigger, -1, 0)) 
//Function for Second strategy
//Strategy return 1 if long and -1 if short and 0 if prev value or flat
EMA_MACrosStr(LengthMA, LengthEMA) =>
    xMA = sma(close, LengthMA)
    xEMA = ema(xMA, LengthEMA)
    iff(xEMA < xMA , 1,
	   iff(xEMA > xMA, -1, 0)) 
//Functions for other strategies....
//....................
//....................

//Main function Code
study(title="Multi Trading System")
//Inputs for First strategy
Length = input(10, minval=1)
ROCLength = input(12, minval=1)
Trigger = input(0, minval=1)
//Inputs for Second strategy
LengthMA = input(10, minval=1)
LengthEMA = input(10,minval=1)
//Get a signals from strategies
posChaikin = ChaikinVolStr(Length, ROCLength, Trigger) //Get signal from first stragey
posEMA_MACrosStr = EMA_MACrosStr(LengthMA, LengthEMA) //Get signal from second stragey
//Make cumulative signal
posResult = iff(posChaikin == 1 and posEMA_MACrosStr == 1 , 1,
	            iff(posChaikin == -1 and posEMA_MACrosStr == -1, -1, 0)) 
barcolor(posResult == -1 ? red: posResult == 1 ? green : blue )