Debugging exit 2 which use stochastic (simple logic)

Работа завершена

Время выполнения 9 минут
Отзыв от заказчика
developer deliver the job according to my need
Отзыв от исполнителя
Thank you!

Техническое задание

1) Core strategy logic (state machine)

States:

  • BEGINNING_00 (idle)

  • SETUP_00 → SETUP_01 → SETUP_02 → SETUP_03

  • SELL mirror required

Donchian touch triggers:

  • BUY_SETUP_00 triggers ONLY when price touches Donchian LOW

  • SELL_SETUP_00 triggers ONLY when price touches Donchian HIGH

  • Special case: if a candle touches BOTH Donchian high and low, use WAD trend on that candle to decide BUY vs SELL on that candle.

Restart-on-touch (important):

  • If there is no position at the close of candle n, and candle n touches Donchian, then the setup must restart to Setup_00 from candle n (even if previously in Setup_01/02/03).

  • This affects which candle is the “first setup candle” and therefore affects fixed cut-loss, retracement reference, and TP1 base.

Valid setup bar count rules:

  • setup candle t, t+1, t+2, t+3 are valid setup candles

  • t+4 is last chance for a pending stop order fill (same as Python logic)

Fixed stop loss rule (big requirement):

  • In SETUP_01, the cut loss (SL) must be fixed at the FIRST Setup01 candle.

  • Entry trigger level can trail each new setup candle.

  • Intrabar special case:

    • If price breaks the stop-loss side first (e.g., long breaks below stop level) then breaks the trigger level later in the same candle, then the SL is adjusted to the new extreme (and sizing adjusted if needed). Mirror for short.

Entry types (user selectable)
A) Normal stop entry:

  • Long: Buy Stop at setup candle High + 1 pip + spread (bid-stream model)

  • Short: Sell Stop at setup candle Low - 1 pip (bid-stream model)

B) Retracement entry:

  • Virtual breakout trigger starts retrace logic when breakout trigger is hit

  • Long: Buy Limit at % retracement from swing high toward swing ref

  • Short: Sell Limit at % retracement from swing low toward swing ref

  • CAP rule:

    • Long: if limit > breakout stop-entry price, cap it at breakout stop-entry

    • Short: if limit < breakout stop-entry price, cap it at breakout stop-entry

TP1 / TP2 exits
Two-position hedging mode:

  • At entry, open two separate positions:

    • TP1 leg = 50% volume, has server-side TP at TP1

    • Runner leg = 50% volume, no TP; TP2 logic activates only after TP1 is closed

  • Preferred over partial close

TP1:

  • Default TP1 = 1R, but in retracement mode TP1 is based on virtual breakout entry (not the retrace fill price)

TP2 method A — Stochastic trailing (this is the main area that still has issues):
Scanning start:

  • If TP1 hits on candle t, start scanning TP2 on candle t+1

Activation (whichever happens first after scanning starts):

  • Long: %K ≥ 80 OR %K crosses below %D

  • Short: %K ≤ 20 OR %K crosses above %D
    Important:

  • If TP1 hit and %K is already beyond threshold when scanning starts, activate immediately (no need to cross into it).

Trailing start:

  • If activation happens on candle a, trailing begins on candle a+1:

    • Long: stop = low(a) − 1 pip (applied from a+1 onward)

    • Short: stop = high(a) + 1 pip (applied from a+1 onward)

  • Tighten-only trailing (never loosens)

TP2 method B — PSAR trailing:

  • PSAR(t-1) trailing after TP1 closed

  • Freeze when PSAR flips to wrong side; resume when PSAR flips back
    (PSAR seems okay)

Risk / sizing:

  • Position size is risk n% of capital m (both inputs)

  • For JPY pairs etc, sizing uses OrderCalcProfit-based calculation to avoid tick-value conversion issues

Execution model:

  • Bid-stream core logic

  • Spread adjustments applied where required (e.g., buy entries, sell SL/TP, etc.)

2) What’s currently wrong

Most state machine is correct now, but TP2 Stochastic trailing sometimes:

  • does not activate when it should

  • or trails using the wrong candle reference

  • or appears inconsistent (sometimes correct, sometimes wrong)

