strategy("Working", overlay=true,pyramiding=20,slippage=5, commission_type=strategy.commission.cash_per_contract, commission_value=0.89, initial_capital=1000, currency=currency.USD) //comm_value = 25000/28089 //int_capital = 0.08*open //Select the years to analyze fromYear = year > 2000 toYear = year < 2020 //fromYear = year==2019 //toYear = month>=1 and month<=4 //Max multiplier strategy.risk.max_position_size(1000) //LOST THE PLOT! plot(strategy.equity) data = strategy.losstrades-strategy.losstrades[1] == 0 and fromYear and toYear plotshape(data, style=shape.triangleup,location=location.abovebar, color=green) profit = strategy.netprofit-strategy.netprofit[1] plot(profit) //Is it the next bar in the series test = barstate.isconfirmed == true //SET the SL and TP cash = 10000.0 SL = 0.0012*open //What is the gain factor multiplier qty = 1 upweek = change(strategy.equity) barsinceup = barssince(upweek>0) losingbars = change(strategy.losstrades)==1 //111111111111111111111111111111111111111111111111111111111111111 if fromYear and toYear and qty ==1 strategy.entry("B1", strategy.long,qty) strategy.close("B1", when = test == true) //*22222222222222222222222222222222222222222222222222222222222 if losingbars ==true and qty[1]==1 and fromYear and toYear qty := 2 //cash := abs(strategy.equity-strategy.equity[1])*5 //cash := (open[0]-close)*5.0 strategy.entry("B1", strategy.long,qty) strategy.close("B1", when = test == true) //333333333333333333333333333333333333333333333333333333333333 if losingbars ==true and qty[1]==2 and fromYear and toYear qty := 3 cash := abs(strategy.equity-strategy.equity[2])*8.0 strategy.entry("B1", strategy.long,qty) strategy.close("B1", when = test == true) //444444444444444444444444444444444444444444444444444444444444 if losingbars ==true and qty[1]==3 and fromYear and toYear qty := 4 cash := abs(strategy.equity-strategy.equity[3])*8 strategy.entry("B1", strategy.long,qty) strategy.close("B1", when = test == true) //5555555555555555555555555555555555555555555555555555555555555 if losingbars ==true and qty[1]==4 and fromYear and toYear qty := 5 //cash := abs(strategy.equity-strategy.equity[4])*8 strategy.entry("B1", strategy.long,qty) strategy.close("B1", when = test == true) //6666666666666666666666666666666666666666666666666666666666666 if losingbars ==true and qty[1]==5 and fromYear and toYear qty := 6 //cash := abs(strategy.equity-strategy.equity[5])*1.3 strategy.entry("B1", strategy.long,qty) strategy.close("B1", when = test == true) //77777777777777777777777777777777777777777777777777777777777777 if losingbars ==true and qty[1]==6 and fromYear and toYear qty := 7 cash := abs(strategy.equity-strategy.equity[6])*2 strategy.entry("B1", strategy.long,qty) strategy.close("B1", when = test == true) //88888888888888888888888888888888888888888888888888888888888888 if losingbars ==true and qty[1]==7 and fromYear and toYear qty := 8 cash := abs(strategy.equity-strategy.equity[7])*2 strategy.entry("B1", strategy.long,qty) strategy.close("B1", when = test == true) //**************TAKE PROFIT and STOP LOSS******************** strategy.exit("SL", "B1", profit = cash, loss = SL)