Stratégie de croisement des moyennes mobiles

Auteur:ChaoZhang est là., Date: 2023-10-09 17h03 et 23h
Les étiquettes:

Résumé

La stratégie permet de sélectionner différents types de moyennes mobiles et de configurer des paramètres moyennes mobiles à court et à long terme pour produire des signaux d'achat et de vente.

La logique de la stratégie

La logique de base de cette stratégie est basée sur le croisement de deux moyennes mobiles pour générer des signaux de trading.

  • Un signal d'achat est généré lorsque la moyenne mobile à court terme dépasse la moyenne mobile à long terme.

  • Un signal de vente est généré lorsque la moyenne mobile à court terme dépasse la moyenne mobile à long terme.

En outre, la stratégie offre la possibilité de sélectionner parmi quatre types de moyennes mobiles, notamment la moyenne mobile simple (SMA), la moyenne mobile exponentielle (EMA), la moyenne mobile pondérée (WMA) et la moyenne mobile pondérée par volume (VWMA).

En outre, la stratégie offre trois modes d'opération: long only, short only et long/short, ce qui permet aux utilisateurs de choisir la direction de négociation appropriée selon les différentes conditions du marché.

Enfin, une option de filtrage de tendance est incluse. Cela nécessite que les signaux de trading s'alignent sur la direction de la tendance, sinon le signal sera ignoré. Plus précisément, lorsque l'option est définie sur Above, seuls les signaux longs sont générés lorsque le prix est supérieur à la moyenne mobile de la tendance. Lorsque l'option est définie sur Below, seuls les signaux courts sont générés lorsque le prix est inférieur à la moyenne mobile de la tendance.

Analyse des avantages

L'avantage majeur de cette stratégie est qu'elle est paramétrique et flexible. Les moyennes mobiles, en tant qu'un des indicateurs techniques les plus basiques, sont largement utilisés dans le trading quantitatif. Cette stratégie fournit un système de croisement de moyennes mobiles hautement configurable, de sorte que les utilisateurs peuvent ajuster flexiblement les paramètres pour s'adapter aux différentes conditions du marché.

Plus précisément, les avantages comprennent:

  • Fournir plusieurs types de moyennes mobiles parmi lesquels choisir, ce qui permet d'optimiser le système en ajustant les paramètres des moyennes mobiles

  • Périodes moyennes mobiles à court et à long terme configurables pour s'adapter aux différents cycles de marché

  • Directions de négociation longues ou courtes facultatives pour éviter des marchés unilatéraux défavorables

  • Filtrage facultatif des tendances afin d'éviter les opérations contre tendance

  • Une logique de stratégie simple et claire, facile à comprendre et à optimiser

En résumé, il s'agit d'un système de croisement des moyennes mobiles hautement flexible et personnalisable.

Analyse des risques

Les principaux risques de cette stratégie proviennent de:

  1. Les moyennes mobiles en tant qu'indicateurs en retard peuvent manquer les premières variations de prix

  2. Des combinaisons de paramètres inappropriées peuvent entraîner une sur-échange et une rentabilité moindre

  3. Le maintien de tendances fixes peut échouer lorsque le régime du marché change

Pour faire face à ces risques, les solutions suivantes peuvent être adoptées:

  1. Incorporer des indicateurs clés tels que le volume et la volatilité pour détecter les changements de prix précoces

  2. Optimiser les paramètres pour une plus grande rentabilité et contrôler la fréquence des échanges

  3. Ajustez dynamiquement les paramètres de stratégie pour les adapter aux tendances et aux variations des marchés

Directions d'optimisation

Les principales orientations d'optimisation de cette stratégie sont les suivantes:

  1. Ajouter d' autres indicateurs techniques tels que le volume et les bandes de Bollinger pour améliorer l' efficacité

  2. Incorporer le stop loss pour contrôler les pertes d'une seule transaction

  3. Utiliser des algorithmes d'apprentissage automatique pour optimiser dynamiquement les paramètres

  4. Identifier les tendances basées sur les structures du marché plutôt que sur de simples moyennes mobiles

  5. Incorporer des indicateurs de volatilité pour la dimensionnement dynamique des positions

Avec ces optimisations, le système peut avoir une meilleure gestion des risques, une robustesse et une adaptabilité aux marchés en évolution.

Conclusion

En conclusion, cette stratégie de croisement des moyennes mobiles est un système de suivi des tendances très typique. Il est simple, flexible, facile à comprendre et fournit un cadre hautement configurable. Les utilisateurs peuvent l'adapter à leurs vues sur les conditions du marché en sélectionnant des moyennes mobiles appropriées, en ajustant les paramètres et en configurant le trading long/short. Bien sûr, ils peuvent également enrichir le système en incorporant d'autres indicateurs techniques tout en conservant ses mérites de suivi des tendances. Avec des améliorations appropriées, il peut devenir une stratégie de trading quantitative plus complète et fiable.