I suspect a combination of:

  • activation gating timing (TP1 close time vs when EA detects it)

  • bar indexing / shift

  • position selection context (PositionSelectByTicket affecting subsequent PositionGet* calls)

  • SL modify failures due to stops/freeze (needs explicit logging)


Откликнулись

1
Разработчик 1
Оценка
(1)
Проекты
0
0%
Арбитраж
2
0% / 100%
Просрочено
0
Свободен
2
Разработчик 2
Оценка
(1)
Проекты
2
0%
Арбитраж
1
0% / 100%
Просрочено
0
Свободен
Опубликовал: 2 примера
3
Разработчик 3
Оценка
(2)
Проекты
3
0%
Арбитраж
1
0% / 0%
Просрочено
2
67%
Свободен
4
Разработчик 4
Оценка
(3)
Проекты
1
0%
Арбитраж
5
0% / 100%
Просрочено
0
Свободен
5
Разработчик 5
Оценка
Проекты
0
0%
Арбитраж
0
Просрочено
0
Свободен
6
Разработчик 6
Оценка
Проекты
0
0%
Арбитраж
0
Просрочено
0
Свободен
7
Разработчик 7
Оценка
Проекты
0
0%
Арбитраж
0
Просрочено
0
Свободен
8
Разработчик 8
Оценка
(319)
Проекты
569
35%
Арбитраж
83
30% / 45%
Просрочено
206
36%
Работает
9
Разработчик 9
Оценка
(7)
Проекты
5
0%
Арбитраж
5
0% / 80%
Просрочено
1
20%
Работает
10
Разработчик 10
Оценка
(15)
Проекты
29
38%
Арбитраж
3
33% / 67%
Просрочено
6
21%
Работает
11
Разработчик 11
Оценка
(16)
Проекты
35
23%
Арбитраж
4
0% / 50%
Просрочено
2
6%
Работает
12
Разработчик 12
Оценка
(4)
Проекты
3
33%
Арбитраж
2
0% / 100%
Просрочено
0
Свободен
13
Разработчик 13
Оценка
(19)
Проекты
22
18%
Арбитраж
9
33% / 44%
Просрочено
3
14%
Работает
Опубликовал: 1 пример
14
Разработчик 14
Оценка
Проекты
2
0%
Арбитраж
0
Просрочено
1
50%
Свободен
15
Разработчик 15
Оценка
Проекты
0
0%
Арбитраж
0
Просрочено
0
Свободен
16
Разработчик 16
Оценка
(13)
Проекты
20
40%
Арбитраж
3
0% / 67%
Просрочено
3
15%
Свободен
17
Разработчик 17
Оценка
(6)
Проекты
7
14%
Арбитраж
1
0% / 100%
Просрочено
1
14%
Свободен
18
Разработчик 18
Оценка
(645)
Проекты
873
48%
Арбитраж
29
38% / 17%
Просрочено
63
7%
Свободен
19
Разработчик 19
Оценка
(22)
Проекты
29
3%
Арбитраж
4
25% / 0%
Просрочено
3
10%
Свободен
20
Разработчик 20
Оценка
(619)
Проекты
722
33%
Арбитраж
46
48% / 41%
Просрочено
14
2%
Загружен
21
Разработчик 21
Оценка
(258)
Проекты
269
29%
Арбитраж
1
100% / 0%
Просрочено
3
1%
Работает
Опубликовал: 2 примера
22
Разработчик 22
Оценка
(9)
Проекты
16
19%
Арбитраж
2
0% / 50%
Просрочено
3
19%
Загружен
23
Разработчик 23
Оценка
Проекты
0
0%
Арбитраж
0
Просрочено
0
Свободен
24
Разработчик 24
Оценка
(10)
Проекты
14
43%
Арбитраж
0
Просрочено
3
21%
Свободен
25
Разработчик 25
Оценка
(22)
Проекты
28
7%
Арбитраж
9
33% / 33%
Просрочено
1
4%
Работает
26
Разработчик 26
Оценка
(1)
Проекты
1
100%
Арбитраж
1
0% / 0%
Просрочено
0
Работает
Опубликовал: 24 статьи, 6 примеров
Похожие заказы
Indicador Maximas e Minimas + Super Trend O Indicador MAX/MIN é um indicador de análise técnica para o MetaTrader 5 , desenvolvido para ajudar você a identificar regiões importantes de preço e possíveis oportunidades de compra e venda. O que ele faz MAX/MIN: identifica máximas e mínimas relevantes do mercado e mostra os preços no gráfico. HH / HL / LH / LL: ajuda a visualizar a estrutura do mercado, mostrando quando
Hello Traders, Have a trading strategy or idea you want to automate? I specialize exclusively in MQL5 development, helping traders turn their concepts into professional trading solutions. Custom Expert Advisors — automate your strategy and reduce manual execution Custom Indicators — transform your market ideas into powerful trading tools Fix & Debug — identify errors and get your existing code working properly
I DO NOT need any programming or strategy development. I already have a working NinjaTrader 8 automated strategy based on a 3/5 EMA crossover. I need you to run my existing strategy through NinjaTrader Strategy Analyzer/Optimizer, test the existing adjustable parameters, and find robust settings with the best profit factor and lowest reasonable drawdown. I will provide the existing NinjaScript ZIP. I do not want the
I'm looking for an experienced developer to create an automated gold trading bot. The bot should be compatible with MetaTrader 4/5 and TradingView. Key Requirements: - Automated trading bot - Compatible with MetaTrader 4/5 and TradingView - Implement scalping and swing trading strategies Ideal Skills and Experience: - Proficiency in trading algorithms - Experience with gold trading - Familiarity with MetaTrader and
I need a robust optimization of my MT5 EA, mainly for XAUUSD (Gold). Please optimize the existing adjustable parameters such as entry/exit settings, SL/TP, trailing/break-even settings, and any other strategy parameters that are appropriate. I want the optimization focused on stable profitability, low/moderate drawdown, and robustness rather than simply the highest possible profit. Please use out-of-sample testing
NinjaTrader 8 / NinjaScript Phase 1 build: convert an existing Auction Market Theory (AMT) strategy into objective, alert-only decision-support logic. Not a bot, no auto-execution — trades stay manual. Covers NQ/MNQ, ES, CL, MGC using 30-min TPO/Volume Profile context with 5-min confirmation: one 5-min close outside VAH/VAL = acceptance, close back inside = rejection. Dashboard shows bias, auction state, location
Hello, I need a custom NON-REPAINT MT5 indicator that gives sell/buy arrow signals 1–2 candlesticks before a spike on Crash and boom indices respectively occurs. Requirements: Works perfectly on MT5 Shows arrows before the spike (1–2 candles earlier). Non-repaint – once the arrow appears, it must stay. Should be accurate, not quantity — only quality signals. Must work on both demo and live accounts. I want the
Hello, I saw an indicator on TradingView and would like to know if you will be able to convert it for use on Thinkorswim platform? Thanks. if anyone can help me with it kindly do well to bid it urgent thanks looking forward too see you
calcVolume( void ) { //--- MqlRates rates[]; if ( CopyRates ( _Symbol , PERIOD_CURRENT , startTime, endTime, rates) > 0 ) { double rangeHigh = rates[ 0 ].high, rangeLow = rates[ 0 ].low; int count = MathAbs ( iBarShift ( _Symbol , PERIOD_CURRENT , startTime) - iBarShift ( _Symbol , PERIOD_CURRENT , endTime)) + 1 ; //---VERTICAL PRICE RANGE for ( int b = 0
Create an MT5 Expert Advisor (EA) for trading Gold (XAUUSD). The EA should provide BUY and SELL signals based on trend direction, market momentum, and price action. It should automatically place trades only when the entry conditions are met. Risk management: Use a small adjustable lot size. Include Stop Loss (SL) and Take Profit (TP). Include a maximum daily loss limit. Include a maximum number of open trades. Do not

Информация о проекте

Бюджет
30 - 100 USD