Hi, All,
I like to create Trading robot / Algo who can place automatic order as per script with stop loss , Booking Profit for multiple instruments with risk management. Script is mention below.
//@version=2
//Supertrend Strategy by breizh29 using *rajandran.r* Supertrend Indicator
strategy("Super Trend 2", overlay=true, default_qty_value=100)
res = input(title="Main SuperTrend Time Frame", type=resolution, defval="120")
Factor=input(1, minval=1,maxval = 100)
Pd=input(1, minval=1,maxval = 100)
tp = input(500,title="Take Profit")
sl = input(400,title="Stop Loss")
Up=hl2-(Factor*atr(Pd))
Dn=hl2+(Factor*atr(Pd))
MUp=security(tickerid,res,hl2- (Factor*atr(Pd)))
MDn=security(tickerid,res,hl2+ (Factor*atr(Pd)))
Mclose=security(tickerid,res, close)
TrendUp=close[1]>TrendUp[1]? max(Up,TrendUp[1]) : Up
TrendDown=close[1]<TrendDown[ 1]? min(Dn,TrendDown[1]) : Dn
MTrendUp=Mclose[1]>MTrendUp[1] ? max(MUp,MTrendUp[1]) : MUp
MTrendDown=Mclose[1]< MTrendDown[1]? min(MDn,MTrendDown[1]) : MDn
Trend = close > TrendDown[1] ? 1: close< TrendUp[1]? -1: nz(Trend[1],1)
Tsl = Trend==1? TrendUp: TrendDown
MTrend = Mclose > MTrendDown[1] ? 1: Mclose< MTrendUp[1]? -1: nz(MTrend[1],1)
MTsl = MTrend==1? MTrendUp: MTrendDown
linecolor = Trend == 1 ? green : red
plot(Tsl, color = linecolor , style = line , linewidth = 2,title = "SuperTrend")
Mlinecolor = MTrend == 1 ? blue : orange
plot(MTsl, color = Mlinecolor , style = line , linewidth = 2,title = "Main SuperTrend")
plotshape(cross(close,Tsl) and close>Tsl , "Up Arrow", [login to view URL],location. belowbar,green,0,0)
plotshape(cross(Tsl,close) and close<Tsl , "Down Arrow", [login to view URL] , [login to view URL], red,0,0)
up = Trend == 1 and Trend[1] == -1 and MTrend == 1
down = Trend == -1 and Trend[1] == 1 and MTrend == -1
plotarrow(up ? Trend : na, title="Up Entry Arrow", colorup=lime, maxheight=60, minheight=50, transp=0)
plotarrow(down ? Trend : na, title="Down Entry Arrow", colordown=red, maxheight=60, minheight=50, transp=0)
golong = Trend == 1 and Trend[1] == -1 and MTrend == 1
goshort = Trend == -1 and Trend[1] == 1 and MTrend == -1
[login to view URL]("Buy", [login to view URL],when=golong)
[login to view URL]("Close Buy","Buy",profit=tp,loss=sl)
[login to view URL]("Sell", [login to view URL],when=goshort)
[login to view URL]("Close Sell","Sell",profit=tp,loss= sl)
-------------------------------------------------------------------------------------------------------------------------------
it should look as below.
Instruments : Forex, Indices, Commodity
Deal Amount: £1,2,3...... (Will be calculated with Total Amount invested and 1%,2%... Risk management)
Open Position: AS per Script
Stop Loss: Previous Hours Low
Profit: AS per Script (Trend Changes from Either Buy / sell direction)
Button: START | END
Above mention format for Trading Robot to start when i put desired Currencies pairs, Indices and Gold & Oil ...
Then it should calculated desired deal amount to place as per account balance and risk management calculated as per total balance.
Basically i am looking for it so i can able to trade multiple instruemts as same time.
Hope it will clear as per me.
Looking Forward.
Thanks & Regards
Prashant Patel