Support Resistance EA with martingale

MQL4 Experten

Spezifikation

Ø  Section 1 – Indicator script (Note that this section 1 script is important for the EA describe in Section 2 below)

This indicator script outputs the following variable:

PriceHighBox = #Price_level

PriceLowBox = #Price_level

SRBox = up or down

Draw red and blue dots to indicate support and resistance

Valid scenario A:

A peak has to rise up and down in price by Y amount of pips (user input). Vice versa for support.

[A: The highest price of 3 peaks (for uptrend; 3 peaks cannot be consecutively higher) with [B: one identified support or resistance] that has a [C: clearance more than X pips]. Draw [D: blue dot (below low)] and [E: red dot (above high)] on chart. (see graphic below)

 

 Valid scenario B:

[A: The Lowest price of 3 supports (for downtrend; 3 supports cannot be consecutively lower) with [B: one identified peak] that has a [C: clearance more than X pips]. Draw [D: blue dot (below low)] and [E: red dot (above high)] on chart. (see graphic below)

 

 Valid scenario C:

[A: The highest price of 3 peaks (for downtrend; 3 peaks cannot be consecutively lower) with [B: one identified support] that has a [C: clearance more than X pips]. Draw [D: blue dot (below low)] and [E: red dot (above high)] on chart. (see graphic below)

 

 Valid scenario D:

[A: The Lowest price of 3 supports (for uptrend; 3 supports cannot be consecutively higher) with [B: one identified peak] that has a [C: clearance more than X pips]. Draw [D: blue dot (below low)] and [E: red dot (above high)] on chart. (see graphic below)

 

 When the indicator becomes invalid

Invalid scenario A:

 

Invalid scenario B:

 

Invalid scenario C:

 

 Invalid scenario D:

 

 

Ø  Section 2 – EA Program:

PairSpread          //Fixed spread of instrument input by user
SRBox  
ExistingTrade = False      //At the start of the program, existing trade will be false i.e. none. It has 3 states: None, Long, Short

SupportPrice = 0               //Lowest price as determined by SRBox indicator
ResistancePrice = 0         //Highest price as determined by SRBox indicator
PercentTriggerBuffer     //Percent input by user to be applied on SupportPrice and ResistancePrice to determine stop trigger//

TriggerBuffer     //TriggerBuffer = PercentTriggerBuffer * (ResistancePrice –SupportPrice)

SplitBlock            //Dividing the whole box including two sides of the buffer by 10, SplitBlock = [(ResistancePrice – SupportPrice) + 2*TriggerBuffer]/10

PF[1] = 5, PF[2] = 6, PF[3] = 6, PF[4] = 6, PF[5] = 6, PF[6], PF[7] = 7, PF[8] = 8, PF[9] = 9, PF[10] =10 //Number input by user for target profit calculation

BStop[1]              // First trade: Buy stop order, BStop1 = ResistancePrice + TriggerBuffer + PairSpread;
BStopSLoss[N]  // Stop loss for first trade: BStopSLoss [N]= BStop1 – N*SplitBlock
SStopSLoss[N]   // Stop loss for first trade: SStopSLoss [N]= BStop1 + N*SplitBlock
BTargetProfit[N]// Buy target profit for first trade: BTargetProfit[1] = PF[1]*SplitBlock + PairSpread

PercentRisk[1], PercentRisk[2], PercentRisk[3], PercentRisk[4], PercentRisk[5], PercentRisk[6], PercentRisk[7], PercentRisk[8], PercentRisk[9], PercentRisk[10]
//User input on percentage in decimals to indicate how much capital to risks, use to calculate lot size

N = 1                      // number of trade
LotSize1               // Lot size calculation based on PercentRisk1 of capital
MarketBuy2       // 2nd trade which is a market buy

Ø  Process 1: SRBox Script from Section to assign support and resistance price

//Identify latest valid SR box for both up and down based on rule describe in section 1.

Use indicator from section 1

PriceHighBoxUp = #Highest price of the up box
PriceLowBoxUp = #Lowest price of the up box
PriceHighBoxDown = #Highest price of the Down box

PriceLowBoxDown = #Lowest price of the Down box

 

 

SplitBlockUpNew = [(PriceHighBoxUp – PriceLowBoxUp)*(1+ PercentTriggerBuffer)]/10
SplitBlockDownNew = [(PriceHighBoxDown – PriceLowBoxDown) *(1+ PercentTriggerBuffer)] /10

Ø  Process 2: Calculate Buy and Sell stop level, stop loss and target profit (for both long and short)

ResistancePrice = PriceHighBoxUp
ResistanceBasePrice = PriceLowBoxUp

SupportPrice = PriceLowBoxDown
SupportBasePrice = PriceHighBoxDown

BStop[1] = ResistancePrice + TriggerBuffer + PairSpread;
BTargetProfit[1] = BStop[1] + PF[1]*SplitBlock + PairSpread
BStopSLoss[1] = BStop[1] – SplitBlock

SStop[1] = SupportPrice - TriggerBuffer;
STargetProfit[1] = SStop[1] – (PF[1]*SplitBlock + PairSpread)
SStopSLoss[1]= SStop[1] + SplitBlock

 

Ø  Process 3: Activate price levels (for both long and short)

If [ExistingTrade != long]
{BuyStop @ BStop[1] with Stop Loss @ BStopSLoss[1] and BTargetProfit[1]; LotSize[1]

IF BStop[1] is executed, CLOSE previous short trade if exists, ExistingTrade = long, N=1} 


If [ExistingTrade != short]
{SellStop @ SStop[1] with Stop Loss @ SStopSLoss[1] and STargetProfit[1]; LotSize[1]

IF SStop[1] is executed, CLOSE previous long trade if exists, ExistingTrade = short, N=1}


Ø  Process Step 4: Activate Martingale for orders taken

//If the first trade is taken and stop loss of first trade is hit, continue taking trade in the same direction but martingale the risks. Take trade in the same direction only up to a maximum of 10 times.

If ExistingTrade = Long && If BStopSLoss[N] is hit && N <=10, N++
{ BStop[N] = ResistancePrice + N*TriggerBuffer + PairSpread;
BTargetProfit[N] = BStop[N] + PF[N]*SplitBlock + PairSpread
BStopSLoss[N] = BStop[N] – SplitBlock
MarketBuy[N] with BStopSLoss[N], BTargetProfit[N], LotSize[N]}

If ExistingTrade = short && If SStopSLoss[N] is hit && N <=10, N++
{ SStop[N] = SupportPrice - TriggerBuffer;
STargetProfit[N] = SStop[N] – (PF[N]*SplitBlock + PairSpread)
SStopSLoss[N]= SStop[N] + SplitBlock
MarketSell[N] with SStopSLoss[N], STargetProfitN], LotSize[N]}

Ø  Process Step 5 (Final): Reset everything

If Target profit is hit, N = 0, ExistingTrade = False

End. 

Bewerbungen

1
Entwickler 1
Bewertung
(218)
Projekte
404
60%
Schlichtung
13
38% / 23%
Frist nicht eingehalten
160
40%
Frei
2
Entwickler 2
Bewertung
(90)
Projekte
159
61%
Schlichtung
40
18% / 63%
Frist nicht eingehalten
70
44%
Frei
Ähnliche Aufträge
I have a custom EA that works fine in the live market trading, but when doing a back test in the strategy tester , it does not open sell orders. There are no errors or warnings; it just doesn't open sell orders. I've checked every possible reason that might be the reason why it does not open sell orders, but I can't find anything, especially since it works fine in the real market and it opens both buys and sells
The Expert Advisor would use two built-in indicators as entry/exit signals and our own risk management strategy with customizable inputs. The goal is to create a reliable and efficient trading tool that can automate our trading process on the MT5 platform
Hi, I have an indicator from my friend, I want to copy it to my own MT5 can you do that for me. Here is the link
I installed the E.A. into the Experts folder in MT4. When I double click on it nothing happens. When I right click and "attach to chart" nothing happens. The E.A. is not grayed out, it simply will not attach. Any help would be greatly Appreciated
I have an EA and want to add few new logic to fetch profit taking factors and other values from an external master data and use it in existing EA
Hello Every one, Good day, I want from someone professional to create an EA is working on Mt5, This EA is working by depend on some indicators, and all those indicators must be working on MACD window, not on the chart, for more details please read my attached pdf file carefully. Many Thanks
I'm looking for an expert MQL5 developer that can create an EA that's based on my price action trading strategy with no indicators. The EA must analyze trades based on my price action rules, enter trades based on my price action rules, manage trades based on my price action rules and exit trades based on my price action rules
hi hi there i have an strategy on tradingview and i want to automate it like metatrader EA so i want the strategy to open and close trade automaticlly on tradingview
We are looking for an experienced Expert Advisor Developer who can build a customized MT5 Expert Advisor for us. The Expert Advisor would use two built-in indicators as entry/exit signals and our own risk management strategy with customizable inputs. The goal is to create a reliable and efficient trading tool that can automate our trading process on the MT5 platform. Skills required: - Strong understanding of
I need stochastic div (hidden &regular ea) that should perform task in all tf's ..divergence is a repaint stly so i want to use it with candlestick flips .. so bet for it

Projektdetails

Budget
30 - 80 USD
Für die Entwickler
27 - 72 USD
Ausführungsfristen
von 3 bis 8 Tag(e)