Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Bot Swing Trend Trailing Equity Control Drawdown //
- // **************************************************************************************************************************
- // 2 Metodi EQC:
- // 1) Start sopra equityControlPercent "relative rawdown percent", stop sotto equityControlPercent "relative rawdown percent"
- // 2) Start sopra equityControlPercent "relative rawdown percent" ma con una nuova rottura dell'equity , stop sotto equityControlPercent "relative rawdown percent"
- // **************************************************************************************************************************
- // **************************************************************************************************************************
- // Inizio Equity Control
- // **************************************************************************************************************************
- Input: Start_EQC_Inputs("--------------"),
- EQC_Method_Inp(0),
- equityControlPercent(7),
- Start_Strategy_Inputs("--------------");
- Var: EQC_Method(false),
- EquityBroken(0),
- balance2(0),
- highestRelativeEquity2(0),
- relativeDrawdownMonetary2(0),
- lowestRelativeEquity2(0),
- relativeDrawdownPercent2(0);
- balance2 = (close Of Data2);
- // Highest Relative Equity
- highestRelativeEquity2 = MaxList(balance2, highestRelativeEquity2);
- // LowestRelativeEquity E RelativeDrawdownMonetary E RelativeDrawdownPercent
- if balance2 <= highestRelativeEquity2 then
- lowestRelativeEquity2 = minlist(highestRelativeEquity2, balance2);
- relativeDrawdownMonetary2 = (highestRelativeEquity2 - balance2);
- relativeDrawdownPercent2 = (relativeDrawdownMonetary2 / highestRelativeEquity2) * 100;
- // When we have a new Equity High and Relative Drawdown is Less then equityControlPercent the value is set to 0 else 1. "Start Straidng Broke Equity Allowed"
- If relativeDrawdownPercent2 > equityControlPercent then
- EquityBroken = EquityBroken +1
- else if
- relativeDrawdownPercent2 = 0 then
- EquityBroken = 0;
- // **************************************************************************************************************************
- // Entrata Senza Equity Control EQC_Method = 0
- // **************************************************************************************************************************
- if EQC_Method_Inp = 0 then begin
- EQC_Method = true;
- end
- // **************************************************************************************************************************
- // Equity Control. Stoppa l'operatività ad una percentuale input derivanta dal massimo drawdown relativo della strategia originale caricata in data2 "Balance Con Initial Capital di tutte le candele" EQC_Method = 1
- // **************************************************************************************************************************
- else if EQC_Method_Inp = 1 then begin
- EQC_Method = relativeDrawdownPercent2 >= 0 and relativeDrawdownPercent2 <= equityControlPercent;
- end
- // **************************************************************************************************************************
- // Equity Control. Stoppa l'operatività ad una percentuale input derivanta dal massimo drawdown relativo della strategia originale caricata in data2 "Balance Con Initial Capital di tutte le candele" EQC_Method = 2
- // La strategia Riparte quando rompiamo un nuovo massimo dell'equity e non abbiamo raggiunto l'input del massimo drawdown ammesso ES: Stop >= 7% Max DD; Restart New Highest Equity High and < 7% Max DD;
- // **************************************************************************************************************************
- else if
- EQC_Method_Inp = 2 then Begin
- EQC_Method = EquityBroken = 0;
- end;
- // **************************************************************************************************************************
- // Inizio Strategia
- // **************************************************************************************************************************
- //Il trading system completo - Swing-Trend-Trailing (Strategia Trend Following Con Swing Di Posizione) - parte 1
- // (Exchange= FTX) (Sottostante ETH-PERP) (Timeframe= 4H) (Direzione= LONG E SHORT) (Swing Posizione= SI) (Esclusione Ore=NO) (Esclusione Giorni=NO') (Esclusione Mesi=NO)
- // (Take Profit Long/Short Market = Trailing) (Take Profit Limit Long/Short= NO) (Stop Loss Limit Long/Short= -10%) (Stop Loss Market Long/Short= SI) (Trailing Stop=SI) (Stop Emergenza= NO)
- // (Rischio Operazione 2% Perdita Media)
- // (In Sample Dal=17/08/2017 Al 17/10/2020) (Out Of Sample Dal=18/10/2020 Al 15/03/2021)
- // GLI IMPUT POTREBBERO ESSERE DIVERSI E VANNO PRESI DAL CODICE DI PINESCRIPT, INSERIRE ANCHE LE VARIABILI SHORT CHE POTREBBERO AVERE INPUT DIVERSI
- // Auentare il Max Bars Back Su Tradestation Altrimenti Non Funziona Il Conteggio Barssinceentry 500 E Cliccare Su Enable Strategy Altrimenti Non Parte
- input:
- InitialCapital(100000),
- percent_risk(25),
- lunghezza_ema(90),
- perc_apertura_minima(2),
- perc_apertura_massima(4),
- perc_chiusura_minima(0),
- input_trailing_stop_trigger(12),
- input_trailing_stop_close(6),
- input_stop_loss_percent(10), // Unico Long E Short
- //skipday(saturday),
- //skipmonth1(10),
- //skipmonth2(9),
- solo_long(false),
- solo_short(false);
- Vars:
- media_ema(0),
- apertura_minima(0),
- apertura_massima(0),
- chiusura_minima(0),
- stop_loss(0),
- media_ema_1(0),
- trailing_stop_trigger(0),
- trailing_stop_close(0),
- trailing_stop_trigger_long(0),
- trailing_stop_close_long(0),
- trailing_stop_trigger_short(0),
- trailing_stop_close_short(0),
- trailing_long(false),
- trailing_short(false),
- highesthigh(0),
- lowestlow(0),
- ATR(0),
- risk(0),
- nr_share(0);
- // Calcololo degli indicatori
- media_ema = XAverage(Close, lunghezza_ema);
- media_ema_1 = XAverage(Close[1], lunghezza_ema);
- // calcolo dei filtri in percentuale
- apertura_minima = (media_ema / 100) * perc_apertura_minima;
- apertura_massima = (media_ema / 100) * perc_apertura_massima;
- chiusura_minima = (media_ema / 100) * perc_chiusura_minima;
- // Calcolo Trailing Stop Long E Short
- trailing_stop_trigger_long = Entryprice + (entryprice * input_trailing_stop_trigger)/100;
- trailing_stop_close_long = entryprice + (entryprice * input_trailing_stop_close)/100;
- trailing_stop_trigger_short = Entryprice - (entryprice * input_trailing_stop_trigger)/100;
- trailing_stop_close_short = entryprice - (entryprice * input_trailing_stop_close)/100;
- // Originale
- {trailing_long = high >= trailing_stop_trigger_long and Close < trailing_stop_close_long and close[1] > trailing_stop_close_long) or (MarketPosition =1 and high[1] >= trailing_stop_trigger_long and Close < trailing_stop_close_long and close[1] > trailing_stop_close_long) or (MarketPosition =1 and high[2] >= trailing_stop_trigger_long and Close < trailing_stop_close_long and close[1] > trailing_stop_close_long) or (MarketPosition =1 and high[3] >= trailing_stop_trigger_long and Close < trailing_stop_close_long and close[1] > trailing_stop_close_long)
- or (MarketPosition =1 and high[4] >= trailing_stop_trigger_long and Close < trailing_stop_close_long and close[1] > trailing_stop_close_long) or (MarketPosition =1 and high[5] >= trailing_stop_trigger_long and Close < trailing_stop_close_long and close[1] > trailing_stop_close_long) or (MarketPosition =1 and high[6] >= trailing_stop_trigger_long and Close < trailing_stop_close_long and close[1] > trailing_stop_close_long) or (MarketPosition =1 and high[7] >= trailing_stop_trigger_long and Close < trailing_stop_close_long and close[1] > trailing_stop_close_long)
- or (MarketPosition =1 and high[8] >= trailing_stop_trigger_long and Close < trailing_stop_close_long and close[1] > trailing_stop_close_long) or (MarketPosition =1 and high[9] >= trailing_stop_trigger_long and Close < trailing_stop_close_long and close[1] > trailing_stop_close_long) or (MarketPosition =1 and high[10] >= trailing_stop_trigger_long and Close < trailing_stop_close_long and close[1] > trailing_stop_close_long) or (MarketPosition =1 and high[11] >= trailing_stop_trigger_long and Close < trailing_stop_close_long and close[1] > trailing_stop_close_long)
- or (MarketPosition =1 and high[12] >= trailing_stop_trigger_long and Close < trailing_stop_close_long and close[1] > trailing_stop_close_long) or (MarketPosition =1 and high[13] >= trailing_stop_trigger_long and Close < trailing_stop_close_long and close[1] > trailing_stop_close_long) or (MarketPosition =1 and high[14] >= trailing_stop_trigger_long and Close < trailing_stop_close_long and close[1] > trailing_stop_close_long) or (MarketPosition =1 and high[15] >= trailing_stop_trigger_long and Close < trailing_stop_close_long and close[1] > trailing_stop_close_long)
- or (MarketPosition =1 and high[16] >= trailing_stop_trigger_long and Close < trailing_stop_close_long and close[1] > trailing_stop_close_long);
- // Originale
- trailing_short = low <= trailing_stop_trigger_short and Close > trailing_stop_close_short and close[1] < trailing_stop_close_short) or (MarketPosition =-1 and low[1] <= trailing_stop_trigger_short and Close > trailing_stop_close_short and close[1] < trailing_stop_close_short) or (MarketPosition =-1 and low[2] <= trailing_stop_trigger_short and Close > trailing_stop_close_short and close[1] < trailing_stop_close_short) or (MarketPosition =-1 and low[3] <= trailing_stop_trigger_short and Close > trailing_stop_close_short and close[1] < trailing_stop_close_short)
- or (MarketPosition =-1 and low[4] <= trailing_stop_trigger_short and Close > trailing_stop_close_short and close[1] < trailing_stop_close_short) or (MarketPosition =-1 and low[5] <= trailing_stop_trigger_short and Close > trailing_stop_close_short and close[1] < trailing_stop_close_short) or (MarketPosition =-1 and low[6] <= trailing_stop_trigger_short and Close > trailing_stop_close_short and close[1] < trailing_stop_close_short) or (MarketPosition =-1 and low[7] <= trailing_stop_trigger_short and Close > trailing_stop_close_short and close[1] < trailing_stop_close_short)
- or (MarketPosition =-1 and low[8] <= trailing_stop_trigger_short and Close > trailing_stop_close_short and close[1] < trailing_stop_close_short) or (MarketPosition =-1 and low[9] <=trailing_stop_trigger_short and Close > trailing_stop_close_short and close[1] < trailing_stop_close_short) or (MarketPosition =-1 and low[10] <= trailing_stop_trigger_short and Close > trailing_stop_close_short and close[1] < trailing_stop_close_short) or (MarketPosition =-1 and low[11] <= trailing_stop_trigger_short and Close > trailing_stop_close_short and close[1] < trailing_stop_close_short)
- or (MarketPosition =-1 and low[12] <= trailing_stop_trigger_short and Close > trailing_stop_close_short and close[1] < trailing_stop_close_short) or (MarketPosition =-1 and low[13] <= trailing_stop_trigger_short and Close > trailing_stop_close_short and close[1] < trailing_stop_close_short) or (MarketPosition =-1 and low[14] <= trailing_stop_trigger_short and Close > trailing_stop_close_short and close[1] < trailing_stop_close_short) or (MarketPosition =-1 and low[15] <= trailing_stop_trigger_short and Close > trailing_stop_close_short and close[1] < trailing_stop_close_short)
- or (MarketPosition =-1 and low[16] <= trailing_stop_trigger_short and Close > trailing_stop_close_short and close[1] < trailing_stop_close_short);}
- {trailing_long = high >= trailing_stop_trigger_long and Close cross under trailing_stop_close_long) or (MarketPosition =1 and high[1] >= trailing_stop_trigger_long and Close cross under trailing_stop_close_long) or (MarketPosition =1 and high[2] >= trailing_stop_trigger_long and Close cross under trailing_stop_close_long) or (MarketPosition =1 and high[3] >= trailing_stop_trigger_long and Close cross under trailing_stop_close_long)
- or (MarketPosition =1 and high[4] >= trailing_stop_trigger_long and Close cross under trailing_stop_close_long) or (MarketPosition =1 and high[5] >= trailing_stop_trigger_long and Close cross under trailing_stop_close_long) or (MarketPosition =1 and high[6] >= trailing_stop_trigger_long and Close cross under trailing_stop_close_long) or (MarketPosition =1 and high[7] >= trailing_stop_trigger_long and Close cross under trailing_stop_close_long)
- or (MarketPosition =1 and high[8] >= trailing_stop_trigger_long and Close cross under trailing_stop_close_long) or (MarketPosition =1 and high[9] >= trailing_stop_trigger_long and Close cross under trailing_stop_close_long) or (MarketPosition =1 and high[10] >= trailing_stop_trigger_long and Close cross under trailing_stop_close_long) or (MarketPosition =1 and high[11] >= trailing_stop_trigger_long and Close cross under trailing_stop_close_long)
- or (MarketPosition =1 and high[12] >= trailing_stop_trigger_long and Close cross under trailing_stop_close_long) or (MarketPosition =1 and high[13] >= trailing_stop_trigger_long and Close cross under trailing_stop_close_long) or (MarketPosition =1 and high[14] >= trailing_stop_trigger_long and Close cross under trailing_stop_close_long) or (MarketPosition =1 and high[15] >= trailing_stop_trigger_long and Close cross under trailing_stop_close_long)
- or (MarketPosition =1 and high[16] >= trailing_stop_trigger_long and Close cross under trailing_stop_close_long);
- trailing_short = low <= trailing_stop_trigger_short and Close cross over trailing_stop_close_short) or (MarketPosition =-1 and low[1] <= trailing_stop_trigger_short and Close cross over trailing_stop_close_short) or (MarketPosition =-1 and low[2] <= trailing_stop_trigger_short and Close cross over trailing_stop_close_short) or (MarketPosition =-1 and low[3] <= trailing_stop_trigger_short and Close cross over trailing_stop_close_short)
- or (MarketPosition =-1 and low[4] <= trailing_stop_trigger_short and Close cross over trailing_stop_close_short) or (MarketPosition =-1 and low[5] <= trailing_stop_trigger_short and Close cross over trailing_stop_close_short) or (MarketPosition =-1 and low[6] <= trailing_stop_trigger_short and Close cross over trailing_stop_close_short) or (MarketPosition =-1 and low[7] <= trailing_stop_trigger_short and Close cross over trailing_stop_close_short)
- or (MarketPosition =-1 and low[8] <= trailing_stop_trigger_short and Close cross over trailing_stop_close_short) or (MarketPosition =-1 and low[9] <=trailing_stop_trigger_short and Close cross over trailing_stop_close_short) or (MarketPosition =-1 and low[10] <= trailing_stop_trigger_short and Close cross over trailing_stop_close_short) or (MarketPosition =-1 and low[11] <= trailing_stop_trigger_short and Close cross over trailing_stop_close_short)
- or (MarketPosition =-1 and low[12] <= trailing_stop_trigger_short and Close cross over trailing_stop_close_short) or (MarketPosition =-1 and low[13] <= trailing_stop_trigger_short and Close cross over trailing_stop_close_short) or (MarketPosition =-1 and low[14] <= trailing_stop_trigger_short and Close cross over trailing_stop_close_short) or (MarketPosition =-1 and low[15] <= trailing_stop_trigger_short and Close cross over trailing_stop_close_short)
- or (MarketPosition =-1 and low[16] <= trailing_stop_trigger_short and Close cross over trailing_stop_close_short)}
- highesthigh = highest(high, Barssinceentry);
- trailing_long = (highesthigh >= trailing_stop_trigger_long and close <= trailing_stop_close_long);
- lowestlow = lowest(low, Barssinceentry);
- trailing_short = (lowestlow <= trailing_stop_trigger_short and close >= trailing_stop_close_short);
- // Money menagment
- risk = percent_risk/100;
- nr_share = floor((InitialCapital + NetProfit) * risk) / close ;
- stop_loss=((((InitialCapital + NetProfit) * risk)/100) * input_stop_loss_percent);
- // **************************************************************************************************************************
- // // Entrata/Uscita Long
- // **************************************************************************************************************************
- // Entrata Long
- { and (close[1] < ema1 + apertura_minima or low[1] < ema1 + apertura_minima Tradingview}
- //if close > (media_ema+apertura_minima) and close < (media_ema + apertura_massima) and close[2] < (media_ema+apertura_minima) and open > close and not solo_short {and Dayofweek(date) <> skipday and month(date) <> skipmonth1 and Dayofmonth(date) > 5} then
- if close > (media_ema + apertura_minima) and close < (media_ema + apertura_massima) and ((close[1] < (media_ema_1 + apertura_minima)) or (low[1] < (media_ema_1 + apertura_minima))) and close > open and not solo_short {and Dayofweek(date) <> skipday and month(date) <> skipmonth1 and Dayofmonth(date) > 5} and EQC_Method then//and relativeDrawdownPercent2 >= 0 and relativeDrawdownPercent2 <= equityControlPercent then
- Buy("Long") nr_share contracts Next Bar at market;
- // Uscita Long
- if close < media_ema - chiusura_minima then
- Sell("Chiusura Long") from entry("Long") Next Bar at market;
- // Uscita Trailing Long
- If (MarketPosition =1 and trailing_long) then
- Sell("Trailing Long") from entry("Long") Next Bar at market;
- // **************************************************************************************************************************
- // Entrata/Uscita Short
- // **************************************************************************************************************************
- // Entrata Short
- {and (close[1] > ema1 - apertura_minima or low[1] > ema1 - apertura_minima)}
- if close < (media_ema - apertura_minima) and close > (media_ema - apertura_massima) and ((close[1] > (media_ema_1 - apertura_minima)) or (high[1] > (media_ema_1 - apertura_minima))) and close < open and not solo_long {and Dayofweek(date) <> skipday and month(date) <> skipmonth1 and Dayofmonth > 5} and EQC_Method then //and relativeDrawdownPercent2 >= 0 and relativeDrawdownPercent2 <= equityControlPercent then
- Sellshort("Short") nr_share Contracts Next Bar at market;
- // Uscita Short
- if close > (media_ema + chiusura_minima) then
- Buytocover("Chiusura Short") from entry("Short") Next Bar at market;
- // Uscita Trailing Short
- If (MarketPosition =-1 and trailing_short) then
- Buytocover("Trailing Short") from entry("Short") Next Bar at market;
- Setstopposition;
- SetStopLoss(stop_loss);
- // **************************************************************************************************************************
- // Fine Strategia
- // **************************************************************************************************************************
- // **************************************************************************************************************************
- // Calcolo dell relative drawdown della strategia attuale che stà girando Data1 "Strategy"
- // **************************************************************************************************************************
- inputs: Start_EQC_Input("--------------");
- Vars:
- mp(0),
- formattedDate(""),
- formattedTime(""),
- dateTimeString("");
- Vars:
- balance(0),
- highestRelativeEquity(0),
- relativeDrawdownMonetary(0),
- lowestRelativeEquity(0),
- relativeDrawdownPercent(0);
- // Balance
- balance = (InitialCapital + NetProfit);
- mp = marketposition;
- // Highest Relative Equity
- highestRelativeEquity = MaxList(balance, highestRelativeEquity);
- // LowestRelativeEquity E RelativeDrawdownMonetary E RelativeDrawdownPercent
- if balance <= highestRelativeEquity then
- lowestRelativeEquity = minlist(highestRelativeEquity, balance);
- relativeDrawdownMonetary = (highestRelativeEquity - balance);
- relativeDrawdownPercent = (relativeDrawdownMonetary / highestRelativeEquity) * 100;
- // **************************************************************************************************************************
- // Export Equity Con Initial Capital Incluso Di Tutte Le Candele Eccetto BarsBack Della Strategia On Csv //
- // **************************************************************************************************************************
- // Sul file .csv carico: Date/Time/Open/High/Low /Equity/Volume Per una questione di caricamento su tradestation... . Apro il grafico, clicco su una candela 2 volte e nelle impostazioni style clicco su line on close
- // per avere una linea con solo i valori dell'equity profitti/perdite cumulative con l'initial capital.
- //if mp[0] <> mp[1] and mp[0] <> 0 then begin { Solo per scaricare i dati ad ogni inizio nuova operazione, se commentato scarico tutte le candele.}
- // Quando carico Data2 il numero delle candele deve coincidere con il Data1, altrimenti tradestation non riesce a caricarli, per questo motivo scarico il balance di ongi candela.
- Inputs: printFileEquityWithInitCapitAllCandles(false),
- printLogStrategy(false),
- printLogEquity(false);
- If printFileEquityWithInitCapitAllCandles = True {and mp[0] <> mp[1] and mp[0] <> 0 then begin} Then Begin
- // Formatta la data nel formato "MM-dd-yyyy"
- formattedDate = FormatDate("yyyy-MM-dd", ElDateToDateTime(Date));
- // Formatta l'ora nel formato "00:00:00"
- formattedTime = BarDateTime.Format("%H:%M:%S");
- // Combina data e ora nel formato richiesto
- dateTimeString = formattedDate + "," + formattedTime;
- // Stampa nel file CSV il balance della strategia originale tutte le candele eccetto barbacks
- Print(File("C:\Users\Utente\Desktop\Equity Control\Tradestation\Swing Trend Trailing\Exports\Export_Equity.csv"), dateTimeString, ",", open, ",", high, ",", low, ",", NumToStr(balance, 2) , Volume, ",");
- End;
- // Print Log Strategy Data1 Tutte Le Candele
- if printLogStrategy = true Then
- Begin
- Once Clearprintlog; // Clear the print log when the strategy first applyed or refreshed
- print(Formatdate("dd/MM/yy", ElDateToDateTime( Date )), ", ", BarDateTime.Format( "%H%M.%S" ), ", ", " HighestRelativeEQData1= " ,highestRelativeEquity, ", ", " LowestRelativeEQData1= " ,lowestRelativeEquity, ", ", " RelativeDrawdownMonetaryData1= ", relativeDrawdownMonetary, ", ", " RelativeDrawdownPercentData1= ", relativeDrawdownPercent , " %", ", ", " BarNumData1= ", BarNumber);
- End;
- // Print Log Equity Data2 Tutte Le Candele
- if printLogEquity = true Then
- Begin
- Once Clearprintlog; // Clear the print log when the strategy first applyed or refreshed
- print(Formatdate("dd/MM/yy", ElDateToDateTime( Date )), ", ", BarDateTime.Format( "%H%M.%S" ), ", ", " HighestRelativeEQData2= " ,highestRelativeEquity2, ", ", " LowestRelativeEQData2= " ,lowestRelativeEquity2, ", ", " RelativeDrawdownMonetaryData2= ", relativeDrawdownMonetary2, ", ", " RelativeDrawdownPercentData2= ", relativeDrawdownPercent2 , " %", ", ", " BarNumData2= ", BarNumber);
- End;
- // **************************************************************************************************************************
- // Plotshape E Print Della Strategia Che Stà Girando Data1 "Strategy" // Mostra solo se il DrawDown Supera o meno il valore di input. Non ha nulla a che fare con gli ingressi.
- // **************************************************************************************************************************
- Input: plotshapeStrategy(false);
- // Plot su strategy 1mo plot Start Della Strategia Che Stà Girando Data1 "Strategy"
- If plotshapeStrategy = true and relativeDrawdownPercent < equityControlPercent {and mp <> 0} Then
- Begin
- Value1 = Text_new(D, T, L, "*");
- Text_setcolor(Value1, Green);
- Text_setstyle(Value1, 2, 0);
- End;
- // Plot su strategy 2ndo plot End Solo Dei Trade Conclusi Della Strategia Che Stà Girando Data1 "Strategy"
- If plotshapeStrategy = true and (relativeDrawdownPercent > equityControlPercent) {and (mp = 0) or (mp <> 0))} Then
- Begin
- Value2 = Text_new(D, T, L, "*");
- Text_setcolor(Value2, Red);
- Text_setstyle(Value2, 2, 0);
- End;
- // **************************************************************************************************************************
- // Plotshape E Print Start End Dell'Equity Di Data2 "Equity" // Questo ha a che fare con gli ingressi
- // **************************************************************************************************************************
- Input: plotshapeEquity(false),
- printStartEndEquity(false);
- // Plot su strategy 1mo plot Start Solo Del'equity Data2 "Equity"
- If plotshapeEquity = true and EQC_Method {and mp <> 0} Then
- Begin
- Value3 = Text_new(D, T, L, "*");
- Text_setcolor(Value3, Green);
- Text_setstyle(Value3, 2, 0);
- End;
- // Plot su strategy 2ndo plot End Solo Del'equity Data2 "Equity"
- If plotshapeEquity = true and (relativeDrawdownPercent2 > equityControlPercent) {and (mp = 0) or (mp <> 0))} Then
- Begin
- Value4 = Text_new(D, T, L, "*");
- Text_setcolor(Value4, Red);
- Text_setstyle(Value4, 2, 0);
- End;
- // Print delle date Start Dell'equity Data2 "Equity"
- If printStartEndEquity = true then
- Begin
- Once Clearprintlog; // Clear the print log when the strategy first applyed or refreshed
- if EQC_Method and close of data2 <> close[1] of data2 Then {and close of data2 <> close[1] of data2 "Riduce I Log Non Necessari"}
- print(Formatdate("dd/MM/yy", ElDateToDateTime( Date )), ", ", BarDateTime.Format( "%H%M.%S" ), " Start Equity Data2", ", ", " DD=", relativeDrawdownPercent2, " %");
- // Print delle date End Dell'equity Data2 "Equity"
- if (relativeDrawdownPercent2 > equityControlPercent) and close of data2 <> close[1] of data2 Then {and close of data2 <> close[1] of data2 "Riduce I Log Non Necessari"}
- print(Formatdate("dd/MM/yy", ElDateToDateTime( Date )), ", ", BarDateTime.Format( "%H%M.%S" ), " End Equity Data2", ", ", " DD=", relativeDrawdownPercent2, " %");
- End;
- // **************************************************************************************************************************
- // Export Equity With No Initial Capital On Csv Solo Dei Trade Conclusi //
- // **************************************************************************************************************************
- // Sul file .csv carico: Date/Time/Open/High/Low /Equity/Volume Per una questione di caricamento su tradestation... . Apro il grafico, clicco su una candela 2 volte e nelle impostazioni style clicco su line on close
- // per avere una linea con solo i valori dell'equity profitti/perdite cumulative.
- {Vars:
- mp(0),
- formattedDate(""),
- formattedTime(""),
- dateTimeString("");
- mp = marketposition;
- if mp[0] <> mp[1] and mp[0] <> 0 then begin
- // Formatta la data nel formato "MM-dd-yyyy"
- formattedDate = FormatDate("dd-MM-yyyy", ElDateToDateTime(Date));
- // Formatta l'ora nel formato "00:00:00"
- formattedTime = BarDateTime.Format("%H:%M:%S");
- // Combina data e ora nel formato richiesto
- dateTimeString = formattedDate + "," + formattedTime;
- // Stampa nel file CSV
- Print(File("C:\Users\Utente\Desktop\Equity Control\Tradestation\Swing Trend Trailing\Exports\Export_Equity.csv"), dateTimeString, ",", open, ",", high, ",", low, ",", NumToStr(NetProfit, 2) , Volume, ",");
- end;}
Advertisement
Comments
-
- Wow thanks!
-
- download 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