Advertisement
Maurizio-Ciullo

Bot Scalping-Bot ETH/PERP Ver-5 FTX 5M LONG E SHORT

May 10th, 2022
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  2.  
  3. // Il trading system completo - Bot Scalping Bot Ver-5 (Strategia Breakout) Parte 1
  4. // (Exchange= FTX) (Sottostante ETH-PERP) (Timeframe= 5M) (Direzione= LONG E SHORT) (Swing Posizione= NO) (Esclusione Ore=NO) (Esclusione Giorni=NO') (Esclusione Mesi=NO)
  5. // (Take Profit Long/Short Market = NO) (Take Profit Limit Long/Short= +3%) (Stop Loss Limit Long/Short= -3% Tradingview-Hub) (Stop Loss Market Long/Short= NO) (Trailing Stop=NO) (Stop Emergenza= NO)
  6. // (Rischio Operazione 2% Perdita Media)
  7. // (In Sample Dal=01/02/2021 Al 01/10/2021) (Out Of Sample Dal=01/10/2021 Al 28/04/2022)
  8. // (Progettatta Il=25/04/2022)
  9.  
  10. // 'Bot Scalping-Bot Ver-5 ETH/PERP FTX 5M LONG E SHORT'
  11.  
  12. {*****************************************************************************
  13. Description : HeikinAshiSyn - This Paintbar is a Variation of the Heikin Ashi Candlestick to assist in reading the trend.
  14. ******************************************************************************}
  15. // Inputs ///////////////////////////////////////////////////////
  16.  
  17. inputs: UpColor(RGB(0,192,255)),  
  18.         DnColor(RGB(255,128,64)),  
  19.         HiLoColor(DarkGray),
  20.         CompBars(0),
  21.         SmoothHA(False),
  22.         SmoothAvgType(1 {1 JTHull, 2 SMA, 3 EMA, 4 wAverage} ),
  23.         SmoothLength(6),
  24.         ReverseColor(false),
  25.         input_target_long(3),
  26.         input_stop_loss_long(3),
  27.         input_target_short(3),
  28.         input_stop_loss_short(3),
  29.         percent_risk(100),
  30.         InitialCapital(100000),
  31.         input_boombar_3_long(0.44),
  32.         input_boombar_doji_long(0.44),
  33.         input_boombar_3_short(0.34),
  34.         input_boombar_doji_short(0.34),
  35.         input_distanza_long(1.8), // distanza tra la haClose e la slowema
  36.         input_distanza_short(2.4),
  37.         mult_doji_long(0.2),
  38.         mult_doji_short(0.26),
  39.         lunghezza_adx_long(5),
  40.         lunghezza_adx_short(7),
  41.         differenziale_adx_basso_long(25),
  42.         differenziale_adx_alto_long(75),
  43.         differenziale_adx_basso_short(20),
  44.         differenziale_adx_alto_short(80),
  45.         lunghezza_rsi_long(15),
  46.         lunghezza_rsi_short(6),
  47.         differenziale_rsi_long(90),
  48.         differenziale_rsi_short(24),
  49.         solo_short(false),
  50.         solo_long(false),
  51.         {adx_neutrale_diff_input(0),    
  52.         dmi_min_diff_input_long(26.1),  
  53.         dmi_min_diff_input_short(32.6),}
  54.        
  55.  
  56.  
  57. // Start Initializing Heiken Ashi ///////////////////////////////////////////////////////
  58.  
  59.     double FastPrice( Close ) [
  60.         DisplayName = "FastPrice",
  61.         ToolTip = "Enter an EasyLanguage expression to use in calculation of shorter length moving average."],
  62.    
  63.     double SlowPrice( Close ) [
  64.         DisplayName = "SlowPrice",
  65.         ToolTip = "Enter an EasyLanguage expression to use in calculation of longer length moving average."],
  66.    
  67.     double FastLength_long( 52 ) [
  68.         DisplayName = "FastLength",
  69.         ToolTip = "Enter number of bars to use in calculation of shorter length moving average."],
  70.        
  71.     double FastLength_short( 42 ) [
  72.         DisplayName = "FastLength",
  73.         ToolTip = "Enter number of bars to use in calculation of shorter length moving average."],
  74.    
  75.     double SlowLength_long( 82 ) [
  76.         DisplayName = "SlowLength",
  77.         ToolTip = "Enter number of bars to use in calculation of longer length moving average."],
  78.        
  79.     double SlowLength_short( 170 ) [
  80.         DisplayName = "SlowLength",
  81.         ToolTip = "Enter number of bars to use in calculation of longer length moving average."],
  82.    
  83.     int Displace( 0 ) [
  84.         DisplayName = "Displace",
  85.         ToolTip = "Displacement.  Enter the number of bars by which plots will be displaced.  Displacement may be positive (left) or negative (right)."];
  86.  
  87. // End Initializing Heiken Ashi ///////////////////////////////////////////////////////
  88.  
  89.  
  90. // Initializing Variables ///////////////////////////////////////////////////////
  91.  
  92. vars: haClose(0),haOpen(0),haHigh(0),haLow(0),
  93.         color(0), newHi(0), newLo(0),
  94.         iOpen(0), iClose(0), iHi(0), iLo(0),
  95.         double FastEMA_long( 0 ),
  96.         double FastEMA_short( 0 ),
  97.         double SlowEMA_long( 0 ),
  98.         double SlowEMA_short( 0 ),
  99.         stop_loss_long(0),
  100.         stop_loss_short(0),
  101.         take_profit_long(0),
  102.         take_profit_short(0),
  103.         risk(0),
  104.         nr_share(0),
  105.         boombar_3_long(0),
  106.         boombar_doji_long(0),
  107.         boombar_3_short(0),
  108.         boombar_doji_short(0),
  109.         valore_adx_long(0),
  110.         valore_adx_short(0),
  111.         valore_rsi_long(0),
  112.         valore_rsi_short(0),
  113.         distanza_long(0),
  114.         distanza_short(0),
  115.         diffenziale_adx_long(0),
  116.         diffenziale_adx_short(0);
  117.         {di_pos(0),
  118.         di_neg(0),
  119.         adx_neutrale(0);}
  120.        
  121.  
  122. // Start Detecting Heiken Ashi ///////////////////////////////////////////////////////
  123.  
  124. begin;
  125.  if SmoothHA = False then begin;
  126.     iOpen = Open;
  127.     iClose = Close;
  128.     iHi = High;
  129.     iLo = Low;
  130.  end else begin;
  131.     if SmoothAvgType = 1 then begin;
  132.         iOpen = jthma(Open, SmoothLength);
  133.         iClose = jthma(Close, SmoothLength);
  134.         iHi = jthma(High, SmoothLength);
  135.         iLo = jthma(Low, SmoothLength);
  136.     end;   
  137.     if SmoothAvgType = 2 then begin;
  138.         iOpen = average(Open, SmoothLength);
  139.         iClose = average(Close, SmoothLength);
  140.         iHi = average(High, SmoothLength);
  141.         iLo = average(Low, SmoothLength);
  142.     end;   
  143.     if SmoothAvgType = 3 then begin;
  144.         iOpen = xAverage(Open, SmoothLength);
  145.         iClose = xAverage(Close, SmoothLength);
  146.         iHi = xAverage(High, SmoothLength);
  147.         iLo = xAverage(Low, SmoothLength);
  148.     end;   
  149.     if SmoothAvgType = 4 then begin;
  150.         iOpen = wAverage(Open, SmoothLength);
  151.         iClose = wAverage(Close, SmoothLength);
  152.         iHi = wAverage(High, SmoothLength);
  153.         iLo = wAverage(Low, SmoothLength);
  154.     end;   
  155.  end;  
  156.  
  157.  if BarNumber > 1 then begin
  158.     haClose = (iOpen+iHi+iLo+iClose)/4;
  159.     haOpen = (haOpen [1] + haClose [1])/2 ;
  160.     haHigh = MaxList(iHi, haOpen, haClose) ;
  161.     haLow = MinList(iLo, haOpen, haClose) ;
  162.      
  163.     if haClose > haOpen then
  164.         color = UpColor
  165.     else
  166.         color = DnColor;
  167.    
  168.     if CompBars > 0 then begin;
  169.         for value1 = 1 to CompBars begin
  170.             if haOpen <= MaxList(haOpen[value1],haClose[value1]) and
  171.                 haOpen >= MinList(haOpen[value1],haClose[value1]) and
  172.             haClose <= MaxList(haOpen[value1],haClose[value1]) and
  173.             haClose >= MinList(haOpen[value1],haClose[value1]) then
  174.                 color = color[value1];
  175.         end;
  176.     end;
  177.      
  178.     if ReverseColor then begin;
  179.         if color = UpColor then
  180.             color = DnColor
  181.         else
  182.             color = UpColor;
  183.     end;
  184.    
  185.     {Plot1( haOpen,  "Open",  color ) ;    
  186.     Plot2( haClose, "Close", color ) ;    
  187.     Plot3( haHigh,  "High",  HiLoColor ) ;    
  188.     Plot4( haLow,   "Low",   HiLoColor ) ; }
  189.      
  190. end else begin;
  191.  
  192.     haOpen = iOpen;
  193.     haClose = (iOpen+iHi+iLo+iClose)/4;
  194.     haHigh = MaxList( iHi, haOpen, haClose);
  195.     haLow = MinList( iLo, haOpen,haClose);
  196.  
  197. end;
  198.  
  199. // End Detecting Heiken Ashi ///////////////////////////////////////////////////////
  200.  
  201.  
  202. // Calculating Variables ///////////////////////////////////////////////////////
  203.  
  204. FastEMA_long = XAverage( haClose, FastLength_long );
  205. FastEMA_short = XAverage( haClose, FastLength_short );
  206. SlowEMA_long = XAverage( haClose, SlowLength_long );
  207. SlowEMA_short = XAverage( haClose, SlowLength_short );
  208. valore_adx_long = adx(lunghezza_adx_long);
  209. valore_adx_short = adx(lunghezza_adx_short);
  210. valore_rsi_long = rsi(close, lunghezza_rsi_long);
  211. valore_rsi_short = rsi(close, lunghezza_rsi_short);
  212. boombar_3_long = haClose[1] / 100 * input_boombar_3_long;
  213. boombar_3_short = haClose[1] / 100 *input_boombar_3_short;
  214. boombar_doji_long = haClose[1] / 100 * input_boombar_doji_long;
  215. boombar_doji_short = haClose[1] / 100 * input_boombar_doji_short;
  216. distanza_long = SlowEma_long / 100 * input_distanza_long;
  217. distanza_short = SlowEma_short / 100 * input_distanza_short;
  218. {adx_neutrale = adx(14);
  219. diffenziale_adx = adx_neutrale + (adx_neutrale/100*adx_neutrale_diff_input);
  220. di_pos = (dmiPlus(14));
  221. di_neg = (dmiMinus(14));}
  222.  
  223.  
  224. // Money menagment ///////////////////////////////////////////////////////
  225.        
  226.     risk = percent_risk/100;
  227.     nr_share = floor((InitialCapital + NetProfit) * risk) / close;
  228.     stop_loss_long=((((InitialCapital + NetProfit) * risk)/100) * input_stop_loss_long);
  229.     stop_loss_short=((((InitialCapital + NetProfit) * risk)/100) * input_stop_loss_short);
  230.     take_profit_long=((((InitialCapital + NetProfit) * risk)/100) * input_target_long);
  231.     take_profit_short=((((InitialCapital + NetProfit) * risk)/100) * input_target_short);
  232.    
  233.  
  234. // Cond Entry Long1 ///////////////////////////////////////////////////////
  235.  
  236. begin;
  237. if marketposition = 0 and valore_rsi_long < differenziale_rsi_long and (haClose - SlowEma_long) < distanza_long and valore_adx_long < differenziale_adx_alto_long and valore_adx_long > differenziale_adx_basso_long and (FastEMA_long[1] - SlowEMA_long[1]) < (FastEMA_long - SlowEMA_long) and Absvalue(haOpen-haClose) > boombar_3_long and FastEMA_long > SlowEMA_long  and haOpen < haClose and haOpen[1] > haClose[1] and haOpen[2] > haClose[2] and haOpen[3] > haClose[3] and not solo_short   Then
  238.  
  239.  
  240.    begin;
  241.    
  242.       Buy("Long") nr_share  contracts Next Bar at market;
  243.    
  244.    end;
  245.  
  246. // Cond Entry Long2 ///////////////////////////////////////////////////////
  247.  
  248. if marketposition = 0 and valore_rsi_long < differenziale_rsi_long and (haClose - SlowEma_long) < distanza_long and valore_adx_long < differenziale_adx_alto_long and valore_adx_long > differenziale_adx_basso_long and (FastEMA_long[1] - SlowEMA_long[1]) < (FastEMA_long - SlowEMA_long) and Absvalue(haOpen-haClose) > boombar_doji_long and FastEMA_long > SlowEMA_long  and haOpen < haClose and Absvalue(haClose[1] - haOpen[1]) < (haClose / 100 *mult_doji_long) and not solo_short   Then  
  249.     begin;
  250.    
  251.       Buy("Long2") nr_share  contracts Next Bar at market;
  252.      
  253.    end;
  254.  
  255. // Cond Exit Long 1 E 2 ///////////////////////////////////////////////////////
  256.  
  257.    {if marketposition = 1 then
  258.     begin;
  259.     Setstopposition;
  260.     SetStopLoss(stop_loss_long);
  261.     Setprofittarget(take_profit_long);
  262.     end;}
  263. end;
  264.  
  265.    {(SlowEMA[1] - FastEMA[1]) <= (SlowEMA - FastEMA) and (FastEma - haClose) < differenziale2 and}
  266.  
  267.  
  268. // Cond Entry Short1 ///////////////////////////////////////////////////////
  269.  
  270. begin;
  271. if marketposition = 0 and valore_rsi_short > differenziale_rsi_short and (SlowEma_short - haClose) < distanza_short and valore_adx_short < differenziale_adx_alto_short and valore_adx_short > differenziale_adx_basso_short and (SlowEMA_short[1] - FastEMA_short[1]) <= (SlowEMA_short - FastEMA_short) and  (Absvalue(haOpen-haClose) > boombar_3_short) and (FastEMA_short < SlowEMA_short) and (haOpen > haClose) and (haOpen[1] < haClose[1] and haOpen[2] < haClose[2] and haOpen[3] < haClose[3]) and not solo_long  Then
  272.  
  273.    begin;
  274.    
  275.       sellshort("short") nr_share  contracts Next Bar at market;
  276.      
  277.    end;
  278.  
  279.  
  280. // Cond Entry Short2 ///////////////////////////////////////////////////////
  281.  
  282. if marketposition = 0 and valore_rsi_short > differenziale_rsi_short and (SlowEma_short - haClose) < distanza_short and valore_adx_short < differenziale_adx_alto_short and valore_adx_short > differenziale_adx_basso_short and (SlowEMA_short[1] - FastEMA_short[1]) <= (SlowEMA_short - FastEMA_short) and FastEMA_short < SlowEMA_short and Absvalue(haOpen[1]-haClose[1]) < (haClose / 100 *mult_doji_short) and  (Absvalue(haOpen-haClose) > boombar_doji_short) and (haOpen > haClose) and not solo_long then
  283.  
  284.     begin;
  285.     sellshort("short2") nr_share contracts Next Bar at market;
  286.  
  287.  
  288. // Cond Exit Short 1 E 2 ///////////////////////////////////////////////////////
  289.    
  290.     end;
  291.     {if marketposition = -1 then
  292.     begin;
  293.     Setstopposition;
  294.     SetStopLoss(stop_loss_short);
  295.     Setprofittarget(take_profit_short);
  296.     end;}
  297.    
  298. end;
  299. Setstopposition;
  300. SetStopLoss(stop_loss_short);
  301. Setprofittarget(take_profit_short);
  302.  
  303.  
  304. end;
  305.  
  306.  
  307.  
  308.  
  309.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement