Support Resistance EA with martingale

MQL4 Asesores Expertos

Tarea técnica

Ø  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. 

Han respondido

1
Desarrollador 1
Evaluación
(219)
Proyectos
405
60%
Arbitraje
13
38% / 23%
Caducado
160
40%
Libre
2
Desarrollador 2
Evaluación
(90)
Proyectos
159
61%
Arbitraje
40
18% / 63%
Caducado
70
44%
Libre
Solicitudes similares
Creating of an expert advisor or trading bot that uses a Top Down analysis (using monthly, weekly, daily, hourly, minutes ( 30, 15, 5, 1) to determine trade direction or trend direction and makes multiple trade decisions for mt4. You can use or combine accurate trend indicators
Creating of an expert advisor or trading bot that uses a Top Down analysis (using monthly, weekly, daily, hourly, minutes ( 30, 15, 5, 1) to determine trade direction or trend direction and makes multiple trade decisions for mt4. You can use or combine accurate trend indicators
Hello The EA will work on particular zone choose by the user and can mark it on any TF and with some rules can open trades and mange the trade by some unique rules. the EA need to check the difference by RSI as well and with some extra rules . developer should have good attitude and good communication (englsih) with high performence and knowledge with coding EA
I am looking forward to automate my trading strategy where I use renko bars on Tradingview. I really want to use unirenkos too, but unfortunately I couldn't figure out how to use ninjatrader on my MacBook and Tradingview does not offer unirenkos. As far as I see from your offered services you are very familiar with ninjatrader. I wanted to ask you if you could code me an Indicator for unirenkos for Tradingview so I
I am looking forward to automate my trading strategy where I use renko bars on Tradingview. I really want to use unirenkos too, but unfortunately I couldn't figure out how to use ninjatrader on my MacBook and Tradingview does not offer unirenkos. As far as I see from your offered services you are very familiar with ninjatrader. I wanted to ask you if you could code me an Indicator for unirenkos for Tradingview so I
Hello The EA will work on particular zone choose by the user and can mark it on any TF and with some rules can open trades and mange the trade by some unique rules. the EA need to check the difference by RSI as well and with some extra rules . developer should have good attitude and good communication (englsih) with high performence and knowledge with coding EA
Hello, I want to create an EA that can be able to take and optimise trade bids using the trend tracker concept I have developed. The tracker will monitor 2 lines to determine the trend of the market and afterwards take bids towards the correct direction. It will also be able to use a distance between the bids for the direction of the trend and plan a reverse bid when the price of the extreme doesn’t change again. The
Gradient boosting and L2 100 - 200 USD
I am looking for a well experienced programmer to put/implement a gradient boosting algorithm and an L2 to reduce overfitting in my ea which l already have which uses indicators . If you are experienced please adhere
Hello, I'm looking for a developer for repair calendar in EA MT4/MT5 (News Filter - https://ec.forexprostools.com ) for all windows servers. Note: EA MT4/MT5 works with calendar on PC Win 10, 11 but not on all windows servers. I have the source code and will post within the comments section for review. If you are able to do this and quality. Please apply. Thanks
Create mt4 ea 50+ USD
To convert the provided MT4 indicator script into an Expert Advisor (EA) and implement prompt functionality for user input, we need to modify the code to handle external parameters and provide a user-friendly interface. Below is the EA code that incorporates prompts for user inputs

Información sobre el proyecto

Presupuesto
30 - 80 USD
Para el ejecutor
27 - 72 USD
Plazo límite de ejecución
de 3 a 8 día(s)