//@version=5 strategy("ajterow",overlay = true,process_orders_on_close = true,max_lines_count = 500) h = input.int(9 , "Hour" , minval=0, maxval=23, inline='hm',group="Select Time for Signal") m = input.int(00, ": Min", minval=0, maxval=59, inline='hm',group="Select Time for Signal") // time when trade will close h3 = input.int(17 , "Hour" , minval=0, maxval=23, inline='hm3',group="Select Time for Close Trade") m3 = input.int(30, ": Min", minval=0, maxval=59, inline='hm3',group="Select Time for Close Trade") //select Gmt time gmt=input.string("Europe/Berlin",title="Gmt",options=["America/New_York","America/Los_Angeles","America/Chicago","America/Phoenix","America/Toronto" ,"America/Vancouver","America/Argentina/Buenos_Aires","America/El_Salvador","America/Sao_Paulo","America/Bogota" ,"Europe/Moscow" ,"Europe/Athens" ,"Europe/Berlin","Europe/London" ,"Europe/Madrid" ,"Europe/Paris" ,"Europe/Warsaw", "Australia/Sydney","Australia/Brisbane","Australia/Adelaide","Australia/ACT" ,"Asia/Almaty" ,"Asia/Ashkhabad" ,"Asia/Tokyo" ,"Asia/Taipei" ,"Asia/Singapore" ,"Asia/Shanghai" ,"Asia/Seoul" ,"Asia/Tehran" ,"Asia/Dubai" ,"Asia/Kolkata" ,"Asia/Hong_Kong" ,"Asia/Bangkok" ,"Pacific/Auckland","Pacific/Chatham","Pacific/Fakaofo" ,"Pacific/Honolulu" ],group="Select Time for Signal",inline="hm") select_gmt=gmt=="America/New_York"? "GMT-4:00":gmt=="America/Los_Angeles"? "GMT-7:00":gmt=="America/Chicago"? "GMT-5:00":gmt=="America/Phoenix"?"GMT-7:00": gmt=="America/Toronto"?"GMT-4:00":gmt=="America/Vancouver"?"GMT-7:00": gmt=="America/Argentina/Buenos_Aires"?"GMT-3:00": gmt=="America/El_Salvador" ?"GMT-6:00": gmt=="America/Sao_Paulo"?"GMT-3:00": gmt=="America/Bogota"?"GMT-5:00":gmt=="Europe/Moscow"?"GMT+3:00": gmt=="Europe/Athens"?"GMT+3:00": gmt=="Europe/Berlin" ?"GMT+2:00": gmt=="Europe/London"?"GMT+1:00": gmt=="Europe/Madrid"?"GMT+2:00": gmt=="Europe/Paris"?"GMT+2:00":gmt=="Europe/Warsaw"?"GMT+2:00": gmt=="Australia/Sydney"?"GMT+11:00":gmt=="Australia/Brisbane"?"GMT+10:00":gmt=="Australia/Adelaide"?"GMT+10:30":gmt=="Australia/ACT"?"GMT+9:30": gmt=="Asia/Almaty"?"GMT+6:00":gmt=="Asia/Ashkhabad"?"GMT+5:00":gmt=="Asia/Tokyo"?"GMT+9:00":gmt=="Asia/Taipei"?"GMT+8:00":gmt=="Asia/Singapore"?"GMT+8:00": gmt=="Asia/Shanghai"?"GMT+8:00":gmt=="Asia/Seoul"?"GMT+9:00":gmt=="Asia/Tehran" ?"GMT+3:30":gmt=="Asia/Dubai" ?"GMT+4:00":gmt=="Asia/Kolkata"?"GMT+5:30": gmt=="Asia/Hong_Kong"?"GMT+8:00":gmt=="Asia/Bangkok"?"GMT+7:00":gmt=="Pacific/Auckland"?"GMT+13:00":gmt=="Pacific/Chatham"?"GMT+13:45":gmt=="Pacific/Fakaofo" ?"GMT+13:00": gmt=="Pacific/Honolulu"?"GMT-10:00": na ch_signal=input.string('close',title = "Choose type of signal",options = ['close','High/low','both'],group = "Choose Signal") raid_in=input.float(2.0,step=0.10,title = "Buffer Zone ",group = "Buffer Input") ///martingle input //////////// os = input.float(1.0, 'Order Size', step=0.1,group="Order Size Settings",tooltip ="Order Size For 1st Trade") mf = input.float(2.0, 'Order Size Multiplier', step=0.1,group="Order Size Settings",tooltip ="Order Size Reverse Position Order size Previous Order* Multiplier") //Considering Nifty as the Index var s_high = 0.0 var s_low = 0.0 var Ep =0.0 var sl_bh =0.0 var sl_lh =0.0 if (hour(time,select_gmt) ==h and minute(time,select_gmt) == m) and syminfo.type != "forex" s_high :=high+raid_in s_low :=low-raid_in sl_bh :=high sl_lh :=low if (hour(time,select_gmt) ==h and minute(time,select_gmt) == m) and syminfo.type == "forex" s_high :=high+(raid_in*syminfo.mintick) s_low :=low-(raid_in*syminfo.mintick) sl_bh :=high sl_lh :=low var buy_cond =false var sell_cond=false b_cond=ch_signal=='close'?ta.crossover(close,s_high):ch_signal=='High/low'? ta.crossover(high,s_high):ch_signal=='both'?ta.crossover(close,s_high) or ta.crossover(high,s_high):na s_cond=ch_signal=='close'?ta.crossunder(close,s_low):ch_signal=='High/low'? ta.crossunder(low,s_low):ch_signal=='both'? ta.crossunder(close,s_low) or ta.crossunder(low,s_low):na if b_cond buy_cond:=true if s_cond sell_cond:=true var buy_sig =false var sell_sig=false var count_trade =0 if buy_cond and not buy_cond[1] and sell_cond==false strategy.entry('El',strategy.long,comment = "Long",alert_message="Long Trade" , qty=os) Ep:=close buy_sig:=true count_trade:=0 if sell_cond and not sell_cond[1] and buy_cond==false strategy.entry('Es',strategy.short,comment ="Short",alert_message="Long Trade", qty=os) Ep:=close sell_sig:=true count_trade:=0 var line l1=na var line l2=na lin_clr =input.color(color.white,title = "Line Color",group = "Line Color Settings") if (hour(time,select_gmt) ==h and minute(time,select_gmt) == m) l1 := line.new(bar_index, s_high, bar_index+1,s_high, color=lin_clr, style=line.style_solid, width=2) if (hour(time,select_gmt) ==h and minute(time,select_gmt) == m) l2 := line.new(bar_index, s_low, bar_index+1,s_low, color=lin_clr, style=line.style_solid, width=2) // sl type en_sl =input.bool(true ,"" ,group = "Stop Loss",inline = "lx") sl_type=input.string("High/Low",title="Choose Type of Sl",options = ["Point","Pip","High/Low"],group = "Stop Loss",inline = "lx") sl_point=input.float(40.0,title = "Sl Point",group = "Stop Loss & Take Profit Settings") en_tp =input.bool(true,title = "Enable TP",group = "Stop Loss & Take Profit Settings") tp_point=input.float(40.0,title = "Tp Point",group = "Stop Loss & Take Profit Settings") // closing time of signal // time when trade will close if (hour(time,select_gmt) ==h3 and minute(time,select_gmt) == m3) strategy.close_all('Close Trade') // stop loss GetPipSize() => syminfo.mintick * (syminfo.type == "forex" ? 10 : 1) // checking last trade is long or short is_pos_closed = (strategy.position_size[1] != 0 and strategy.position_size == 0) or ((strategy.position_size[1] * strategy.position_size) < 0) is_long = strategy.position_size > 0 is_short = strategy.position_size < 0 ptrade_islong=is_pos_closed and is_long[1] ptrade_isshort=is_pos_closed and is_short[1] // checking is last trade is profit var lastTradeWasprofit = false if (strategy.wintrades[0] > strategy.wintrades[1]) // last trade was a profit lastTradeWasprofit := true if (strategy.losstrades[0] > strategy.losstrades[1]) // unsuccessful trade, reset lastTradeWasprofit := false var get_size =0.0 var ep2 =0.0 var get_sizes=0.0 var eps =0.0 // reverse poisition open rever_pos =input.bool(false,title = "Reverse Poisition",group = "Reverse Position Settings") buy_sl = sl_type=="Point"?Ep-sl_point:sl_type=="Pip"?Ep-(sl_point*GetPipSize()):sl_type=="High/Low"?sl_lh:na sell_sl= sl_type=="Point"?Ep+sl_point:sl_type=="Pip"?Ep+(sl_point*GetPipSize()):sl_type=="High/Low"?sl_bh:na if (not lastTradeWasprofit) and ptrade_islong and rever_pos and ta.crossunder(low,sl_lh) and count_trade==0 get_size:=math.abs(high-low) ep2 :=close strategy.entry("Es2",strategy.short,comment ="short", qty=os*mf) count_trade:=count_trade+1 if (not lastTradeWasprofit) and ptrade_isshort and rever_pos and ta.crossover(high,sl_bh) and count_trade==0 get_sizes:=math.abs(high-low) eps:=close strategy.entry("El2",strategy.long,comment ="long", qty=os*mf) count_trade:=count_trade+1 buy_tp = sl_type=="Point"?Ep+tp_point:sl_type=="Pip"?Ep+(sl_point*GetPipSize()):sl_type=="High/Low"?Ep+tp_point:na sell_tp= sl_type=="Point"?Ep-tp_point:sl_type=="Pip"?Ep-(sl_point*GetPipSize()):sl_type=="High/Low"?Ep-tp_point:na if strategy.position_size>0 and en_sl strategy.exit('XL',from_entry ='El' ,stop = buy_sl) if strategy.position_size<0 and en_sl strategy.exit('Xs',from_entry ='Es' ,stop =sell_sl) if ta.crossover(high,buy_tp) and en_tp strategy.close('El',comment = "Close Long",immediately = true) if ta.crossunder(low,sell_tp) and en_tp strategy.close('Es',comment = "Close short",immediately = true) // tp for entry 2 buy_tp2=sl_bh+math.abs(sl_bh-sl_lh) sell_tp2=sl_lh-math.abs(sl_bh-sl_lh) if strategy.position_size>0 and rever_pos strategy.exit('XL2',from_entry ='El2' ,stop = s_low,limit = buy_tp2) if strategy.position_size<0 and rever_pos strategy.exit('Xs2',from_entry ='Es2' ,stop =s_high,limit = sell_tp2) if ta.crossover(high,buy_tp) or ta.crossunder(low,buy_sl) buy_sig :=false if ta.crossunder(low,sell_tp) or ta.crossover(high,sell_sl) sell_sig:=false //PLOT FIXED SLTP LINE plot(strategy.position_size > 0 and en_sl and buy_sig ? buy_sl : na, style=plot.style_linebr, color=color.new(color.red, 0), linewidth=1, title='Long Fixed SL') plot(strategy.position_size < 0 and en_sl and sell_sig? sell_sl : na, style=plot.style_linebr, color=color.new(color.red, 0), linewidth=1, title='Short Fixed SL') plot(strategy.position_size > 0 and en_sl and buy_sig and en_tp ? buy_tp : na, style=plot.style_linebr, color=color.new(color.red, 0), linewidth=1, title='Long Fixed TP') plot(strategy.position_size < 0 and en_sl and sell_sig and en_tp? sell_tp : na, style=plot.style_linebr, color=color.new(color.red, 0), linewidth=1, title='Short Fixed Tp') plot(strategy.position_size > 0 and rever_pos and not buy_sig? buy_tp2 : na, style=plot.style_linebr, color=color.new(color.aqua, 0), linewidth=1 ,title='Long Fixed TP2') plot(strategy.position_size < 0 and rever_pos and not sell_sig? sell_tp2 : na, style=plot.style_linebr, color=color.new(color.aqua, 0), linewidth=1,title='Short Fixed TP2') plot(strategy.position_size > 0 and rever_pos and not buy_sig ? buy_sl : na, style=plot.style_linebr, color=color.new(color.red, 0), linewidth=1 ,title='Long Fixed SL2') plot(strategy.position_size < 0 and rever_pos and not sell_sig? sell_sl : na, style=plot.style_linebr, color=color.new(color.red, 0), linewidth=1 ,title='Short Fixed SL2') //revese candle close if (hour(time,select_gmt) ==h and minute(time,select_gmt) == m) buy_cond:=false sell_cond:=false