टीडी अनुक्रमिक द्वि-दिशात्मक एस/आर ट्रेडिंग रणनीति

लेखक:चाओझांग, दिनांकः 2024-02-06 12:13:22
टैगः

img

अवलोकन

यह रणनीति कीमतों के लगातार ऊपर और नीचे की पट्टी को ट्रैक करके समर्थन और प्रतिरोध स्तरों की पहचान करती है, और लंबी और छोटी ट्रेडिंग रणनीतियों का निर्माण करने के लिए प्रवेश और स्टॉप लॉस संकेतों के रूप में चलती औसत को जोड़ती है। रणनीति लंबी और छोटी, या केवल एक तरफ जा सकती है।

सिद्धांत

  1. एस/आर पहचान
    • जब बंद मूल्य 4 दिनों के लिए लगातार 4 दिनों के लिए बंद की तुलना में अधिक है, तो बिंदु को डाउनसाइड समर्थन के रूप में चिह्नित करें
    • जब बंद मूल्य 4 दिनों के लिए लगातार 4 दिनों के लिए बंद की तुलना में कम है, तो बिंदु को ऊपर के प्रतिरोध के रूप में चिह्नित करें
  2. सिग्नल उत्पादन
    • एक समर्थन स्तर की पहचान करने के बाद, यदि ऊपर पट्टी गिनती सीमा (डिफ़ॉल्ट 9 दिन) तक पहुँचता है, तो लंबे संकेत उत्पन्न करें
    • एक प्रतिरोध स्तर की पहचान के बाद, अगर नीचे पट्टी गिनती सीमा (डिफ़ॉल्ट 9 दिन) तक पहुँच जाता है, संक्षिप्त संकेत उत्पन्न
  3. एमए फ़िल्टर और स्टॉप लॉस
    • प्रवेश पर एमए लाइन पार करने के लिए कीमत की आवश्यकता है, संकेतों को फ़िल्टर करने के लिए
    • प्रवेश पर एमए लाइन पर स्टॉप लॉस सेट करें

लाभ

  1. एस/आर पर आधारित निर्णय अपेक्षाकृत विश्वसनीय है, अल्पकालिक उतार-चढ़ावों से आसानी से भटका नहीं जाता है
  2. एमए फ़िल्टर का संयोजन झूठे संकेतों को कम कर सकता है
  3. आवृत्ति और लाभ के अवसरों में सुधार के लिए दोनों लंबी और छोटी जाएं
  4. पैरामीटर समायोज्य, विभिन्न उत्पादों और बाजार स्थितियों के लिए अनुकूलित किया जा सकता है

जोखिम और समाधान

  1. ट्रेंडिंग बाजारों में लगातार घाटे का सामना कर सकता है
    • व्यापारिक आवृत्ति को कम करने के लिए अनुमोदन अवधि में वृद्धि
  2. गलत एस/आर निर्णय की संभावना
    • एस/आर पहचान के लिए बारीक विन्यास की सीमाएँ
  3. विप्सॉ बाजारों में स्टॉप लॉस को अक्सर ट्रिगर किया जा सकता है
    • स्टॉप लॉस रेंज को ढीला करें
    • रुझान सूचक जोड़ें

अनुकूलन दिशाएँ

  1. मजबूतता में सुधार के लिए अधिक तकनीकी संकेतकों को जोड़ें
    • रुझान, गति आदि।
  2. एस/आर पहचान तर्क को अनुकूलित करें
    • विभिन्न मापदंडों का परीक्षण प्रभाव
  3. विशिष्ट उत्पादों और समय सीमाओं के लिए पैरामीटर ट्यूनिंग
    • समायोज्य रेंज विभिन्न उत्पादों में भिन्न होती है
  4. अनुकूलनशील स्टॉप लॉस तंत्र विकसित करना
    • बाजार की अस्थिरता के आधार पर स्टॉप लॉस को गतिशील रूप से समायोजित करें

निष्कर्ष

रणनीति अपेक्षाकृत सरल और विश्वसनीय है। एस / आर स्तरों की सही पहचान करके यह उच्च संभावना के साथ मूल्य उलट अवसरों को पकड़ता है। एमए के साथ संयोजन उचित प्रवेश समय सुनिश्चित करता है और जाल से बचता है। अंत में, दिशात्मक निर्णय रूढ़िवादी लेकिन अनुकूलन योग्य है। उपयोगकर्ता अपने बाजार की समझ के अनुसार मापदंडों को अनुकूलित कर सकते हैं और और भी बेहतर परिणाम प्राप्त कर सकते हैं।


