Buongiorno,
avrei bisogno di capire come inserire il comando di stop profit daily e stop loss daily .
es : al raggiungimento di 50 punti in target profit ,non verranno eseguite ulteriori operazioni fino al giorno dopo
analogamente per lo stop loss daily di 50 punti ,il sistema si ferma e riprende il giorno successivo.
grazie
vuoi una sola operazione al giorno o puoi avere più ingressi, se la condizione di ingresso si verifica più volte, e chiusura allo SL/TP?
una sola operazione al giorno, a prescindere che sia in stop loss o stop profit .
non è molto chiaro quanto di quello riportato qui sotto, devo inserire nel mio codice.
cos’è tally?
once maxTrades = 3 //maxNumberDailyTrades
once tally = 0
if intradayBarIndex = 0 then
tally = 0
endif
newTrades = (onMarket and not onMarket[1]) or ((not onMarket and not onMarket[1]) and (strategyProfit <> strategyProfit[1])) or (longOnMarket and ShortOnMarket[1]) or (longOnMarket[1] and shortOnMarket) or ((tradeIndex(1) = tradeIndex(2)) and (barIndex = tradeIndex(1)) and (barIndex > 0) and (strategyProfit = strategyProfit[1]))
if newTrades then
tally = tally +1
endif
Aggiungi queste righe prime delle entrate:
IF IntraDayBarIndex = 0 THEN
Profitto = StrategyProfit
ENDIF
GuadagnoOdierno = (StrategyProfit - Profitto) / PipValue
OTD = ((Barindex - TradeIndex(2)) > IntradayBarIndex)
IF GuadagnoOdierno < 50*PipSize THEN
OTD = 0
ENDIF
aggiungi poi questa ulteriore condizione alle tue condizioni:
AND Not OTD
in base a questo sistema ,puo’ dirmi cortesemente dove devo inserire esattemente le stringhe di codice che mi ha indicato . grazie
DEFPARAM FLATBEFORE = 090000
// Cancellare tutti gli ordini in attesa e chiudere tutte le posizioni all’orario “Flat After”
DEFPARAM FLATAFTER = 123000
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
ONCE trend = 1 // 1=UP, -1=DOWN
ONCE StartLevel = 18495
ONCE Box = 5*pipsize
if not onmarket then
IF Trend = 1 THEN //UP
IF close <= (StartLevel – Box) THEN
SELLSHORT 0.5 CONTRACT AT MARKET
ENDIF
ELSIF Trend = -1 THEN //DOWN
IF close >= (StartLevel + Box) THEN
BUY 0.5 CONTRACT AT MARKET
ENDIF
ENDIF
ENDIF
// trailing start
IF Trend = -1 THEN
IF close <= (StartLevel – 5*PipSize) THEN
StartLevel = StartLevel – 5*PipSize
ENDIF
ELSIF Trend = 1 THEN
IF close >= (StartLevel + 5*PipSize) THEN
StartLevel = StartLevel + 5*PipSize
ENDIF
ENDIF
// Stop e target
SET STOP pLOSS 5
SET TARGET pPROFIT 5
//
|
|
IF IntraDayBarIndex = 0 THEN
Profitto = StrategyProfit
ENDIF
GuadagnoOdierno = (StrategyProfit – Profitto) / PipValue
OTD = ((Barindex – TradeIndex(2)) > IntradayBarIndex)
IF GuadagnoOdierno < 50*PipSize THEN
OTD = 0
ENDIF
|
credo sia stata mal interpretata la mia richiesta.
La mia necessità era quella di interrompere la strategia DOPO LA PRIMA OPERAZIONE effettuata, qualunque ne sia l’esito positivo o negativo .
Quindi mi fermo dopo la 1° operazione, sempre.
Quindi non deve fare più di un’operazione giornaliera, comunque vada:
DEFPARAM CumulateOrders = False
DEFPARAM FLATBEFORE = 090000
// Cancellare tutti gli ordini in attesa e chiudere tutte le posizioni all’orario "Flat After"
DEFPARAM FLATAFTER = 123000
OTD = ((Barindex - TradeIndex(2)) > IntradayBarIndex)
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
ONCE trend = 1 // 1=UP, -1=DOWN
ONCE StartLevel = 18495
ONCE Box = 5*pipsize
if not onmarket AND OTD then
IF Trend = 1 THEN //UP
IF close <= (StartLevel - Box) THEN
SELLSHORT 0.5 CONTRACT AT MARKET
ENDIF
ELSIF Trend = -1 THEN //DOWN
IF close >= (StartLevel + Box) THEN
BUY 0.5 CONTRACT AT MARKET
ENDIF
ENDIF
ENDIF
// trailing start
IF Trend = -1 THEN
IF close <= (StartLevel - 5*PipSize) THEN
StartLevel = StartLevel - 5*PipSize
ENDIF
ELSIF Trend = 1 THEN
IF close >= (StartLevel + 5*PipSize) THEN
StartLevel = StartLevel + 5*PipSize
ENDIF
ENDIF
// Stop e target
SET STOP pLOSS 5
SET TARGET pPROFIT 5
//
Buongiorno,
ho provato il funzionamento della strategia con il codice riportato sopre , ma purtroppo il sistema non parte e non esegue neanche un’operazione.
sa cortesemente dirmi il perchè?
al contrario questo codice esegue perfettamente ingresso e trailing start, ma non si ferma ad una solo trade al giorno (1 ingresso e 1 uscita, a prescindere che sia positiva o negativa)
può aiutarmi cortesemente?
EFPARAM FLATBEFORE = 090000
// Cancellare tutti gli ordini in attesa e chiudere tutte le posizioni all’orario “Flat After”
DEFPARAM FLATAFTER = 123000
// MaxTrades yearly, daily, weekly, monthly
//
//daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
ONCE trend = 1 // 1=UP, -1=DOWN
ONCE StartLevel = 18485
ONCE Box = 5*pipsize
Once MaxTrades = 1 //max 1 trade allowed
Once TradeOn = 1
Once TradeCount = 0
If TradeCount = MaxTrades then
TradeOn = 0
endif
if not onmarket then
IF Trend = 1 THEN //UP
IF close <= (StartLevel – Box) THEN
SELLSHORT 0.5 CONTRACT AT MARKET
ENDIF
ELSIF Trend = -1 THEN //DOWN
IF close >= (StartLevel + Box) THEN
BUY 0.5 CONTRACT AT MARKET
ENDIF
ENDIF
ENDIF
// trailing start
IF Trend = -1 THEN
IF close <= (StartLevel – 5*PipSize) THEN
StartLevel = StartLevel – 5*PipSize
ENDIF
ELSIF Trend = 1 THEN
IF close >= (StartLevel + 5*PipSize) THEN
StartLevel = StartLevel + 5*PipSize
ENDIF
ENDIF
// Stop e target
SET STOP pLOSS 5
SET TARGET pPROFIT 5
//