Simple EMA Crossing Strategy TradeMath
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TheHulkTrading

// Simple EMA strategy for BTCUSDT, timeframe - 1H. Based on crossing EMA21 and EMA55


//@version=4
strategy("Simple EMA Crossing Strategy ", overlay=true)

//Percent for stop loss, recommended = 3%
percent_loss = input(3, minval=1, title="Stop Loss") 

//Ema's
emaFast=ema(close,21)
emaSlow=ema(close,55)

//Long Contition is crossover ema21 and ema55
longCond = crossover(emaFast,emaSlow) 

//Stop level based on input percent_loss, default = 3%
stop_level_long = strategy.position_avg_price*((100-percent_loss)/100)
//Take profit - x3 of percent loss, default = 9%
take_level_long = strategy.position_avg_price*((100+percent_loss*3)/100)

//Entries and exits 
strategy.entry("Long", strategy.long, when=longCond)
strategy.exit("Stop Loss/TP","Long", stop=stop_level_long, limit = take_level_long)


