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 Uzman Danışmanlar

İş Gereklilikleri

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 

Yanıtlandı

1
Geliştirici 1
Derecelendirme
(195)
Projeler
395
28%
Arabuluculuk
155
20% / 52%
Süresi dolmuş
112
28%
Serbest
2
Geliştirici 2
Derecelendirme
(46)
Projeler
73
16%
Arabuluculuk
13
8% / 92%
Süresi dolmuş
37
51%
Serbest
Benzer siparişler
I would like an EA that follows exactly this steps to trade de daily candle. Watch the video and then see if you can do the task. https://www.youtube.com/watch?v=g3oDYq4P9ZE Document is one this link https://cdn.discordapp.com/attachments/1135977927469703230/1135978751461695598/Daily_Bias-TTrades_edu.pdf?ex=669a9a27&amp ;is=669948a7&hm=96de195f7e695a381c1261b065f67b94fae319d02a0c88641b146f8b2978320c& Should have
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

Proje bilgisi

Bütçe
20 - 100 USD
Geliştirici için
18 - 90 USD
Son teslim tarihi
from 1 to 3 gün