/*backtest
start: 2023-09-08 00:00:00
end: 2023-10-08 00:00:00
period: 3h
basePeriod: 15m
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: Moving Average Crossover Strategy", overlay=true)

LongShort = input(title="Long Only or Short Only or Both?", type=input.string, defval="Both", options=["Both", "Long Only", "Short Only"])
MAs1 = input(title="Which Moving Average? (1)", type=input.string, defval="SMA", options=["SMA", "EMA", "WMA", "VWMA"])
MAs2 = input(title="Which Moving Average? (2)", type=input.string, defval="SMA", options=["SMA", "EMA", "WMA", "VWMA"])
MA1 = input(title="Moving Average Length 1", type = input.integer ,defval=10)
MAL2 = input(title="Moving Average Length 2", type = input.integer ,defval=20)
AboveBelow = input(title="Trend SMA Filter?", type=input.string, defval="Above", options=["Above", "Below", "Don't Include"])
TLen = input(title="Trend SMA Length", type = input.integer ,defval=200)


////////////////////////
///////LONG ONLY////////
////////////////////////

//ABOVE

if LongShort =="Long Only" and AboveBelow == "Above" and MAs1 == "SMA" and MAs2 == "SMA"
    strategy.entry("LONG", true, when = crossover(sma(close,MA1),sma(close,MAL2)) and close>sma(close,TLen))
    strategy.close("LONG", when = crossunder(sma(close,MA1),sma(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Above" and MAs1 == "SMA" and MAs2 == "EMA"
    strategy.entry("LONG", true, when = crossover(sma(close,MA1),ema(close,MAL2)) and close>sma(close,TLen))
    strategy.close("LONG", when = crossunder(sma(close,MA1),ema(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Above" and MAs1 == "SMA" and MAs2 == "VWMA"
    strategy.entry("LONG", true, when = crossover(sma(close,MA1),vwma(close,MAL2)) and close>sma(close,TLen))
    strategy.close("LONG", when = crossunder(sma(close,MA1),vwma(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Above" and MAs1 == "SMA" and MAs2 == "WMA"
    strategy.entry("LONG", true, when = crossover(sma(close,MA1),wma(close,MAL2)) and close>sma(close,TLen))
    strategy.close("LONG", when = crossunder(sma(close,MA1),wma(close,MAL2)))    
   
    
///--///    

if LongShort =="Long Only" and AboveBelow == "Above" and MAs1 == "EMA" and MAs2 == "SMA"
    strategy.entry("LONG", true, when = crossover(ema(close,MA1),sma(close,MAL2)) and close>sma(close,TLen))
    strategy.close("LONG", when = crossunder(ema(close,MA1),sma(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Above" and MAs1 == "EMA" and MAs2 == "EMA"
    strategy.entry("LONG", true, when = crossover(ema(close,MA1),ema(close,MAL2)) and close>sma(close,TLen))
    strategy.close("LONG", when = crossunder(ema(close,MA1),ema(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Above" and MAs1 == "EMA" and MAs2 == "VWMA"
    strategy.entry("LONG", true, when = crossover(ema(close,MA1),vwma(close,MAL2)) and close>sma(close,TLen))
    strategy.close("LONG", when = crossunder(ema(close,MA1),vwma(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Above" and MAs1 == "EMA" and MAs2 == "WMA"
    strategy.entry("LONG", true, when = crossover(ema(close,MA1),wma(close,MAL2)) and close>sma(close,TLen))
    strategy.close("LONG", when = crossunder(ema(close,MA1),wma(close,MAL2)))
  
    
///--///     
    
if LongShort =="Long Only" and AboveBelow == "Above" and MAs1 == "VWMA" and MAs2 == "VWMA"
    strategy.entry("LONG", true, when = crossover(vwma(close,MA1),vwma(close,MAL2)) and close>sma(close,TLen))
    strategy.close("LONG", when = crossunder(vwma(close,MA1),vwma(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Above" and MAs1 == "VWMA" and MAs2 == "SMA"
    strategy.entry("LONG", true, when = crossover(vwma(close,MA1),sma(close,MAL2)) and close>sma(close,TLen))
    strategy.close("LONG", when = crossunder(vwma(close,MA1),sma(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Above" and MAs1 == "VWMA" and MAs2 == "EMA"
    strategy.entry("LONG", true, when = crossover(vwma(close,MA1),ema(close,MAL2)) and close>sma(close,TLen))
    strategy.close("LONG", when = crossunder(vwma(close,MA1),ema(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Above" and MAs1 == "VWMA" and MAs2 == "WMA"
    strategy.entry("LONG", true, when = crossover(vwma(close,MA1),wma(close,MAL2)) and close>sma(close,TLen))
    strategy.close("LONG", when = crossunder(vwma(close,MA1),wma(close,MAL2))) 
 
    
///--///     
    
if LongShort =="Long Only" and AboveBelow == "Above" and MAs1 == "WMA" and MAs2 == "WMA"
    strategy.entry("LONG", true, when = crossover(wma(close,MA1),wma(close,MAL2)) and close>sma(close,TLen))
    strategy.close("LONG", when = crossunder(wma(close,MA1),wma(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Above" and MAs1 == "WMA" and MAs2 == "SMA"
    strategy.entry("LONG", true, when = crossover(wma(close,MA1),sma(close,MAL2)) and close>sma(close,TLen))
    strategy.close("LONG", when = crossunder(wma(close,MA1),sma(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Above" and MAs1 == "WMA" and MAs2 == "EMA"
    strategy.entry("LONG", true, when = crossover(wma(close,MA1),ema(close,MAL2)) and close>sma(close,TLen))
    strategy.close("LONG", when = crossunder(wma(close,MA1),ema(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Above" and MAs1 == "WMA" and MAs2 == "VWMA"
    strategy.entry("LONG", true, when = crossover(wma(close,MA1),vwma(close,MAL2)) and close>sma(close,TLen))
    strategy.close("LONG", when = crossunder(wma(close,MA1),vwma(close,MAL2)))  

    
// BELOW

if LongShort =="Long Only" and AboveBelow == "Below" and MAs1 == "SMA" and MAs2 == "SMA"
    strategy.entry("LONG", true, when = crossover(sma(close,MA1),sma(close,MAL2)) and close<sma(close,TLen))
    strategy.close("LONG", when = crossunder(sma(close,MA1),sma(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Below" and MAs1 == "SMA" and MAs2 == "EMA"
    strategy.entry("LONG", true, when = crossover(sma(close,MA1),ema(close,MAL2)) and close<sma(close,TLen))
    strategy.close("LONG", when = crossunder(sma(close,MA1),ema(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Below" and MAs1 == "SMA" and MAs2 == "VWMA"
    strategy.entry("LONG", true, when = crossover(sma(close,MA1),vwma(close,MAL2)) and close<sma(close,TLen))
    strategy.close("LONG", when = crossunder(sma(close,MA1),vwma(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Below" and MAs1 == "SMA" and MAs2 == "WMA"
    strategy.entry("LONG", true, when = crossover(sma(close,MA1),wma(close,MAL2)) and close<sma(close,TLen))
    strategy.close("LONG", when = crossunder(sma(close,MA1),wma(close,MAL2)))    

    
///--///    

if LongShort =="Long Only" and AboveBelow == "Below" and MAs1 == "EMA" and MAs2 == "SMA"
    strategy.entry("LONG", true, when = crossover(ema(close,MA1),sma(close,MAL2)) and close<sma(close,TLen))
    strategy.close("LONG", when = crossunder(ema(close,MA1),sma(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Below" and MAs1 == "EMA" and MAs2 == "EMA"
    strategy.entry("LONG", true, when = crossover(ema(close,MA1),ema(close,MAL2)) and close<sma(close,TLen))
    strategy.close("LONG", when = crossunder(ema(close,MA1),ema(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Below" and MAs1 == "EMA" and MAs2 == "VWMA"
    strategy.entry("LONG", true, when = crossover(ema(close,MA1),vwma(close,MAL2)) and close<sma(close,TLen))
    strategy.close("LONG", when = crossunder(ema(close,MA1),vwma(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Below" and MAs1 == "EMA" and MAs2 == "WMA"
    strategy.entry("LONG", true, when = crossover(ema(close,MA1),wma(close,MAL2)) and close<sma(close,TLen))
    strategy.close("LONG", when = crossunder(ema(close,MA1),wma(close,MAL2)))
     
    
///--///     
    
if LongShort =="Long Only" and AboveBelow == "Below" and MAs1 == "VWMA" and MAs2 == "VWMA"
    strategy.entry("LONG", true, when = crossover(vwma(close,MA1),vwma(close,MAL2)) and close<sma(close,TLen))
    strategy.close("LONG", when = crossunder(vwma(close,MA1),vwma(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Below" and MAs1 == "VWMA" and MAs2 == "SMA"
    strategy.entry("LONG", true, when = crossover(vwma(close,MA1),sma(close,MAL2)) and close<sma(close,TLen))
    strategy.close("LONG", when = crossunder(vwma(close,MA1),sma(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Below" and MAs1 == "VWMA" and MAs2 == "EMA"
    strategy.entry("LONG", true, when = crossover(vwma(close,MA1),ema(close,MAL2)) and close<sma(close,TLen))
    strategy.close("LONG", when = crossunder(vwma(close,MA1),ema(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Below" and MAs1 == "VWMA" and MAs2 == "WMA"
    strategy.entry("LONG", true, when = crossover(vwma(close,MA1),wma(close,MAL2)) and close<sma(close,TLen))
    strategy.close("LONG", when = crossunder(vwma(close,MA1),wma(close,MAL2))) 
    
    
///--///     
    
if LongShort =="Long Only" and AboveBelow == "Below" and MAs1 == "WMA" and MAs2 == "WMA"
    strategy.entry("LONG", true, when = crossover(wma(close,MA1),wma(close,MAL2)) and close<sma(close,TLen))
    strategy.close("LONG", when = crossunder(wma(close,MA1),wma(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Below" and MAs1 == "WMA" and MAs2 == "SMA"
    strategy.entry("LONG", true, when = crossover(wma(close,MA1),sma(close,MAL2)) and close<sma(close,TLen))
    strategy.close("LONG", when = crossunder(wma(close,MA1),sma(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Below" and MAs1 == "WMA" and MAs2 == "EMA"
    strategy.entry("LONG", true, when = crossover(wma(close,MA1),ema(close,MAL2)) and close<sma(close,TLen))
    strategy.close("LONG", when = crossunder(wma(close,MA1),ema(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Below" and MAs1 == "WMA" and MAs2 == "VWMA"
    strategy.entry("LONG", true, when = crossover(wma(close,MA1),vwma(close,MAL2)) and close<sma(close,TLen))
    strategy.close("LONG", when = crossunder(wma(close,MA1),vwma(close,MAL2)))  
    
    
// DONT INCLUDE

if LongShort =="Long Only" and AboveBelow == "Don't Include" and MAs1 == "SMA" and MAs2 == "SMA"
    strategy.entry("LONG", true, when = crossover(sma(close,MA1),sma(close,MAL2)) )
    strategy.close("LONG", when = crossunder(sma(close,MA1),sma(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Don't Include" and MAs1 == "SMA" and MAs2 == "EMA"
    strategy.entry("LONG", true, when = crossover(sma(close,MA1),ema(close,MAL2)) )
    strategy.close("LONG", when = crossunder(sma(close,MA1),ema(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Don't Include" and MAs1 == "SMA" and MAs2 == "VWMA"
    strategy.entry("LONG", true, when = crossover(sma(close,MA1),vwma(close,MAL2)) )
    strategy.close("LONG", when = crossunder(sma(close,MA1),vwma(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Don't Include" and MAs1 == "SMA" and MAs2 == "WMA"
    strategy.entry("LONG", true, when = crossover(sma(close,MA1),wma(close,MAL2)) )
    strategy.close("LONG", when = crossunder(sma(close,MA1),wma(close,MAL2)))    
   
    
///--///    

if LongShort =="Long Only" and AboveBelow == "Don't Include" and MAs1 == "EMA" and MAs2 == "SMA"
    strategy.entry("LONG", true, when = crossover(ema(close,MA1),sma(close,MAL2)) )
    strategy.close("LONG", when = crossunder(ema(close,MA1),sma(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Don't Include" and MAs1 == "EMA" and MAs2 == "EMA"
    strategy.entry("LONG", true, when = crossover(ema(close,MA1),ema(close,MAL2)) )
    strategy.close("LONG", when = crossunder(ema(close,MA1),ema(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Don't Include" and MAs1 == "EMA" and MAs2 == "VWMA"
    strategy.entry("LONG", true, when = crossover(ema(close,MA1),vwma(close,MAL2)) )
    strategy.close("LONG", when = crossunder(ema(close,MA1),vwma(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Don't Include" and MAs1 == "EMA" and MAs2 == "WMA"
    strategy.entry("LONG", true, when = crossover(ema(close,MA1),wma(close,MAL2)) )
    strategy.close("LONG", when = crossunder(ema(close,MA1),wma(close,MAL2)))
    
    
///--///     
    
if LongShort =="Long Only" and AboveBelow == "Don't Include" and MAs1 == "VWMA" and MAs2 == "VWMA"
    strategy.entry("LONG", true, when = crossover(vwma(close,MA1),vwma(close,MAL2)) )
    strategy.close("LONG", when = crossunder(vwma(close,MA1),vwma(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Don't Include" and MAs1 == "VWMA" and MAs2 == "SMA"
    strategy.entry("LONG", true, when = crossover(vwma(close,MA1),sma(close,MAL2)) )
    strategy.close("LONG", when = crossunder(vwma(close,MA1),sma(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Don't Include" and MAs1 == "VWMA" and MAs2 == "EMA"
    strategy.entry("LONG", true, when = crossover(vwma(close,MA1),ema(close,MAL2)) )
    strategy.close("LONG", when = crossunder(vwma(close,MA1),ema(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Don't Include" and MAs1 == "VWMA" and MAs2 == "WMA"
    strategy.entry("LONG", true, when = crossover(vwma(close,MA1),wma(close,MAL2)) )
    strategy.close("LONG", when = crossunder(vwma(close,MA1),wma(close,MAL2))) 
 
    
///--///     
    
if LongShort =="Long Only" and AboveBelow == "Don't Include" and MAs1 == "WMA" and MAs2 == "WMA"
    strategy.entry("LONG", true, when = crossover(wma(close,MA1),wma(close,MAL2)) )
    strategy.close("LONG", when = crossunder(wma(close,MA1),wma(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Don't Include" and MAs1 == "WMA" and MAs2 == "SMA"
    strategy.entry("LONG", true, when = crossover(wma(close,MA1),sma(close,MAL2)) )
    strategy.close("LONG", when = crossunder(wma(close,MA1),sma(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Don't Include" and MAs1 == "WMA" and MAs2 == "EMA"
    strategy.entry("LONG", true, when = crossover(wma(close,MA1),ema(close,MAL2)) )
    strategy.close("LONG", when = crossunder(wma(close,MA1),ema(close,MAL2)))
    
if LongShort =="Long Only" and AboveBelow == "Don't Include" and MAs1 == "WMA" and MAs2 == "VWMA"
    strategy.entry("LONG", true, when = crossover(wma(close,MA1),vwma(close,MAL2)) )
    strategy.close("LONG", when = crossunder(wma(close,MA1),vwma(close,MAL2)))  


////////////////////////
///////SHORT ONLY///////
////////////////////////

//ABOVE

if LongShort =="Short Only" and AboveBelow == "Above" and MAs1 == "SMA" and MAs2 == "SMA"
    strategy.entry("SHORT", false, when = crossunder(sma(close,MA1),sma(close,MAL2)) and close>sma(close,TLen))
    strategy.close("SHORT", when = crossover(sma(close,MA1),sma(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Above" and MAs1 == "SMA" and MAs2 == "EMA"
    strategy.entry("SHORT", false, when = crossunder(sma(close,MA1),ema(close,MAL2)) and close>sma(close,TLen))
    strategy.close("SHORT", when = crossover(sma(close,MA1),ema(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Above" and MAs1 == "SMA" and MAs2 == "VWMA"
    strategy.entry("SHORT", false, when = crossunder(sma(close,MA1),vwma(close,MAL2)) and close>sma(close,TLen))
    strategy.close("SHORT", when = crossover(sma(close,MA1),vwma(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Above" and MAs1 == "SMA" and MAs2 == "WMA"
    strategy.entry("SHORT", false, when = crossunder(sma(close,MA1),wma(close,MAL2)) and close>sma(close,TLen))
    strategy.close("SHORT", when = crossover(sma(close,MA1),wma(close,MAL2)))    
  
    
///--///    

if LongShort =="Short Only" and AboveBelow == "Above" and MAs1 == "EMA" and MAs2 == "SMA"
    strategy.entry("SHORT", false, when = crossunder(ema(close,MA1),sma(close,MAL2)) and close>sma(close,TLen))
    strategy.close("SHORT", when = crossover(ema(close,MA1),sma(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Above" and MAs1 == "EMA" and MAs2 == "EMA"
    strategy.entry("SHORT", false, when = crossunder(ema(close,MA1),ema(close,MAL2)) and close>sma(close,TLen))
    strategy.close("SHORT", when = crossover(ema(close,MA1),ema(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Above" and MAs1 == "EMA" and MAs2 == "VWMA"
    strategy.entry("SHORT", false, when = crossunder(ema(close,MA1),vwma(close,MAL2)) and close>sma(close,TLen))
    strategy.close("SHORT", when = crossover(ema(close,MA1),vwma(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Above" and MAs1 == "EMA" and MAs2 == "WMA"
    strategy.entry("SHORT", false, when = crossunder(ema(close,MA1),wma(close,MAL2)) and close>sma(close,TLen))
    strategy.close("SHORT", when = crossover(ema(close,MA1),wma(close,MAL2)))
  
    
///--///     
    
if LongShort =="Short Only" and AboveBelow == "Above" and MAs1 == "VWMA" and MAs2 == "VWMA"
    strategy.entry("SHORT", false, when = crossunder(vwma(close,MA1),vwma(close,MAL2)) and close>sma(close,TLen))
    strategy.close("SHORT", when = crossover(vwma(close,MA1),vwma(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Above" and MAs1 == "VWMA" and MAs2 == "SMA"
    strategy.entry("SHORT", false, when = crossunder(vwma(close,MA1),sma(close,MAL2)) and close>sma(close,TLen))
    strategy.close("SHORT", when = crossover(vwma(close,MA1),sma(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Above" and MAs1 == "VWMA" and MAs2 == "EMA"
    strategy.entry("SHORT", false, when = crossunder(vwma(close,MA1),ema(close,MAL2)) and close>sma(close,TLen))
    strategy.close("SHORT", when = crossover(vwma(close,MA1),ema(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Above" and MAs1 == "VWMA" and MAs2 == "WMA"
    strategy.entry("SHORT", false, when = crossunder(vwma(close,MA1),wma(close,MAL2)) and close>sma(close,TLen))
    strategy.close("SHORT", when = crossover(vwma(close,MA1),wma(close,MAL2))) 
   
    
///--///     
    
if LongShort =="Short Only" and AboveBelow == "Above" and MAs1 == "WMA" and MAs2 == "WMA"
    strategy.entry("SHORT", false, when = crossunder(wma(close,MA1),wma(close,MAL2)) and close>sma(close,TLen))
    strategy.close("SHORT", when = crossover(wma(close,MA1),wma(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Above" and MAs1 == "WMA" and MAs2 == "SMA"
    strategy.entry("SHORT", false, when = crossunder(wma(close,MA1),sma(close,MAL2)) and close>sma(close,TLen))
    strategy.close("SHORT", when = crossover(wma(close,MA1),sma(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Above" and MAs1 == "WMA" and MAs2 == "EMA"
    strategy.entry("SHORT", false, when = crossunder(wma(close,MA1),ema(close,MAL2)) and close>sma(close,TLen))
    strategy.close("SHORT", when = crossover(wma(close,MA1),ema(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Above" and MAs1 == "WMA" and MAs2 == "VWMA"
    strategy.entry("SHORT", false, when = crossunder(wma(close,MA1),vwma(close,MAL2)) and close>sma(close,TLen))
    strategy.close("SHORT", when = crossover(wma(close,MA1),vwma(close,MAL2)))  
    
// BELOW

if LongShort =="Short Only" and AboveBelow == "Below" and MAs1 == "SMA" and MAs2 == "SMA"
    strategy.entry("SHORT", false, when = crossunder(sma(close,MA1),sma(close,MAL2)) and close<sma(close,TLen))
    strategy.close("SHORT", when = crossover(sma(close,MA1),sma(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Below" and MAs1 == "SMA" and MAs2 == "EMA"
    strategy.entry("SHORT", false, when = crossunder(sma(close,MA1),ema(close,MAL2)) and close<sma(close,TLen))
    strategy.close("SHORT", when = crossover(sma(close,MA1),ema(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Below" and MAs1 == "SMA" and MAs2 == "VWMA"
    strategy.entry("SHORT", false, when = crossunder(sma(close,MA1),vwma(close,MAL2)) and close<sma(close,TLen))
    strategy.close("SHORT", when = crossover(sma(close,MA1),vwma(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Below" and MAs1 == "SMA" and MAs2 == "WMA"
    strategy.entry("SHORT", false, when = crossunder(sma(close,MA1),wma(close,MAL2)) and close<sma(close,TLen))
    strategy.close("SHORT", when = crossover(sma(close,MA1),wma(close,MAL2)))    
 
    
///--///    

if LongShort =="Short Only" and AboveBelow == "Below" and MAs1 == "EMA" and MAs2 == "SMA"
    strategy.entry("SHORT", false, when = crossunder(ema(close,MA1),sma(close,MAL2)) and close<sma(close,TLen))
    strategy.close("SHORT", when = crossover(ema(close,MA1),sma(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Below" and MAs1 == "EMA" and MAs2 == "EMA"
    strategy.entry("SHORT", false, when = crossunder(ema(close,MA1),ema(close,MAL2)) and close<sma(close,TLen))
    strategy.close("SHORT", when = crossover(ema(close,MA1),ema(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Below" and MAs1 == "EMA" and MAs2 == "VWMA"
    strategy.entry("SHORT", false, when = crossunder(ema(close,MA1),vwma(close,MAL2)) and close<sma(close,TLen))
    strategy.close("SHORT", when = crossover(ema(close,MA1),vwma(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Below" and MAs1 == "EMA" and MAs2 == "WMA"
    strategy.entry("SHORT", false, when = crossunder(ema(close,MA1),wma(close,MAL2)) and close<sma(close,TLen))
    strategy.close("SHORT", when = crossover(ema(close,MA1),wma(close,MAL2)))
   
    
///--///     
    
if LongShort =="Short Only" and AboveBelow == "Below" and MAs1 == "VWMA" and MAs2 == "VWMA"
    strategy.entry("SHORT", false, when = crossunder(vwma(close,MA1),vwma(close,MAL2)) and close<sma(close,TLen))
    strategy.close("SHORT", when = crossover(vwma(close,MA1),vwma(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Below" and MAs1 == "VWMA" and MAs2 == "SMA"
    strategy.entry("SHORT", false, when = crossunder(vwma(close,MA1),sma(close,MAL2)) and close<sma(close,TLen))
    strategy.close("SHORT", when = crossover(vwma(close,MA1),sma(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Below" and MAs1 == "VWMA" and MAs2 == "EMA"
    strategy.entry("SHORT", false, when = crossunder(vwma(close,MA1),ema(close,MAL2)) and close<sma(close,TLen))
    strategy.close("SHORT", when = crossover(vwma(close,MA1),ema(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Below" and MAs1 == "VWMA" and MAs2 == "WMA"
    strategy.entry("SHORT", false, when = crossunder(vwma(close,MA1),wma(close,MAL2)) and close<sma(close,TLen))
    strategy.close("SHORT", when = crossover(vwma(close,MA1),wma(close,MAL2))) 
  
    
///--///     
    
if LongShort =="Short Only" and AboveBelow == "Below" and MAs1 == "WMA" and MAs2 == "WMA"
    strategy.entry("SHORT", false, when = crossunder(wma(close,MA1),wma(close,MAL2)) and close<sma(close,TLen))
    strategy.close("SHORT", when = crossover(wma(close,MA1),wma(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Below" and MAs1 == "WMA" and MAs2 == "SMA"
    strategy.entry("SHORT", false, when = crossunder(wma(close,MA1),sma(close,MAL2)) and close<sma(close,TLen))
    strategy.close("SHORT", when = crossover(wma(close,MA1),sma(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Below" and MAs1 == "WMA" and MAs2 == "EMA"
    strategy.entry("SHORT", false, when = crossunder(wma(close,MA1),ema(close,MAL2)) and close<sma(close,TLen))
    strategy.close("SHORT", when = crossover(wma(close,MA1),ema(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Below" and MAs1 == "WMA" and MAs2 == "VWMA"
    strategy.entry("SHORT", false, when = crossunder(wma(close,MA1),vwma(close,MAL2)) and close<sma(close,TLen))
    strategy.close("SHORT", when = crossover(wma(close,MA1),vwma(close,MAL2)))  
    
// DONT INCLUDE

if LongShort =="Short Only" and AboveBelow == "Don't Include" and MAs1 == "SMA" and MAs2 == "SMA"
    strategy.entry("SHORT", false, when = crossunder(sma(close,MA1),sma(close,MAL2)) )
    strategy.close("SHORT", when = crossover(sma(close,MA1),sma(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Don't Include" and MAs1 == "SMA" and MAs2 == "EMA"
    strategy.entry("SHORT", false, when = crossunder(sma(close,MA1),ema(close,MAL2)) )
    strategy.close("SHORT", when = crossover(sma(close,MA1),ema(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Don't Include" and MAs1 == "SMA" and MAs2 == "VWMA"
    strategy.entry("SHORT", false, when = crossunder(sma(close,MA1),vwma(close,MAL2)) )
    strategy.close("SHORT", when = crossover(sma(close,MA1),vwma(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Don't Include" and MAs1 == "SMA" and MAs2 == "WMA"
    strategy.entry("SHORT", false, when = crossunder(sma(close,MA1),wma(close,MAL2)) )
    strategy.close("SHORT", when = crossover(sma(close,MA1),wma(close,MAL2)))    
  
    
///--///    

if LongShort =="Short Only" and AboveBelow == "Don't Include" and MAs1 == "EMA" and MAs2 == "SMA"
    strategy.entry("SHORT", false, when = crossunder(ema(close,MA1),sma(close,MAL2)) )
    strategy.close("SHORT", when = crossover(ema(close,MA1),sma(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Don't Include" and MAs1 == "EMA" and MAs2 == "EMA"
    strategy.entry("SHORT", false, when = crossunder(ema(close,MA1),ema(close,MAL2)) )
    strategy.close("SHORT", when = crossover(ema(close,MA1),ema(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Don't Include" and MAs1 == "EMA" and MAs2 == "VWMA"
    strategy.entry("SHORT", false, when = crossunder(ema(close,MA1),vwma(close,MAL2)) )
    strategy.close("SHORT", when = crossover(ema(close,MA1),vwma(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Don't Include" and MAs1 == "EMA" and MAs2 == "WMA"
    strategy.entry("SHORT", false, when = crossunder(ema(close,MA1),wma(close,MAL2)) )
    strategy.close("SHORT", when = crossover(ema(close,MA1),wma(close,MAL2)))
  
    
///--///     
    
if LongShort =="Short Only" and AboveBelow == "Don't Include" and MAs1 == "VWMA" and MAs2 == "VWMA"
    strategy.entry("SHORT", false, when = crossunder(vwma(close,MA1),vwma(close,MAL2)) )
    strategy.close("SHORT", when = crossover(vwma(close,MA1),vwma(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Don't Include" and MAs1 == "VWMA" and MAs2 == "SMA"
    strategy.entry("SHORT", false, when = crossunder(vwma(close,MA1),sma(close,MAL2)) )
    strategy.close("SHORT", when = crossover(vwma(close,MA1),sma(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Don't Include" and MAs1 == "VWMA" and MAs2 == "EMA"
    strategy.entry("SHORT", false, when = crossunder(vwma(close,MA1),ema(close,MAL2)) )
    strategy.close("SHORT", when = crossover(vwma(close,MA1),ema(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Don't Include" and MAs1 == "VWMA" and MAs2 == "WMA"
    strategy.entry("SHORT", false, when = crossunder(vwma(close,MA1),wma(close,MAL2)) )
    strategy.close("SHORT", when = crossover(vwma(close,MA1),wma(close,MAL2))) 
   
    
///--///     
    
if LongShort =="Short Only" and AboveBelow == "Don't Include" and MAs1 == "WMA" and MAs2 == "WMA"
    strategy.entry("SHORT", false, when = crossunder(wma(close,MA1),wma(close,MAL2)) )
    strategy.close("SHORT", when = crossover(wma(close,MA1),wma(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Don't Include" and MAs1 == "WMA" and MAs2 == "SMA"
    strategy.entry("SHORT", false, when = crossunder(wma(close,MA1),sma(close,MAL2)) )
    strategy.close("SHORT", when = crossover(wma(close,MA1),sma(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Don't Include" and MAs1 == "WMA" and MAs2 == "EMA"
    strategy.entry("SHORT", false, when = crossunder(wma(close,MA1),ema(close,MAL2)) )
    strategy.close("SHORT", when = crossover(wma(close,MA1),ema(close,MAL2)))
    
if LongShort =="Short Only" and AboveBelow == "Don't Include" and MAs1 == "WMA" and MAs2 == "VWMA"
    strategy.entry("SHORT", false, when = crossunder(wma(close,MA1),vwma(close,MAL2)) )
    strategy.close("SHORT", when = crossover(wma(close,MA1),vwma(close,MAL2)))  

    
////////////////////////
/////// BOTH ///////////
////////////////////////

//ABOVE

if LongShort =="Both" and AboveBelow == "Above" and MAs1 == "SMA" and MAs2 == "SMA"
    strategy.entry("LONG", true, when = crossover(sma(close,MA1),sma(close,MAL2)) and close>sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(sma(close,MA1),sma(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Above" and MAs1 == "SMA" and MAs2 == "EMA"
    strategy.entry("LONG", true, when = crossover(sma(close,MA1),ema(close,MAL2)) and close>sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(sma(close,MA1),ema(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Above" and MAs1 == "SMA" and MAs2 == "VWMA"
    strategy.entry("LONG", true, when = crossover(sma(close,MA1),vwma(close,MAL2)) and close>sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(sma(close,MA1),vwma(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Above" and MAs1 == "SMA" and MAs2 == "WMA"
    strategy.entry("LONG", true, when = crossover(sma(close,MA1),wma(close,MAL2)) and close>sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(sma(close,MA1),wma(close,MAL2)))    
    
///--///    

if LongShort =="Both" and AboveBelow == "Above" and MAs1 == "EMA" and MAs2 == "SMA"
    strategy.entry("LONG", true, when = crossover(ema(close,MA1),sma(close,MAL2)) and close>sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(ema(close,MA1),sma(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Above" and MAs1 == "EMA" and MAs2 == "EMA"
    strategy.entry("LONG", true, when = crossover(ema(close,MA1),ema(close,MAL2)) and close>sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(ema(close,MA1),ema(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Above" and MAs1 == "EMA" and MAs2 == "VWMA"
    strategy.entry("LONG", true, when = crossover(ema(close,MA1),vwma(close,MAL2)) and close>sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(ema(close,MA1),vwma(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Above" and MAs1 == "EMA" and MAs2 == "WMA"
    strategy.entry("LONG", true, when = crossover(ema(close,MA1),wma(close,MAL2)) and close>sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(ema(close,MA1),wma(close,MAL2)))
    
///--///     
    
if LongShort =="Both" and AboveBelow == "Above" and MAs1 == "VWMA" and MAs2 == "VWMA"
    strategy.entry("LONG", true, when = crossover(vwma(close,MA1),vwma(close,MAL2)) and close>sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(vwma(close,MA1),vwma(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Above" and MAs1 == "VWMA" and MAs2 == "SMA"
    strategy.entry("LONG", true, when = crossover(vwma(close,MA1),sma(close,MAL2)) and close>sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(vwma(close,MA1),sma(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Above" and MAs1 == "VWMA" and MAs2 == "EMA"
    strategy.entry("LONG", true, when = crossover(vwma(close,MA1),ema(close,MAL2)) and close>sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(vwma(close,MA1),ema(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Above" and MAs1 == "VWMA" and MAs2 == "WMA"
    strategy.entry("LONG", true, when = crossover(vwma(close,MA1),wma(close,MAL2)) and close>sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(vwma(close,MA1),wma(close,MAL2))) 
    
///--///     
    
if LongShort =="Both" and AboveBelow == "Above" and MAs1 == "WMA" and MAs2 == "WMA"
    strategy.entry("LONG", true, when = crossover(wma(close,MA1),wma(close,MAL2)) and close>sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(wma(close,MA1),wma(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Above" and MAs1 == "WMA" and MAs2 == "SMA"
    strategy.entry("LONG", true, when = crossover(wma(close,MA1),sma(close,MAL2)) and close>sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(wma(close,MA1),sma(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Above" and MAs1 == "WMA" and MAs2 == "EMA"
    strategy.entry("LONG", true, when = crossover(wma(close,MA1),ema(close,MAL2)) and close>sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(wma(close,MA1),ema(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Above" and MAs1 == "WMA" and MAs2 == "VWMA"
    strategy.entry("LONG", true, when = crossover(wma(close,MA1),vwma(close,MAL2)) and close>sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(wma(close,MA1),vwma(close,MAL2)))  
    
// BELOW

if LongShort =="Both" and AboveBelow == "Below" and MAs1 == "SMA" and MAs2 == "SMA"
    strategy.entry("LONG", true, when = crossover(sma(close,MA1),sma(close,MAL2)) and close<sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(sma(close,MA1),sma(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Below" and MAs1 == "SMA" and MAs2 == "EMA"
    strategy.entry("LONG", true, when = crossover(sma(close,MA1),ema(close,MAL2)) and close<sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(sma(close,MA1),ema(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Below" and MAs1 == "SMA" and MAs2 == "VWMA"
    strategy.entry("LONG", true, when = crossover(sma(close,MA1),vwma(close,MAL2)) and close<sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(sma(close,MA1),vwma(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Below" and MAs1 == "SMA" and MAs2 == "WMA"
    strategy.entry("LONG", true, when = crossover(sma(close,MA1),wma(close,MAL2)) and close<sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(sma(close,MA1),wma(close,MAL2)))    
    
///--///    

if LongShort =="Both" and AboveBelow == "Below" and MAs1 == "EMA" and MAs2 == "SMA"
    strategy.entry("LONG", true, when = crossover(ema(close,MA1),sma(close,MAL2)) and close<sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(ema(close,MA1),sma(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Below" and MAs1 == "EMA" and MAs2 == "EMA"
    strategy.entry("LONG", true, when = crossover(ema(close,MA1),ema(close,MAL2)) and close<sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(ema(close,MA1),ema(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Below" and MAs1 == "EMA" and MAs2 == "VWMA"
    strategy.entry("LONG", true, when = crossover(ema(close,MA1),vwma(close,MAL2)) and close<sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(ema(close,MA1),vwma(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Below" and MAs1 == "EMA" and MAs2 == "WMA"
    strategy.entry("LONG", true, when = crossover(ema(close,MA1),wma(close,MAL2)) and close<sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(ema(close,MA1),wma(close,MAL2)))
    
    
///--///     
    
if LongShort =="Both" and AboveBelow == "Below" and MAs1 == "VWMA" and MAs2 == "VWMA"
    strategy.entry("LONG", true, when = crossover(vwma(close,MA1),vwma(close,MAL2)) and close<sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(vwma(close,MA1),vwma(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Below" and MAs1 == "VWMA" and MAs2 == "SMA"
    strategy.entry("LONG", true, when = crossover(vwma(close,MA1),sma(close,MAL2)) and close<sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(vwma(close,MA1),sma(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Below" and MAs1 == "VWMA" and MAs2 == "EMA"
    strategy.entry("LONG", true, when = crossover(vwma(close,MA1),ema(close,MAL2)) and close<sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(vwma(close,MA1),ema(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Below" and MAs1 == "VWMA" and MAs2 == "WMA"
    strategy.entry("LONG", true, when = crossover(vwma(close,MA1),wma(close,MAL2)) and close<sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(vwma(close,MA1),wma(close,MAL2))) 
   
    
///--///     
    
if LongShort =="Both" and AboveBelow == "Below" and MAs1 == "WMA" and MAs2 == "WMA"
    strategy.entry("LONG", true, when = crossover(wma(close,MA1),wma(close,MAL2)) and close<sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(wma(close,MA1),wma(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Below" and MAs1 == "WMA" and MAs2 == "SMA"
    strategy.entry("LONG", true, when = crossover(wma(close,MA1),sma(close,MAL2)) and close<sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(wma(close,MA1),sma(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Below" and MAs1 == "WMA" and MAs2 == "EMA"
    strategy.entry("LONG", true, when = crossover(wma(close,MA1),ema(close,MAL2)) and close<sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(wma(close,MA1),ema(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Below" and MAs1 == "WMA" and MAs2 == "VWMA"
    strategy.entry("LONG", true, when = crossover(wma(close,MA1),vwma(close,MAL2)) and close<sma(close,TLen))
    strategy.entry("SHORT", false, when = crossunder(wma(close,MA1),vwma(close,MAL2)))  
    
    
// DONT INCLUDE

if LongShort =="Both" and AboveBelow == "Don't Include" and MAs1 == "SMA" and MAs2 == "SMA"
    strategy.entry("LONG", true, when = crossover(sma(close,MA1),sma(close,MAL2)) )
    strategy.entry("SHORT", false, when = crossunder(sma(close,MA1),sma(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Don't Include" and MAs1 == "SMA" and MAs2 == "EMA"
    strategy.entry("LONG", true, when = crossover(sma(close,MA1),ema(close,MAL2)) )
    strategy.entry("SHORT", false, when = crossunder(sma(close,MA1),ema(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Don't Include" and MAs1 == "SMA" and MAs2 == "VWMA"
    strategy.entry("LONG", true, when = crossover(sma(close,MA1),vwma(close,MAL2)) )
    strategy.entry("SHORT", false, when = crossunder(sma(close,MA1),vwma(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Don't Include" and MAs1 == "SMA" and MAs2 == "WMA"
    strategy.entry("LONG", true, when = crossover(sma(close,MA1),wma(close,MAL2)) )
    strategy.entry("SHORT", false, when = crossunder(sma(close,MA1),wma(close,MAL2)))    
 
    
///--///    

if LongShort =="Both" and AboveBelow == "Don't Include" and MAs1 == "EMA" and MAs2 == "SMA"
    strategy.entry("LONG", true, when = crossover(ema(close,MA1),sma(close,MAL2)) )
    strategy.entry("SHORT", false, when = crossunder(ema(close,MA1),sma(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Don't Include" and MAs1 == "EMA" and MAs2 == "EMA"
    strategy.entry("LONG", true, when = crossover(ema(close,MA1),ema(close,MAL2)) )
    strategy.entry("SHORT", false, when = crossunder(ema(close,MA1),ema(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Don't Include" and MAs1 == "EMA" and MAs2 == "VWMA"
    strategy.entry("LONG", true, when = crossover(ema(close,MA1),vwma(close,MAL2)) )
    strategy.entry("SHORT", false, when = crossunder(ema(close,MA1),vwma(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Don't Include" and MAs1 == "EMA" and MAs2 == "WMA"
    strategy.entry("LONG", true, when = crossover(ema(close,MA1),wma(close,MAL2)) )
    strategy.entry("SHORT", false, when = crossunder(ema(close,MA1),wma(close,MAL2)))
    
///--///     
    
if LongShort =="Both" and AboveBelow == "Don't Include" and MAs1 == "VWMA" and MAs2 == "VWMA"
    strategy.entry("LONG", true, when = crossover(vwma(close,MA1),vwma(close,MAL2)) )
    strategy.entry("SHORT", false, when = crossunder(vwma(close,MA1),vwma(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Don't Include" and MAs1 == "VWMA" and MAs2 == "SMA"
    strategy.entry("LONG", true, when = crossover(vwma(close,MA1),sma(close,MAL2)) )
    strategy.entry("SHORT", false, when = crossunder(vwma(close,MA1),sma(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Don't Include" and MAs1 == "VWMA" and MAs2 == "EMA"
    strategy.entry("LONG", true, when = crossover(vwma(close,MA1),ema(close,MAL2)) )
    strategy.entry("SHORT", false, when = crossunder(vwma(close,MA1),ema(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Don't Include" and MAs1 == "VWMA" and MAs2 == "WMA"
    strategy.entry("LONG", true, when = crossover(vwma(close,MA1),wma(close,MAL2)) )
    strategy.entry("SHORT", false, when = crossunder(vwma(close,MA1),wma(close,MAL2))) 
    
///--///     
    
if LongShort =="Both" and AboveBelow == "Don't Include" and MAs1 == "WMA" and MAs2 == "WMA"
    strategy.entry("LONG", true, when = crossover(wma(close,MA1),wma(close,MAL2)) )
    strategy.entry("SHORT", false, when = crossunder(wma(close,MA1),wma(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Don't Include" and MAs1 == "WMA" and MAs2 == "SMA"
    strategy.entry("LONG", true, when = crossover(wma(close,MA1),sma(close,MAL2)) )
    strategy.entry("SHORT", false, when = crossunder(wma(close,MA1),sma(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Don't Include" and MAs1 == "WMA" and MAs2 == "EMA"
    strategy.entry("LONG", true, when = crossover(wma(close,MA1),ema(close,MAL2)) )
    strategy.entry("SHORT", false, when = crossunder(wma(close,MA1),ema(close,MAL2)))
    
if LongShort =="Both" and AboveBelow == "Don't Include" and MAs1 == "WMA" and MAs2 == "VWMA"
    strategy.entry("LONG", true, when = crossover(wma(close,MA1),vwma(close,MAL2)) )
    strategy.entry("SHORT", false, when = crossunder(wma(close,MA1),vwma(close,MAL2))) 

Plus de