I need a simple EA program based on RVI study (calculations included). The original program was written in Thinkscript. I need that converted to MQL4

MQL4 Esperti

Specifiche

Hi,  I need an EA based on the following thinkscript program. The program is simple and self explanatory. Let me know if there are any questions.  I will need the actual script of the program so that I can  modify it.  

 Thank you. 

Input RVIlength =2;

Input Investment = 1000;

input No_Share_To-Buy =  Investment /close;


def highPrice = StDev(high, 2);

def lowPrice = StDev(low, 2);
def highAvgUp = ExpAverage(if high > high[1] then highPrice else 0, RVIlength);
def highAvgDown = ExpAverage(if high < high[1] then highPrice else 0, RVIlength);
def lowAvgUp = ExpAverage(if low > low[1] then lowPrice else 0, RVIlength);
def lowAvgDown = ExpAverage(if low < low[1] then lowPrice else 0, RVIlength);
def highRVI = 100 - 100 / (300 + highAvgUp / highAvgDown);
def lowRVI = 100 - 100 / (300 + lowAvgUp / lowAvgDown);
def RVI = (highRVI + lowRVI) / 2;

 

//the following  is a simple moving average//

def AVGRVI =  (MovingAverage(data = RVI, length =RVIlength));

def AvgRVI_V = if AVGRVI[-1]-AVGRVI>0 and AVGRVI-AVGRVI[1]<0 then 1 else 0;

def AvgRVI_H = if AVGRVI[-1]-AVGRVI<0 and AVGRVI-AVGRVI[1]>0 then 1 else 0;

def AVGRVI_Slope_Up = if AVGRVI-AVGRVI[1] >0 then 1 else 0;

def AVGRVI_Slope_down = if AVGRVI-AVGRVI[1] >0 then 1 else 0; 

/////////////////////////////////////////////////////////////////////////////////////////////////////// 

//And here are the Buy to Open (BTO), Sell to Close (STC) and STO and BTC sell signals:

def BTO = if AvgRvi_Valley==1 and AVGRVI_Slope_Up==1  then 1 else 0;

def STC = if  AvgRvi_hill==1   then 1 else 0;

def STO = if AvgRvi_hill[1]==1  and AVGRVI_Slope_Down==1  then 1 else 0;

def BTC = if AvgRvi_Valley[-1]==1 then 1 else 0;

//Please note that every STO is exactly one tick after the STC and every BTO is exactly one tick following the BTC (ie, the entire pairs chart is divided into buy or sell with no gaps in between unless the sale is going in the wrong direction within 3 ticks of the purchase. In other words, if the BTO doesn't generate a profit of any amount within the first three ticks, I'd take the loss in that trade and close the position. Same thing for STO positions. That too needs to lead to a positive P&L within the first three ticks (I don't care if after the third tick it doesn't generate a positive P&L-as a matter of fact, I would like the program to disregard the P&L past the first three ticks and not to close the position). The way I programmed that in Thinkscript is to assign a Timer to keep track of the P&L within only the first three ticks of any new BTO or STO signals.  IN MQL there may be easier ways to accomplish this than in thinkscript, but the following is my explanation of my workaround this issue which may help. 

 //The following will keep track of how many ticks has passed since the position was first opened regardless of how many more open signals are generated between that time and the time this trade position is closed  

Def BTO/STO_Timer = if (BTO ==1 or STO==1) then BTO/STO_Timer[1]+1 else if (STC ==1 or BTC==1) then 0 else BTO/STO_Timer[1]+1

//the following will remember the opening price of each position regardless of how many more Open signals are generated between that time and the time this trade position is closed  

Def BTO/STO_Price = if (BTO == 1 or STO ==1)  then Close else if (STC == 1 or BTC==1) then 0 else BTO/STO_Price[1];

//the following will generate the close signals if the P&L within the first three ticks of the new position is not going in the right direction.   

def StopLoss_STC = if BTO_Price > close and BTO[3]==1 and BTO/STO_Timer[3]<3 then 1 else  0;

def StopLoss_BTC = if STO_Price < close and STO[3] ==1 and BTO_Timer[3]<2 then 1 else 0;

  /////////////////////////////////////////////////////////////////////////////////////////////////////

//Lastly I need to Generate the BTO  and STO...  signals to auto_purchase the number of units as calculated in  "No_Share_To-Buy" with the signal above,

