Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Bot Utente QTA VIX-Mean-Reversion-RSI-BB-ATR-4H
- Inputs:
- BB_Length(40),
- BB_NumDevsUp(2),
- BB_NumDevsDn(-2),
- RSI_Length(5),
- RSI_Threshold(30),
- RSI_ThresholdShort(70),
- AtrMult_TP(4.5),
- AtrMult_SL(6),
- AtrMult_TP_Short(6),
- AtrMult_SL_Short(1.5),
- ATRLength(7),
- AllowLong(true),
- AllowShortSelling(False);
- variables:
- var0( 0 ),
- var1( 0 ),
- var2( 0 ),
- var3( 0 ),
- RSI_Value(0),
- con1(0),
- ATR(0),
- Limit_price(0),
- Stop_price(0),
- con2(0),
- TP_Short(0),
- SL_Short(0);
- var0 = Average( Close, BB_Length ) ;
- var1 = StandardDev( Close, BB_Length, 1 ) ;
- var3 = var0 + BB_NumDevsUp * var1 ; // Upper Band
- var2 = var0 + BB_NumDevsDn * var1 ; // Lower Band
- Value1 = BarsSinceEntry(0);
- //---------------------------------------------------------------------------------------------------------------------------------------------------------------------
- RSI_Value = RSI( Close, RSI_Length ) ;
- ATR = AvgTrueRange( ATRLength ) ;
- if AllowLong then begin
- if close crosses below var2 and RSI_Value < RSI_Threshold then
- con1 = 1 ;
- //-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
- if con1 = 1 and Marketposition= 0 then begin
- Buy next bar at market;
- end;
- Limit_price = High[Value1] + (AtrMult_TP * ATR);
- Stop_price = Low[Value1] - (AtrMult_SL * ATR);
- sell ("TP") next bar at limit_price limit;
- sell ("SL") next bar at stop_price stop;
- con1 = 0;
- End;
- //------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- //Short Side
- if AllowShortSelling then begin
- if Close crosses above var3 and RSI_Value >= RSI_ThresholdShort then begin
- con2 = 1;
- end;
- if con2 = 1 and Marketposition = 0 then begin
- SellShort("Short") next bar at market;
- end;
- TP_Short = Low[Value1] - (AtrMult_TP_Short * ATR);
- SL_Short = High[Value1] + (AtrMult_SL_Short * ATR);
- BuyToCover("SL Short") next bar at SL_Short stop;
- BuyToCover("TP Short") next bar at TP_Short limit;
- con2 = 0;
- end;
Advertisement
Comments
-
- i got all types of premium tradingview indicators codes available on telegram - https://t.me/tradingview_premium_indicator
Add Comment
Please, Sign In to add comment
Advertisement