/*backtest
start: 2023-01-30 00:00:00
end: 2024-02-05 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © GlobalMarketSignals

//@version=4
strategy("GMS: TD Sequential Strategy", overlay=true)

LongShort     = input(title="Long Only or Short Only or Both?", type=input.string, defval="Both", options=["Both", "Long Only", "Short Only"])
PriceFlipL    = input(title="TD Sequential Long Price Flip", type = input.integer ,defval=9)
PriceFlipS    = input(title="TD Sequential Short Price Flip", type = input.integer ,defval=9)
MAs1          = input(title="Long MA", type=input.string, defval="SMA", options=["SMA", "EMA", "VWMA"])
MAs2          = input(title="Short MA", type=input.string, defval="SMA", options=["SMA", "EMA", "VWMA"])
SMAlenL       = input(title="Long MA Exit Length", type = input.integer ,defval=10)
SMAlenS       = input(title="Short MA Exit Length", type = input.integer ,defval=10)
AboveBelowL   = input(title="Long Trend Filter?", type=input.string, defval="Above", options=["Above", "Below", "Don't Include"])
AboveBelowS   = input(title="Short Trend Filter?", type=input.string, defval="Below", options=["Above", "Below", "Don't Include"])
TLma          = input(title="Trend MA", type=input.string, defval="SMA", options=["SMA", "EMA", "VWMA"])
TrendLength   = input(title="Trend MA Length", type = input.integer ,defval=200)
PTbutton      = input(title="Profit Target On/Off", type=input.bool, defval=true)
ProfitTarget  = input(title="Profit Target %", type=input.float, defval=1, step=0.1, minval=0)
SLbutton      = input(title="Stop Loss On/Off", type=input.bool, defval=true)
StopLoss      = input(title="Stop Loss %", type=input.float, defval=-1, step=0.1, maxval=0)

//PROFIT TARGET & STOPLOSS

if PTbutton == true and SLbutton == true
    strategy.exit("EXIT", profit=((close*(ProfitTarget*0.01))/syminfo.mintick), loss=((close*(StopLoss*-0.01))/syminfo.mintick))
else
    if PTbutton == true and SLbutton == false
        strategy.exit("PT EXIT", profit=((close*(ProfitTarget*0.01))/syminfo.mintick))
    else
        if PTbutton == false and SLbutton == true
            strategy.exit("SL EXIT", loss=((close*(StopLoss*-0.01))/syminfo.mintick))
        else    
            strategy.cancel("PT EXIT")

// S/R Code By johan.gradin (lines 36-46)
// Buy setup//
priceflip1 = barssince(close>close[4])
buysetup = close<close[4] and priceflip1
buy = buysetup and barssince(priceflip1!=9)
buyovershoot = barssince(priceflip1!=13) and buysetup
// Sell Setup //
priceflip = barssince(close<close[4])
sellsetup = close>close[4] and priceflip
sell = sellsetup and barssince(priceflip!=9)
sellovershoot = sellsetup and barssince(priceflip!=13)


///////
/////// SMA
///////

if LongShort =="Long Only" and AboveBelowL == "Above" and MAs1 == "SMA" and TLma == "SMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<sma(close,SMAlenL) and close>sma(close,TrendLength))
    strategy.close("LONG", when = close>sma(close,SMAlenL))
    
if LongShort =="Long Only" and  AboveBelowL == "Below" and MAs1 == "SMA" and TLma == "SMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<sma(close,SMAlenL) and  close<sma(close,TrendLength))
    strategy.close("LONG", when = close>sma(close,SMAlenL))

if LongShort =="Long Only" and  AboveBelowL == "Don't Include" and MAs1 == "SMA" and TLma == "SMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<sma(close,SMAlenL) )
    strategy.close("LONG", when = close>sma(close,SMAlenL))
    
///////
    
if LongShort =="Short Only" and  AboveBelowS == "Above" and MAs2 == "SMA" and TLma == "SMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>sma(close,SMAlenS) and close>sma(close,TrendLength))
    strategy.close("SHORT", when = close<sma(close,SMAlenS))
    
if LongShort =="Short Only" and  AboveBelowS == "Below" and MAs2 == "SMA" and TLma == "SMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>sma(close,SMAlenS) and close<sma(close,TrendLength))
    strategy.close("SHORT",  when = close<sma(close,SMAlenS))

if LongShort =="Short Only" and  AboveBelowS == "Don't Include" and MAs2 == "SMA" and TLma == "SMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>sma(close,SMAlenS) )
    strategy.close("SHORT",  when = close<sma(close,SMAlenS))

///////
    
if LongShort =="Both" and AboveBelowL == "Above" and MAs1 == "SMA" and TLma == "SMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<sma(close,SMAlenL) and close>sma(close,TrendLength))
    strategy.close("LONG", when = close>sma(close,SMAlenL))
    
if LongShort =="Both" and  AboveBelowL == "Below" and MAs1 == "SMA" and TLma == "SMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<sma(close,SMAlenL) and  close<sma(close,TrendLength))
    strategy.close("LONG", when = close>sma(close,SMAlenL))

if LongShort =="Both" and  AboveBelowL == "Don't Include" and MAs1 == "SMA" and TLma == "SMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<sma(close,SMAlenL) )
    strategy.close("LONG", when = close>sma(close,SMAlenL))
    
    
if LongShort =="Both" and  AboveBelowS == "Above" and MAs2 == "SMA" and TLma == "SMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>sma(close,SMAlenS) and close>sma(close,TrendLength))
    strategy.close("SHORT", when = close<sma(close,SMAlenS))
    
if LongShort =="Both" and  AboveBelowS == "Below" and MAs2 == "SMA" and TLma == "SMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>sma(close,SMAlenS) and close<sma(close,TrendLength))
    strategy.close("SHORT",  when = close<sma(close,SMAlenS))

if LongShort =="Both" and  AboveBelowS == "Don't Include" and MAs2 == "SMA" and TLma == "SMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>sma(close,SMAlenS) )
    strategy.close("SHORT",  when = close<sma(close,SMAlenS))  

///////
/////// EMA
///////

if LongShort =="Long Only" and AboveBelowL == "Above" and MAs1 == "EMA" and TLma == "SMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<ema(close,SMAlenL) and close>sma(close,TrendLength))
    strategy.close("LONG", when = close>ema(close,SMAlenL))
    
if LongShort =="Long Only" and  AboveBelowL == "Below" and MAs1 == "EMA" and TLma == "SMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<ema(close,SMAlenL) and  close<sma(close,TrendLength))
    strategy.close("LONG", when = close>ema(close,SMAlenL))

if LongShort =="Long Only" and  AboveBelowL == "Don't Include" and MAs1 == "EMA" and TLma == "SMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<ema(close,SMAlenL) )
    strategy.close("LONG", when = close>ema(close,SMAlenL))
    
///////
    
if LongShort =="Short Only" and  AboveBelowS == "Above" and MAs2 == "EMA" and TLma == "SMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>ema(close,SMAlenS) and close>sma(close,TrendLength))
    strategy.close("SHORT", when = close<ema(close,SMAlenS))
    
if LongShort =="Short Only" and  AboveBelowS == "Below" and MAs2 == "EMA" and TLma == "SMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>ema(close,SMAlenS) and close<sma(close,TrendLength))
    strategy.close("SHORT",  when = close<ema(close,SMAlenS))

if LongShort =="Short Only" and  AboveBelowS == "Don't Include" and MAs2 == "EMA" and TLma == "SMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>ema(close,SMAlenS) )
    strategy.close("SHORT",  when = close<ema(close,SMAlenS))

///////
    
if LongShort =="Both" and AboveBelowL == "Above" and MAs1 == "EMA" and TLma == "SMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<ema(close,SMAlenL) and close>sma(close,TrendLength))
    strategy.close("LONG", when = close>ema(close,SMAlenL))
    
if LongShort =="Both" and  AboveBelowL == "Below" and MAs1 == "EMA" and TLma == "SMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<ema(close,SMAlenL) and  close<sma(close,TrendLength))
    strategy.close("LONG", when = close>ema(close,SMAlenL))

if LongShort =="Both" and  AboveBelowL == "Don't Include" and MAs1 == "EMA" and TLma == "SMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<ema(close,SMAlenL) )
    strategy.close("LONG", when = close>ema(close,SMAlenL))
    
    
if LongShort =="Both" and  AboveBelowS == "Above" and MAs2 == "EMA" and TLma == "SMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>ema(close,SMAlenS) and close>sma(close,TrendLength))
    strategy.close("SHORT", when = close<ema(close,SMAlenS))
    
if LongShort =="Both" and  AboveBelowS == "Below" and MAs2 == "EMA" and TLma == "SMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>ema(close,SMAlenS) and close<sma(close,TrendLength))
    strategy.close("SHORT",  when = close<ema(close,SMAlenS))

if LongShort =="Both" and  AboveBelowS == "Don't Include" and MAs2 == "EMA" and TLma == "SMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>ema(close,SMAlenS) )
    strategy.close("SHORT",  when = close<ema(close,SMAlenS)) 



///////
/////// VWMA
///////

if LongShort =="Long Only" and AboveBelowL == "Above" and MAs1 == "VWMA" and TLma == "SMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<vwma(close,SMAlenL) and close>sma(close,TrendLength))
    strategy.close("LONG", when = close>vwma(close,SMAlenL))
    
if LongShort =="Long Only" and  AboveBelowL == "Below" and MAs1 == "VWMA" and TLma == "SMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<vwma(close,SMAlenL) and  close<sma(close,TrendLength))
    strategy.close("LONG", when = close>vwma(close,SMAlenL))

if LongShort =="Long Only" and  AboveBelowL == "Don't Include" and MAs1 == "VWMA" and TLma == "SMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<vwma(close,SMAlenL) )
    strategy.close("LONG", when = close>vwma(close,SMAlenL))
    
///////
    
if LongShort =="Short Only" and  AboveBelowS == "Above" and MAs2 == "VWMA" and TLma == "SMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>vwma(close,SMAlenS) and close>sma(close,TrendLength))
    strategy.close("SHORT", when = close<vwma(close,SMAlenS))
    
if LongShort =="Short Only" and  AboveBelowS == "Below" and MAs2 == "VWMA" and TLma == "SMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>vwma(close,SMAlenS) and close<sma(close,TrendLength))
    strategy.close("SHORT",  when = close<vwma(close,SMAlenS))

if LongShort =="Short Only" and  AboveBelowS == "Don't Include" and MAs2 == "VWMA" and TLma == "SMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>vwma(close,SMAlenS) )
    strategy.close("SHORT",  when = close<vwma(close,SMAlenS))

///////
    
if LongShort =="Both" and AboveBelowL == "Above" and MAs1 == "VWMA" and TLma == "SMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<vwma(close,SMAlenL) and close>sma(close,TrendLength))
    strategy.close("LONG", when = close>vwma(close,SMAlenL))
    
if LongShort =="Both" and  AboveBelowL == "Below" and MAs1 == "VWMA" and TLma == "SMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<vwma(close,SMAlenL) and  close<sma(close,TrendLength))
    strategy.close("LONG", when = close>vwma(close,SMAlenL))

if LongShort =="Both" and  AboveBelowL == "Don't Include" and MAs1 == "VWMA" and TLma == "SMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<vwma(close,SMAlenL) )
    strategy.close("LONG", when = close>vwma(close,SMAlenL))
    
    
if LongShort =="Both" and  AboveBelowS == "Above" and MAs2 == "VWMA" and TLma == "SMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>vwma(close,SMAlenS) and close>sma(close,TrendLength))
    strategy.close("SHORT", when = close<vwma(close,SMAlenS))
    
if LongShort =="Both" and  AboveBelowS == "Below" and MAs2 == "VWMA" and TLma == "SMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>vwma(close,SMAlenS) and close<sma(close,TrendLength))
    strategy.close("SHORT",  when = close<vwma(close,SMAlenS))

if LongShort =="Both" and  AboveBelowS == "Don't Include" and MAs2 == "VWMA" and TLma == "SMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>vwma(close,SMAlenS) )
    strategy.close("SHORT",  when = close<vwma(close,SMAlenS)) 

    
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////
/////// SMA
///////


if LongShort =="Long Only" and AboveBelowL == "Above" and MAs1 == "SMA" and TLma == "EMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<sma(close,SMAlenL) and close>ema(close,TrendLength))
    strategy.close("LONG", when = close>sma(close,SMAlenL))
    
if LongShort =="Long Only" and  AboveBelowL == "Below" and MAs1 == "SMA" and TLma == "EMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<sma(close,SMAlenL) and  close<ema(close,TrendLength))
    strategy.close("LONG", when = close>sma(close,SMAlenL))

if LongShort =="Long Only" and  AboveBelowL == "Don't Include" and MAs1 == "SMA" and TLma == "EMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<sma(close,SMAlenL) )
    strategy.close("LONG", when = close>sma(close,SMAlenL))
    
///////
    
if LongShort =="Short Only" and  AboveBelowS == "Above" and MAs2 == "SMA" and TLma == "EMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>sma(close,SMAlenS) and close>ema(close,TrendLength))
    strategy.close("SHORT", when = close<sma(close,SMAlenS))
    
if LongShort =="Short Only" and  AboveBelowS == "Below" and MAs2 == "SMA" and TLma == "EMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>sma(close,SMAlenS) and close<ema(close,TrendLength))
    strategy.close("SHORT",  when = close<sma(close,SMAlenS))

if LongShort =="Short Only" and  AboveBelowS == "Don't Include" and MAs2 == "SMA" and TLma == "EMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>sma(close,SMAlenS) )
    strategy.close("SHORT",  when = close<sma(close,SMAlenS))

///////
    
if LongShort =="Both" and AboveBelowL == "Above" and MAs1 == "SMA" and TLma == "EMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<sma(close,SMAlenL) and close>ema(close,TrendLength))
    strategy.close("LONG", when = close>sma(close,SMAlenL))
    
if LongShort =="Both" and  AboveBelowL == "Below" and MAs1 == "SMA" and TLma == "EMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<sma(close,SMAlenL) and  close<ema(close,TrendLength))
    strategy.close("LONG", when = close>sma(close,SMAlenL))

if LongShort =="Both" and  AboveBelowL == "Don't Include" and MAs1 == "SMA" and TLma == "EMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<sma(close,SMAlenL) )
    strategy.close("LONG", when = close>sma(close,SMAlenL))
    
    
if LongShort =="Both" and  AboveBelowS == "Above" and MAs2 == "SMA" and TLma == "EMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>sma(close,SMAlenS) and close>ema(close,TrendLength))
    strategy.close("SHORT", when = close<sma(close,SMAlenS))
    
if LongShort =="Both" and  AboveBelowS == "Below" and MAs2 == "SMA" and TLma == "EMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>sma(close,SMAlenS) and close<ema(close,TrendLength))
    strategy.close("SHORT",  when = close<sma(close,SMAlenS))

if LongShort =="Both" and  AboveBelowS == "Don't Include" and MAs2 == "SMA" and TLma == "EMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>sma(close,SMAlenS) )
    strategy.close("SHORT",  when = close<sma(close,SMAlenS))  

///////
/////// EMA
///////

if LongShort =="Long Only" and AboveBelowL == "Above" and MAs1 == "EMA" and TLma == "EMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<ema(close,SMAlenL) and close>ema(close,TrendLength))
    strategy.close("LONG", when = close>ema(close,SMAlenL))
    
if LongShort =="Long Only" and  AboveBelowL == "Below" and MAs1 == "EMA" and TLma == "EMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<ema(close,SMAlenL) and  close<ema(close,TrendLength))
    strategy.close("LONG", when = close>ema(close,SMAlenL))

if LongShort =="Long Only" and  AboveBelowL == "Don't Include" and MAs1 == "EMA" and TLma == "EMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<ema(close,SMAlenL) )
    strategy.close("LONG", when = close>ema(close,SMAlenL))
    
///////
    
if LongShort =="Short Only" and  AboveBelowS == "Above" and MAs2 == "EMA" and TLma == "EMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>ema(close,SMAlenS) and close>ema(close,TrendLength))
    strategy.close("SHORT", when = close<ema(close,SMAlenS))
    
if LongShort =="Short Only" and  AboveBelowS == "Below" and MAs2 == "EMA" and TLma == "EMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>ema(close,SMAlenS) and close<ema(close,TrendLength))
    strategy.close("SHORT",  when = close<ema(close,SMAlenS))

if LongShort =="Short Only" and  AboveBelowS == "Don't Include" and MAs2 == "EMA" and TLma == "EMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>ema(close,SMAlenS) )
    strategy.close("SHORT",  when = close<ema(close,SMAlenS))

///////
    
if LongShort =="Both" and AboveBelowL == "Above" and MAs1 == "EMA" and TLma == "EMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<ema(close,SMAlenL) and close>ema(close,TrendLength))
    strategy.close("LONG", when = close>ema(close,SMAlenL))
    
if LongShort =="Both" and  AboveBelowL == "Below" and MAs1 == "EMA" and TLma == "EMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<ema(close,SMAlenL) and  close<ema(close,TrendLength))
    strategy.close("LONG", when = close>ema(close,SMAlenL))

if LongShort =="Both" and  AboveBelowL == "Don't Include" and MAs1 == "EMA" and TLma == "EMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<ema(close,SMAlenL) )
    strategy.close("LONG", when = close>ema(close,SMAlenL))
    
    
if LongShort =="Both" and  AboveBelowS == "Above" and MAs2 == "EMA" and TLma == "EMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>ema(close,SMAlenS) and close>ema(close,TrendLength))
    strategy.close("SHORT", when = close<ema(close,SMAlenS))
    
if LongShort =="Both" and  AboveBelowS == "Below" and MAs2 == "EMA" and TLma == "EMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>ema(close,SMAlenS) and close<ema(close,TrendLength))
    strategy.close("SHORT",  when = close<ema(close,SMAlenS))

if LongShort =="Both" and  AboveBelowS == "Don't Include" and MAs2 == "EMA" and TLma == "EMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>ema(close,SMAlenS) )
    strategy.close("SHORT",  when = close<ema(close,SMAlenS)) 



///////
/////// VWMA
///////

if LongShort =="Long Only" and AboveBelowL == "Above" and MAs1 == "VWMA" and TLma == "EMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<vwma(close,SMAlenL) and close>ema(close,TrendLength))
    strategy.close("LONG", when = close>vwma(close,SMAlenL))
    
if LongShort =="Long Only" and  AboveBelowL == "Below" and MAs1 == "VWMA" and TLma == "EMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<vwma(close,SMAlenL) and  close<ema(close,TrendLength))
    strategy.close("LONG", when = close>vwma(close,SMAlenL))

if LongShort =="Long Only" and  AboveBelowL == "Don't Include" and MAs1 == "VWMA" and TLma == "EMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<vwma(close,SMAlenL) )
    strategy.close("LONG", when = close>vwma(close,SMAlenL))
    
///////
    
if LongShort =="Short Only" and  AboveBelowS == "Above" and MAs2 == "VWMA" and TLma == "EMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>vwma(close,SMAlenS) and close>ema(close,TrendLength))
    strategy.close("SHORT", when = close<vwma(close,SMAlenS))
    
if LongShort =="Short Only" and  AboveBelowS == "Below" and MAs2 == "VWMA" and TLma == "EMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>vwma(close,SMAlenS) and close<ema(close,TrendLength))
    strategy.close("SHORT",  when = close<vwma(close,SMAlenS))

if LongShort =="Short Only" and  AboveBelowS == "Don't Include" and MAs2 == "VWMA" and TLma == "EMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>vwma(close,SMAlenS) )
    strategy.close("SHORT",  when = close<vwma(close,SMAlenS))

///////
    
if LongShort =="Both" and AboveBelowL == "Above" and MAs1 == "VWMA" and TLma == "EMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<vwma(close,SMAlenL) and close>ema(close,TrendLength))
    strategy.close("LONG", when = close>vwma(close,SMAlenL))
    
if LongShort =="Both" and  AboveBelowL == "Below" and MAs1 == "VWMA" and TLma == "EMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<vwma(close,SMAlenL) and  close<ema(close,TrendLength))
    strategy.close("LONG", when = close>vwma(close,SMAlenL))

if LongShort =="Both" and  AboveBelowL == "Don't Include" and MAs1 == "VWMA" and TLma == "EMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<vwma(close,SMAlenL) )
    strategy.close("LONG", when = close>vwma(close,SMAlenL))
    
    
if LongShort =="Both" and  AboveBelowS == "Above" and MAs2 == "VWMA" and TLma == "EMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>vwma(close,SMAlenS) and close>ema(close,TrendLength))
    strategy.close("SHORT", when = close<vwma(close,SMAlenS))
    
if LongShort =="Both" and  AboveBelowS == "Below" and MAs2 == "VWMA" and TLma == "EMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>vwma(close,SMAlenS) and close<ema(close,TrendLength))
    strategy.close("SHORT",  when = close<vwma(close,SMAlenS))

if LongShort =="Both" and  AboveBelowS == "Don't Include" and MAs2 == "VWMA" and TLma == "EMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>vwma(close,SMAlenS) )
    strategy.close("SHORT",  when = close<vwma(close,SMAlenS)) 

    
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////
/////// SMA
///////


if LongShort =="Long Only" and AboveBelowL == "Above" and MAs1 == "SMA" and TLma == "VWMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<sma(close,SMAlenL) and close>vwma(close,TrendLength))
    strategy.close("LONG", when = close>sma(close,SMAlenL))
    
if LongShort =="Long Only" and  AboveBelowL == "Below" and MAs1 == "SMA" and TLma == "VWMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<sma(close,SMAlenL) and  close<vwma(close,TrendLength))
    strategy.close("LONG", when = close>sma(close,SMAlenL))

if LongShort =="Long Only" and  AboveBelowL == "Don't Include" and MAs1 == "SMA" and TLma == "VWMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<sma(close,SMAlenL) )
    strategy.close("LONG", when = close>sma(close,SMAlenL))
    
///////
    
if LongShort =="Short Only" and  AboveBelowS == "Above" and MAs2 == "SMA" and TLma == "VWMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>sma(close,SMAlenS) and close>vwma(close,TrendLength))
    strategy.close("SHORT", when = close<sma(close,SMAlenS))
    
if LongShort =="Short Only" and  AboveBelowS == "Below" and MAs2 == "SMA" and TLma == "VWMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>sma(close,SMAlenS) and close<vwma(close,TrendLength))
    strategy.close("SHORT",  when = close<sma(close,SMAlenS))

if LongShort =="Short Only" and  AboveBelowS == "Don't Include" and MAs2 == "SMA" and TLma == "VWMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>sma(close,SMAlenS) )
    strategy.close("SHORT",  when = close<sma(close,SMAlenS))

///////
    
if LongShort =="Both" and AboveBelowL == "Above" and MAs1 == "SMA" and TLma == "VWMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<sma(close,SMAlenL) and close>vwma(close,TrendLength))
    strategy.close("LONG", when = close>sma(close,SMAlenL))
    
if LongShort =="Both" and  AboveBelowL == "Below" and MAs1 == "SMA" and TLma == "VWMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<sma(close,SMAlenL) and  close<vwma(close,TrendLength))
    strategy.close("LONG", when = close>sma(close,SMAlenL))

if LongShort =="Both" and  AboveBelowL == "Don't Include" and MAs1 == "SMA" and TLma == "VWMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<sma(close,SMAlenL) )
    strategy.close("LONG", when = close>sma(close,SMAlenL))
    
    
if LongShort =="Both" and  AboveBelowS == "Above" and MAs2 == "SMA" and TLma == "VWMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>sma(close,SMAlenS) and close>vwma(close,TrendLength))
    strategy.close("SHORT", when = close<sma(close,SMAlenS))
    
if LongShort =="Both" and  AboveBelowS == "Below" and MAs2 == "SMA" and TLma == "VWMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>sma(close,SMAlenS) and close<vwma(close,TrendLength))
    strategy.close("SHORT",  when = close<sma(close,SMAlenS))

if LongShort =="Both" and  AboveBelowS == "Don't Include" and MAs2 == "SMA" and TLma == "VWMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>sma(close,SMAlenS) )
    strategy.close("SHORT",  when = close<sma(close,SMAlenS))  

///////
/////// EMA
///////

if LongShort =="Long Only" and AboveBelowL == "Above" and MAs1 == "EMA" and TLma == "VWMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<ema(close,SMAlenL) and close>vwma(close,TrendLength))
    strategy.close("LONG", when = close>ema(close,SMAlenL))
    
if LongShort =="Long Only" and  AboveBelowL == "Below" and MAs1 == "EMA" and TLma == "VWMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<ema(close,SMAlenL) and  close<vwma(close,TrendLength))
    strategy.close("LONG", when = close>ema(close,SMAlenL))

if LongShort =="Long Only" and  AboveBelowL == "Don't Include" and MAs1 == "EMA" and TLma == "VWMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<ema(close,SMAlenL) )
    strategy.close("LONG", when = close>ema(close,SMAlenL))
    
///////
    
if LongShort =="Short Only" and  AboveBelowS == "Above" and MAs2 == "EMA" and TLma == "VWMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>ema(close,SMAlenS) and close>vwma(close,TrendLength))
    strategy.close("SHORT", when = close<ema(close,SMAlenS))
    
if LongShort =="Short Only" and  AboveBelowS == "Below" and MAs2 == "EMA" and TLma == "VWMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>ema(close,SMAlenS) and close<vwma(close,TrendLength))
    strategy.close("SHORT",  when = close<ema(close,SMAlenS))

if LongShort =="Short Only" and  AboveBelowS == "Don't Include" and MAs2 == "EMA" and TLma == "VWMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>ema(close,SMAlenS) )
    strategy.close("SHORT",  when = close<ema(close,SMAlenS))

///////
    
if LongShort =="Both" and AboveBelowL == "Above" and MAs1 == "EMA" and TLma == "VWMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<ema(close,SMAlenL) and close>vwma(close,TrendLength))
    strategy.close("LONG", when = close>ema(close,SMAlenL))
    
if LongShort =="Both" and  AboveBelowL == "Below" and MAs1 == "EMA" and TLma == "VWMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<ema(close,SMAlenL) and  close<vwma(close,TrendLength))
    strategy.close("LONG", when = close>ema(close,SMAlenL))

if LongShort =="Both" and  AboveBelowL == "Don't Include" and MAs1 == "EMA" and TLma == "VWMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<ema(close,SMAlenL) )
    strategy.close("LONG", when = close>ema(close,SMAlenL))
    
    
if LongShort =="Both" and  AboveBelowS == "Above" and MAs2 == "EMA" and TLma == "VWMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>ema(close,SMAlenS) and close>vwma(close,TrendLength))
    strategy.close("SHORT", when = close<ema(close,SMAlenS))
    
if LongShort =="Both" and  AboveBelowS == "Below" and MAs2 == "EMA" and TLma == "VWMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>ema(close,SMAlenS) and close<vwma(close,TrendLength))
    strategy.close("SHORT",  when = close<ema(close,SMAlenS))

if LongShort =="Both" and  AboveBelowS == "Don't Include" and MAs2 == "EMA" and TLma == "VWMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>ema(close,SMAlenS) )
    strategy.close("SHORT",  when = close<ema(close,SMAlenS)) 



///////
/////// VWMA
///////

if LongShort =="Long Only" and AboveBelowL == "Above" and MAs1 == "VWMA" and TLma == "VWMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<vwma(close,SMAlenL) and close>vwma(close,TrendLength))
    strategy.close("LONG", when = close>vwma(close,SMAlenL))
    
if LongShort =="Long Only" and  AboveBelowL == "Below" and MAs1 == "VWMA" and TLma == "VWMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<vwma(close,SMAlenL) and  close<vwma(close,TrendLength))
    strategy.close("LONG", when = close>vwma(close,SMAlenL))

if LongShort =="Long Only" and  AboveBelowL == "Don't Include" and MAs1 == "VWMA" and TLma == "VWMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<vwma(close,SMAlenL) )
    strategy.close("LONG", when = close>vwma(close,SMAlenL))
    
///////
    
if LongShort =="Short Only" and  AboveBelowS == "Above" and MAs2 == "VWMA" and TLma == "VWMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>vwma(close,SMAlenS) and close>vwma(close,TrendLength))
    strategy.close("SHORT", when = close<vwma(close,SMAlenS))
    
if LongShort =="Short Only" and  AboveBelowS == "Below" and MAs2 == "VWMA" and TLma == "VWMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>vwma(close,SMAlenS) and close<vwma(close,TrendLength))
    strategy.close("SHORT",  when = close<vwma(close,SMAlenS))

if LongShort =="Short Only" and  AboveBelowS == "Don't Include" and MAs2 == "VWMA" and TLma == "VWMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>vwma(close,SMAlenS) )
    strategy.close("SHORT",  when = close<vwma(close,SMAlenS))

///////
    
if LongShort =="Both" and AboveBelowL == "Above" and MAs1 == "VWMA" and TLma == "VWMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<vwma(close,SMAlenL) and close>vwma(close,TrendLength))
    strategy.close("LONG", when = close>vwma(close,SMAlenL))
    
if LongShort =="Both" and  AboveBelowL == "Below" and MAs1 == "VWMA" and TLma == "VWMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<vwma(close,SMAlenL) and  close<vwma(close,TrendLength))
    strategy.close("LONG", when = close>vwma(close,SMAlenL))

if LongShort =="Both" and  AboveBelowL == "Don't Include" and MAs1 == "VWMA" and TLma == "VWMA"
    strategy.entry("LONG", true, when = buysetup and barssince(priceflip1!=PriceFlipL) and close<vwma(close,SMAlenL) )
    strategy.close("LONG", when = close>vwma(close,SMAlenL))
    
    
if LongShort =="Both" and  AboveBelowS == "Above" and MAs2 == "VWMA" and TLma == "VWMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>vwma(close,SMAlenS) and close>vwma(close,TrendLength))
    strategy.close("SHORT", when = close<vwma(close,SMAlenS))
    
if LongShort =="Both" and  AboveBelowS == "Below" and MAs2 == "VWMA" and TLma == "VWMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>vwma(close,SMAlenS) and close<vwma(close,TrendLength))
    strategy.close("SHORT",  when = close<vwma(close,SMAlenS))

if LongShort =="Both" and  AboveBelowS == "Don't Include" and MAs2 == "VWMA" and TLma == "VWMA"
    strategy.entry("SHORT", false, when = sellsetup and barssince(priceflip!=PriceFlipS) and close>vwma(close,SMAlenS) )
    strategy.close("SHORT",  when = close<vwma(close,SMAlenS)) 

    
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    

अधिक