//I  need to generate STC  signal which closes the position  with either STC or StopLoss_STC

// and  to generate BTC  signal which closes the position with either BTC or StopLoss_BTC

 

BTW, I don't care if the program is in MQL4 or MQL5. Whichever is more convenient. 

Thank You,


David 

Con risposta

1
Sviluppatore 1
Valutazioni
(195)
Progetti
395
28%
Arbitraggio
155
20% / 52%
In ritardo
112
28%
Gratuito
2
Sviluppatore 2
Valutazioni
(46)
Progetti
73
16%
Arbitraggio
13
8% / 92%
In ritardo
37
51%
Gratuito
Ordini simili
Project Overview We are seeking an experienced MetaTrader 5 (MT5) / MQL5 developer to design and build a production-ready Expert Advisor intended for live trading with capital at risk . This is not a hobby, experimental, or retail-grade EA. We are only interested in developers with proven experience delivering robust, well-tested MT5 systems . Project Objective Design and implement a high-quality MT5 Expert Advisor
Updated Freelance Job Instruction (Copy-Paste Ready) Description: Hello, I need a simple, secure MT4 Expert Advisor (pure MQL4, NO DLLs ) that protects my XAUUSD trading by instantly closing any new position opened by another EA (identified by magic number) when price is inside user-defined "block zones", and then enforces a cooldown period before allowing the next position from that EA. This is for risk management
I need someone to build a Telegram bot signal provider for IQ Option that works like this: 🔔 NEW SIGNAL! 🎫 Trade: 🇬🇧 GBP/USD 🇺🇸 (OTC) ⏳ Timer: 2 minutes ➡️ Entry: 5:29 PM 📈 Direction: BUY 🟩 ↪️ Martingale Levels: Level 1 → 5:31 PM Level 2 → 5:33 PM Level 3 → 5:35 PM Requirements: The bot should send signals automatically to Telegram. Must support multiple trades and martingale levels. I will test it for 3 days
Hi guys, — I’m looking to purchase an existing Expert Advisor with source code . Serious enquiries only, please. Below are my requirements: Mandatory requirements Source code required (full .mq5 , readable & well-commented preferred) Backtest period: 4 years — Jan 1, 2022 → Dec 31, 2025 (tick/data quality must be stated) Demo test: 1 month on a live/demo broker after backtest passes Target performance: ~15%
As in tittle, I need opening range breakout profitable EA, you mabe have ready made? If not we can create such EA together. Rules are Simple, I have programmed this EA, my budget is 30 USD
EA Development Request: Multi-Zone AutoTrading Blocker for MT4 (XAUUSD Focused) Description: Hello Freelancers, I'm a disciplined gold trader based in Canada, focusing on XAUUSD with a strong emphasis on risk management. I need a simple, bulletproof MT4 EA that disables AutoTrading (turning the button red) when price is inside any of 10 user-defined "block zones" to prevent any new positions from opening (from other
I am hiring an experienced MT4/MT5 EA developer to build a prop firm and personal account Expert Advisor for US30 and XAUUSD . The EA must be non-martingale , low drawdown , and designed for consistent profitability with strict risk control. Markets & Platform • Instruments: US30 and XAUUSD • Platform: MT4 or MT5 • EA must support .set file configurations Trading & Risk Requirements • Non-martingale • No
Hello, I am looking to purchase an existing MT5 Expert Advisor, specifically designed for scalping XAUUSD (Gold), with the following clear requirements: Core Requirements Instrument: XAUUSD (Gold) Timeframe: M1 or M5 Style: Real scalping with controlled risk No martingale / no grid strategies Stop Loss mandatory, proper risk management included EA must be already functional and ready to attach to the chart (not
I am looking for a trading robot with a similar strategy. I will buy a script that works similarly. Please send a description of how the script works or a test version in the message
Expert Advisor 35+ USD
Hello, I have an MT5 Expert Advisor that compiles successfully with no errors, but it does not open any trades in live market or Strategy Tester. The EA logic is already implemented and quite detailed. I need an experienced MQL5 developer to debug, validate conditions, and fix execution issues, not to redesign the strategy. 🔹 Strategy Summary Timeframe: M30 Instruments: NAS100 / XAUUSD Core Logic: Market structure

Informazioni sul progetto

Budget
20 - 100 USD
Scadenze
da 1 a 3 giorno(i)