.ex4/.ex5 files can't be fixed or modified / I'm not a coder!
Similar Threads
I will code your pivot EAs for no charge 28 replies
I will code your scalping EAs for no charge 163 replies
Oanda MT4 - Indicators and EAs not showing 2 replies
EAs and indicators relating to moutaki... 22 replies
InterbankFX has loaded its MT4 platform with custom EAs, indicators and scripts 1 reply
- #79,922
- Edited 11:22am Oct 23, 2025 10:44am | Edited 11:22am
Disliked{quote} if(type==long || type==both) vs if(type!=short) I'd generally recommend the first one, it's self documenting, more scalable with simpler enum updates, and more readable because it's checking what's included, rather than checking what's excluded, it'd be a niche case I'd go with the second. For this specific case, depending on my mood I'd go with the second. {quote} Many? Since the difference is in nanoseconds and possibly none depending on how it's compiled, other than iterations in the millions or billions every tick or a 1ms timer doing...Ignored
It's funny that you jumped on this, focusing entirely on the specific example. Looking at the specific example, my comment would have been meaningless, since it was only about 1-2 "ifs." You should think a little before jumping on the snot.
As for the practical side of things, 99 percent of the dashboards on FF are completely useless because poorly written code eats up the CPU and causes the terminal to stutter.
My dashboards, on the other hand (despite having many more features), are light as a breeze and fast as the wind. They are completely CPU-friendly (as far as possible within the limited capabilities of MT4 - one CPU-thread only), I know this myself and I get a lot of private feedback about it.
So I'm not just talking smart with AI behind my back, I'm putting efficiency into practice. Do you too?!
(Of course, I have to admit that your ON/OFF buttons are incredibly fast. LOL)
I would have been completely surprised if sneakylouie hadn't come here to talk smart. Again, as always.
- #79,923
- Oct 23, 2025 11:58am Oct 23, 2025 11:58am
- Joined Mar 2022 | Status: Trader | 6,558 Posts
Statistically both operations take about 1.8 nanoseconds per iteration.
The difference, though exists, is on the level of 0.0x nanoseconds per iteration.
The difference, though exists, is on the level of 0.0x nanoseconds per iteration.
Inserted Code
ulong start, elapsed;
start = GetMicrosecondCount();
for(int i=0;i<100000000;i++) if(PositionType == Long || PositionType == Both) continue;
elapsed = GetMicrosecondCount() - start;
Print("== version: ", elapsed);
start = GetMicrosecondCount();
for(int i=0;i<100000000;i++) if(PositionType != Short) continue;
elapsed = GetMicrosecondCount() - start;
Print("!= version: ", elapsed); .ex4/.ex5 files can't be fixed or modified / I'm not a coder!
- #79,924
- Oct 23, 2025 1:42pm Oct 23, 2025 1:42pm
- Joined Jun 2012 | Status: Trader , Analyst and Mentor | 5,884 Posts
Disliked{quote} there is nothing in the pictures that explains where the horizontal arrow should be placed. The second picture has two horizontal arrows; the first one from left (the one almost in the middle of the picture) has the arrow at the close of bar1, while the next one has it at the open of bar2. We also cannot say the highest of the two bars. Assuming that you define your engulfing bars based on the body, with bar0 being the bar on which we can see and evaluate the previous bars (bar1 and bar2) to see if they meet the conditions, will the following...Ignored
Say something meaningful or Silence!!
- #79,925
- Oct 23, 2025 4:03pm Oct 23, 2025 4:03pm
- Joined Dec 2010 | Status: Trader | 2,136 Posts
QuoteDislikedThe fact is that my statement was general in nature, namely that you should always strive to write the most efficient code possible...It's funny that you jumped on this, focusing entirely on the specific example
You have a valid point, but for the reasons stated I wouldn't go with it for the most part, micro optimization also takes attention away from actual sources of performance load like redundant processes which would have million x greater effect.
I recall the coding priorities as, make something that works, then tidy it, then make it faster. A micro optimization is at the far end of that last step, and can come with tradeoffs mentioned.
QuoteDislikeddespite having many more features...are light as a breeze and fast as the wind
Only since you're boasting quite colorfully, at least for the scanners, I think they could be made much faster on fresh loading and way more on tf changing. They also turn off a chart property in a case which can affect other indicators (I'm reminded of you claiming issues are caused by other's poor coding). The show/hide relies on object deletion/creation, which is a perfectly acceptable approach, but if you were going for "the most efficient code possible", then I would have thought doing 1 operation is faster than about 10 new ones for every object, and the panel dragging can be quite choppy, and they still dont remember their position on template loading. Now none of these are serious issues in any way, the indicators are good, but they could be improved for the sake of being "most efficient/light as a breeze/fast as the wind". That colorful boasting combined with disparaging others, is, quite a handful.
In no way am I claiming or implying everything I make is amazing, there are issues to be found and always room for improvement, I'm no stranger to it.
QuoteDislikedI would have been completely surprised if sneakylouie hadn't come here to talk smart
- #79,926
- Oct 23, 2025 4:19pm Oct 23, 2025 4:19pm
- Joined Jun 2012 | Status: Trader , Analyst and Mentor | 5,884 Posts
Disliked{quote} hi classy try this . This is indicator not script. Important " click on candle you want to show hloc" use key "x" for delete. Sorry for my english hi aydn24 i upload on this thead {file} {file}Ignored
Say something meaningful or Silence!!
- #79,927
- Edited Oct 24, 2025 10:33am Oct 23, 2025 5:38pm | Edited Oct 24, 2025 10:33am
Once again, you've made big claims that you can't back up with anything.
Much faster?! Total nonsense. This is the fastest possible. Objects are created only once, after which only their properties are updated in a very efficient manner. Cannot be faster at all. Not in MT4.
Years ago, I discovered that CHART_EVENT_MOUSE_MOVE was set to false by default and had to be enabled programmatically. It seems that MetaQuotes changed this to true during one of their updates, but of course, they didn't mention this in any of their documentation (as usual). So I learned not to leave this to chance in my own programs and to handle the switching on and off myself. Everyone should do this because it is something you can influence (unlike when someone uses ObjectsDeleteAll() or GlobalVariablesDeleteAll(), because you can't do anything about that).
This case is a good example of why everything possible should be handled in our own programs, so that there are no surprises.
It is not choppy at all, basically. It only becomes slightly choppy when there are too many visual objects on the charts (I drew attention to this in the description), but this is a shortcoming of MT4, as 1./ it is not optimized in terms of graphics, and 2./ it can only use a single thread. I always have at least 10-12 panels open, and I don't notice any annoying choppiness during movement, although my computer is not a power plant.
(Sometimes, during breaking news, the number of incoming ticks can jump to several times the usual amount for a short period of time, causing the entire MT4 to slow down. This is also due to the single-thread bottleneck.)
This is at least the third or fourth time I've asked you: how? Show me how this can be solved. I don't think it can, but I'm waiting for your solution (still).
My thoughts on this matter are here and here. Come on, show us!
What hypocrisy! Don't expect me to use a "civil" tone anymore (which I did at first), because for some time now, you've been making nothing but provocative, taunting comments, all hidden behind a mask of appearance of objectivity. To be honest, I'm really fed up with you.
I'm wasting too much time on you, and it bothers me.
DislikedI think they could be made much faster on fresh loading and way more on tf changing ... The show/hide relies on object deletion/creation, which is a perfectly acceptable approach, but if you were going for "the most efficient code possible", then I would have thought doing 1 operation is faster than about 10 new ones for every objectIgnored
DislikedThey also turn off a chart property in a case which can affect other indicators (I'm reminded of you claiming issues are caused by other's poor coding).Ignored
This case is a good example of why everything possible should be handled in our own programs, so that there are no surprises.
(Sometimes, during breaking news, the number of incoming ticks can jump to several times the usual amount for a short period of time, causing the entire MT4 to slow down. This is also due to the single-thread bottleneck.)
My thoughts on this matter are here and here. Come on, show us!
DislikedIt is possible for others to have a reasoned and different opinion to something you say, they're not jabs, you can still be civil.Ignored
I'm wasting too much time on you, and it bothers me.
1
- #79,928
- Oct 23, 2025 10:48pm Oct 23, 2025 10:48pm
- Joined Dec 2010 | Status: Trader | 2,136 Posts
QuoteDislikedThis is the fastest possible
QuoteDislikedObjects are created only once, after which only their properties are updated in a very efficient manner
QuoteDislikedCHART_EVENT_MOUSE_MOVE was set to false by default...It seems that MetaQuotes changed this to true during one of their updates
I also handle its state manually, but typically only once in oninit, I haven't found it to be common that other indicators turn it off while running. I know that of course still leaves the potential for other programs to turn it off like yours, similar to what you experienced with objectdeleting and global variables issues. I'd have to add a tiny bit extra to accommodate you turning it off, I'm not going to disparage you about it, but it is still affecting other programs eg you could opt to only turn it off if it was off to begin with.
QuoteDislikeda good example of why everything possible should be handled in our own programs, so that there are no surprises
QuoteDislikedIt only becomes slightly choppy when there are too many visual objects on the charts
QuoteDislikedThis is at least the third or fourth time I've asked you: how?
QuoteDislikedyou've been making nothing but provocative, taunting comments
So ok other than 1 sarcastic comment which I'm sure you can walk off, comments are context adding or rebuttals to overt boasting, "most efficient/light as a breeze/fast as the wind"+disparaging others+several obvious improvements that could be made (for "efficiency" and "speed", if you're so focused on that and call others out on it).
- #79,929
- Oct 23, 2025 10:50pm Oct 23, 2025 10:50pm
- Joined Dec 2010 | Status: Trader | 2,136 Posts
Disliked{quote} tt bro is not available so my humble request to all master coder if possible please code one indicator same as click to ohlc but with option to change line color style like thick/thin/solid .thanksIgnored
1
- #79,930
- Edited Oct 24, 2025 12:23am Oct 23, 2025 11:43pm | Edited Oct 24, 2025 12:23am
- Joined Jun 2012 | Status: Trader , Analyst and Mentor | 5,884 Posts
Disliked{quote} As in, click a candle to show ohlc prices as texts on the candle, or put level lines on the ohlc prices of a selected candle?Ignored
Say something meaningful or Silence!!
- #79,931
- Oct 24, 2025 1:33am Oct 24, 2025 1:33am
- Joined Jun 2013 | Status: enjoying life | 23,842 Posts
kindly convert this code into standalone indicator to update ontick
Inserted Code
//+------------------------------------------------------------------+
//| ProjectName |
//| Copyright 2018, CompanyName |
//| http://www.companyname.net |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| ELIOT WAVE |
//| https://5d3071208c5e2.site123.me/ |
//+------------------------------------------------------------------+
#property copyright "AHARON TZADIK"
#property link "https://5d3071208c5e2.site123.me/"
#property version "1.00"
#property strict
extern bool Use_TP_In_Money=false;
extern double TP_In_Money=10;
extern bool Use_TP_In_percent=false;
extern double TP_In_Percent=10;
//--------------------------------------------------------------------
//--------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////
input string txt32 = "------------[Money Trailing Stop]---------------"; //———————————————————————————————————————————
input bool Enable_Trailing = true; //Enable_Trailing
input double Take_Profit_Money = 40.0; //Take Profit In Money (in current currency)
input double Stop_Loss_Money = 10; //Stop Loss In Money(in current currency)
/////////////////////////////////////////////////////////////////////////////////
//---------------------------------------------------------------------------------
//--------------------------------------------------------------------
input color Color_UPLine=clrYellow; // Color Of Sell Line
input color Color_DWLine=clrYellow; // Color Of Buy Line
extern bool Exit=false;//Enable Exit strategy
bool tick=false;//every tick\open price
extern double IncreaseFactor=0.001; //IncreaseFactor
extern int CandlesToRetrace=10; //Num.Of Candles For Divergence
extern double Lots=0.01; //Lots size
extern double LotExponent = 1.44; //Lots size Exponent
extern double TrailingStop=40; //TrailingStop
extern double Stop_Loss=20; //Stop Loss
extern int MagicNumber=1234; //MagicNumber
input double Take_Profit=50; //TakeProfit
extern int FastMA=6; //FastMA
extern int SlowMA=85; //SlowMA
extern double Mom_Sell=0.3; //Momentum_Sell
extern double Mom_Buy=0.3; //Momentum_Buy
input bool UseEquityStop = true; //Use Equity Stop
input double TotalEquityRisk = 1.0; //Total Equity Risk
input int Max_Trades=10;
extern int FractalNum=10; // Number Of High And Low
extern string desc1="========= Eliot Trend Line =====";
int InpDepth=5; // Depth
int InpDeviation = 3; // Deviation
int InpBackstep = 1; // Backstep
int ZigZagNum = 10; // Number Of High And Low
//---------------------------------------------------------------------------------
extern bool USETRAILINGSTOP=true; //IF USE TRAILING STOP
extern int WHENTOTRAIL=40;//WHEN TO TRAIL
extern int TRAILAMOUNT=40;//TRAIL AMOUNT
extern int PADAMOUNT=10;//PAD AMOUNT
extern bool USECANDELTRAIL=true;//USE CANDEL TRAIL
extern int X=3;//NUMBER OF CANDLES
//---------------------------------------------------------------------------------
extern bool USEMOVETOBREAKEVEN=true;//Enable "no loss"
extern double WHENTOMOVETOBE=30; //When to move break even
extern double PIPSTOMOVESL=30; //How much pips to move sl
int err;
int BUYSTOPCANDLE;
int SELSTOPCANDLE;
//---
int INDEX2=0;
double PROFIT_SUM1=0;
double PROFIT_SUM2=0;
int total=0;
double
Lot,Dmax,Dmin,// Amount of lots in a selected order
Lts, // Amount of lots in an opened order
Min_Lot, // Minimal amount of lots
Step, // Step of lot size change
Free, // Current free margin
One_Lot, // Price of one lot
Price, // Price of a selected order,
pips,
MA_1,MA_2,MACD_SIGNAL;
int Type,freeze_level,Spread;
//--- price levels for orders and positions
double priceopen,stoploss,takeprofit;
datetime timeTag;
//--- ticket of the current order
int orderticket;
double Linenow=0;
double Lineprev=0;
double Linenow1=0;
double Lineprev1=0;
double Linenow2=0;
double Lineprev2=0;
double Linenow3=0;
double Lineprev3=0;
//--------------------------------------------------------------- 3 --
int
Period_MA_2, Period_MA_3, // Calculation periods of MA for other timefr.
Period_MA_02, Period_MA_03, // Calculation periods of supp. MAs
K2,K3,T,L;
//---
datetime dt=0;
datetime dt1=0;
datetime dt2=0;
datetime dt12=0;
datetime dt3=0;
datetime dt13=0;
datetime dt4=0;
datetime dt14=0;
datetime prevtime;
int First_Low_Candel=0,Secund_Low_Candel=3,First_High_Candel=0,Secund_High_Candel=3,ZigHCandel[],ZigLCandel[];
double ZigZagHigh[],ZigZagLow[],LineValLow=0,LineValHigh=0;
bool DrawLine=false;
string MODE="none"; //trendLine mode
double AccountEquityHighAmt,PrevEquity;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--------------------------------------------------------------- 5 --
switch(Period()) // Calculating coefficient for..
{
// .. different timeframes
case 1:
L=PERIOD_M5;
T=PERIOD_M15;
break;// Timeframe M1
case 5:
L=PERIOD_M1;
T=PERIOD_M15;
break;// Timeframe M5
case 15:
L=PERIOD_M5;
T=PERIOD_M30;
break;// Timeframe M15
case 30:
L=PERIOD_M15;
T=PERIOD_H1;
break;// Timeframe M30
case 60:
L=PERIOD_M30;
T=PERIOD_H4;
break;// Timeframe H1
case 240:
L=PERIOD_H1;
T=PERIOD_D1;
break;// Timeframe H4
case 1440:
L=PERIOD_H4;
T=PERIOD_W1;
break;// Timeframe D1
case 10080:
L=PERIOD_D1;
T=PERIOD_MN1;
break;// Timeframe W1
case 43200:
L=PERIOD_W1;
T=PERIOD_D1;
break;// Timeframe MN
}
double ticksize=MarketInfo(Symbol(),MODE_TICKSIZE);
if(ticksize==0.00001 || ticksize==0.001)
pips=ticksize*10;
else
pips=ticksize;
return(INIT_SUCCEEDED);
//--- distance from the activation price, within which it is not allowed to modify orders and positions
freeze_level=(int)SymbolInfoInteger(_Symbol,SYMBOL_TRADE_FREEZE_LEVEL);
if(freeze_level!=0)
{
PrintFormat("SYMBOL_TRADE_FREEZE_LEVEL=%d: order or position modification is not allowed,"+
" if there are %d points to the activation price",freeze_level,freeze_level);
}
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
del();
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnTick(void)
{
TrendLine();
if(Use_TP_In_Money)
{ Take_Profit_In_Money();}
if(Use_TP_In_percent)
{ Take_Profit_In_percent();}
if(Enable_Trailing==true)
{TRAIL_PROFIT_IN_MONEY2();}
if(prevtime == Time[0])
return;
prevtime = Time[0];
// Check for New Bar (Compatible with both MQL4 and MQL5)
int ticket=0;
double AveragePrice=0;
double Count=0;
double CurrentPairProfit=CalculateProfit();
// Check for New Bar (Compatible with both MQL4 and MQL5)
static datetime dtBarCurrent=WRONG_VALUE;
datetime dtBarPrevious=dtBarCurrent;
dtBarCurrent=(datetime) SeriesInfoInteger(_Symbol,_Period,SERIES_LASTBAR_DATE);
bool NewBarFlag=(dtBarCurrent!=dtBarPrevious);
if(NewBarFlag&&tick==0)
{
if(USEMOVETOBREAKEVEN)
{MOVETOBREAKEVEN();}
adjustTrail();
}
else
{
if(USEMOVETOBREAKEVEN)
{MOVETOBREAKEVEN();}
adjustTrail();
}
if(UseEquityStop)
{
if(CurrentPairProfit<0.0 && MathAbs(CurrentPairProfit)>TotalEquityRisk/100.0*AccountEquityHigh())
{
CloseThisSymbolAll();
Print("Closed All due to Stop Out");
}
}
ticket=0;
// initial data checks
// it is important to make sure that the expert works with a normal
// chart and the user did not make any mistakes setting external
// variables (Lots, StopLoss, TakeProfit,
// TrailingStop) in our case, we check TakeProfit
// on a chart of less than 100 bars
//---
if(Bars<100)
{
Print("bars less than 100");
return;
}
if(Take_Profit<10)
{
Print("TakeProfit less than 10");
return;
}
//--- to simplify the coding and speed up access data are put into internal variables
HideTestIndicators(true);
//--------------------------------------------------------------------------------------------------
double MomLevelB=MathAbs(100-iMomentum(NULL,T,14,PRICE_CLOSE,1));
double MomLevelB1=MathAbs(100 - iMomentum(NULL,T,14,PRICE_CLOSE,2));
double MomLevelB2=MathAbs(100 - iMomentum(NULL,T,14,PRICE_CLOSE,3));
double MomLevelS=MathAbs(iMomentum(NULL,T,14,PRICE_CLOSE,1)-100);
double MomLevelS1=MathAbs(iMomentum(NULL,T,14,PRICE_CLOSE,2)-100);
double MomLevelS2=MathAbs(iMomentum(NULL,T,14,PRICE_CLOSE,3)-100);
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
double MA_1_t=iMA(NULL,T,FastMA,0,MODE_LWMA,PRICE_TYPICAL,0); // МА_1
double MA_2_t=iMA(NULL,T,SlowMA,0,MODE_LWMA,PRICE_TYPICAL,0); // МА_2
//-------------------------------------------------------------------------------------------------
//+------------------------------------------------------------------+
HideTestIndicators(false);
//-------------------------------------------------------------------------------------------------
double LineValHigh1=NormalizeDouble(ObjectGetValueByShift("ELIOT.HighLine",1),Digits);
double LineValLow1=NormalizeDouble(ObjectGetValueByShift("ELIOT.LowLine",1),Digits);
double LineValHigh2=NormalizeDouble(ObjectGetValueByShift("ELIOT.HighLine",2),Digits);
double LineValLow2=NormalizeDouble(ObjectGetValueByShift("ELIOT.LowLine",2),Digits);
//--------------------------------------------------------------------------------------------------
double LOT = Lots * MathPow(LotExponent, CountTrades());
{
//--- no opened orders identified
if(AccountFreeMargin()<(1000*Lots))
{
Print("We have no money. Free Margin = ",AccountFreeMargin());
return;
}
//--- check for long position (BUY) possibility
//+------------------------------------------------------------------+
//| BUY BUY BUY |
//+------------------------------------------------------------------+
if(CountTrades()<Max_Trades)
if(MA_1_t>MA_2_t)
if(Low[2]<High[1])
if(MomLevelB>Mom_Buy || MomLevelB1>Mom_Buy || MomLevelB2>Mom_Buy)
{
if(IsTesting()==true)
{
if((CheckVolumeValue(LotsOptimized(LOT)))==TRUE)
if((CheckMoneyForTrade(Symbol(),LotsOptimized(LOT),OP_BUY))==TRUE)
if((CheckStopLoss_Takeprofit(OP_BUY,NDTP(Bid-Stop_Loss*pips),NDTP(Bid+Take_Profit*pips)))==TRUE)
if(IsTradeAllowed())
ticket=OrderSend(Symbol(),OP_BUY,LotsOptimized(LOT),ND(Ask),3,NDTP(Bid-Stop_Loss*pips),NDTP(Bid+Take_Profit*pips),"Long 1",MagicNumber,0,PaleGreen);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
Print("BUY order opened : ",OrderOpenPrice());
Alert("we just got a buy signal on the ",_Period,"M",_Symbol);
SendNotification("we just got a buy signal on the1 "+(string)_Period+"M"+_Symbol);
SendMail("Order sent successfully","we just got a buy signal on the1 "+(string)_Period+"M"+_Symbol);
}
else
Print("Error opening BUY order : ",GetLastError());
return;
}
if(IsTesting()==false)//only in live trading we use the line
{
if((LineValLow1<LineValLow2
&& LineValHigh1<LineValHigh2))
if(!(High[iBarShift(NULL,0,dt2)]<High[iBarShift(NULL,0,dt12)]))
if((CheckVolumeValue(LotsOptimized(LOT)))==TRUE)
if((CheckMoneyForTrade(Symbol(),LotsOptimized(LOT),OP_BUY))==TRUE)
if((CheckStopLoss_Takeprofit(OP_BUY,NDTP(Bid-Stop_Loss*pips),NDTP(Bid+Take_Profit*pips)))==TRUE)
if(IsTradeAllowed())
ticket=OrderSend(Symbol(),OP_BUY,LotsOptimized(Lots),ND(Ask),3,NDTP(Bid-Stop_Loss*pips),NDTP(Bid+Take_Profit*pips),"Long 1",MagicNumber,0,PaleGreen);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
Print("BUY order opened : ",OrderOpenPrice());
Alert("we just got a buy signal on the ",_Period,"M",_Symbol);
SendNotification("we just got a buy signal on the1 "+(string)_Period+"M"+_Symbol);
SendMail("Order sent successfully","we just got a buy signal on the1 "+(string)_Period+"M"+_Symbol);
}
else
Print("Error opening BUY order : ",GetLastError());
return;
}
}
//--- check for short position (SELL) possibility
//+------------------------------------------------------------------+
//| SELL SELL SELL |
//+------------------------------------------------------------------+
if(CountTrades()<Max_Trades)
if(MA_1_t<MA_2_t)
if(Low[1]<High[2])
if(MomLevelS>Mom_Sell || MomLevelS1>Mom_Sell || MomLevelS2>Mom_Sell)
{
if(IsTesting()==true)
{
if((CheckVolumeValue(LotsOptimized(LOT)))==TRUE)
if((CheckMoneyForTrade(Symbol(),LotsOptimized(LOT),OP_SELL))==TRUE)
if((CheckStopLoss_Takeprofit(OP_SELL,NDTP(Ask+Stop_Loss*pips),NDTP(Ask-Take_Profit*pips)))==TRUE)
if(IsTradeAllowed())
ticket=OrderSend(Symbol(),OP_SELL,LotsOptimized(LOT),ND(Bid),3,NDTP(Ask+Stop_Loss*pips),NDTP(Ask-Take_Profit*pips),"Short 1",MagicNumber,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
Print("SELL order opened : ",OrderOpenPrice());
Alert("we just got a sell signal on the ",_Period,"M",_Symbol);
SendMail("Order sent successfully","we just got a sell signal on the "+(string)_Period+"M"+_Symbol);
}
else
Print("Error opening SELL order : ",GetLastError());
}
if(IsTesting()==false)//only in live trading we use the line
{
if((LineValLow1>LineValLow2
&& LineValHigh1>LineValHigh2))
if((CheckVolumeValue(LotsOptimized(Lots)))==TRUE)
if((CheckMoneyForTrade(Symbol(),LotsOptimized(Lots),OP_SELL))==TRUE)
if((CheckStopLoss_Takeprofit(OP_SELL,NDTP(Ask+Stop_Loss*pips),NDTP(Ask-Take_Profit*pips)))==TRUE)
if(IsTradeAllowed())
ticket=OrderSend(Symbol(),OP_SELL,LotsOptimized(Lots),ND(Bid),3,NDTP(Ask+Stop_Loss*pips),NDTP(Ask-Take_Profit*pips),"Short 1",MagicNumber,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
Print("SELL order opened : ",OrderOpenPrice());
Alert("we just got a sell signal on the ",_Period,"M",_Symbol);
SendMail("Order sent successfully","we just got a sell signal on the "+(string)_Period+"M"+_Symbol);
}
else
Print("Error opening SELL order : ",GetLastError());
}
//--- exit from the "no opened orders" block
return;
}
}
}
//+------------------------------------------------------------------+
//| Trailing stop loss |
//+------------------------------------------------------------------+
// --------------- ----------------------------------------------------------- ------------------------
//+---------------------------------------------------------------------------+
//| CANDLE Trailing stop loss
//+---------------------------------------------------------------------------+
void adjustTrail()// CANDLE TRAIL
{
// Check for New Bar (Compatible with both MQL4 and MQL5)
static datetime dtBarCurrent=WRONG_VALUE;
datetime dtBarPrevious=dtBarCurrent;
dtBarCurrent=(datetime) SeriesInfoInteger(_Symbol,_Period,SERIES_LASTBAR_DATE);
bool NewBarFlag=(dtBarCurrent!=dtBarPrevious);
BUYSTOPCANDLE=iLowest(Symbol(),0,1,X,0);//Lowest
SELSTOPCANDLE=iHighest(Symbol(),0,2,X,0);//Highest
//Buy
//+------------------------------------------------------------------+
//| Buy |
//+------------------------------------------------------------------+
//----------------------------------------------------------------------------------
for(int b=OrdersTotal()-1; b>=0; b--)
{
if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES))
if(OrderMagicNumber()!=MagicNumber)
continue;
if(OrderSymbol()==Symbol())//Symbol
if(OrderType()==OP_BUY)//OrderType
if(USECANDELTRAIL)
{
if(NewBarFlag)
{
RefreshRates();
stoploss=Low[BUYSTOPCANDLE]-PADAMOUNT*pips;
takeprofit=OrderTakeProfit()+pips*TRAILAMOUNT;
double StopLevel=MarketInfo(Symbol(),MODE_STOPLEVEL)+MarketInfo(Symbol(),MODE_SPREAD);
if(stoploss<StopLevel*pips)
stoploss=StopLevel*pips;
string symbol=OrderSymbol();
double point=SymbolInfoDouble(symbol,SYMBOL_POINT);
if(MathAbs(OrderStopLoss()-stoploss)>point)
if((pips*TRAILAMOUNT)>(int)SymbolInfoInteger(_Symbol,SYMBOL_TRADE_FREEZE_LEVEL)*pips)
//--- modify order and exit
if(CheckStopLoss_Takeprofit(OP_BUY,stoploss,takeprofit))
if(OrderModifyCheck(OrderTicket(),OrderOpenPrice(),stoploss,takeprofit))
if(OrderStopLoss()<Low[BUYSTOPCANDLE]-PADAMOUNT*pips)
if(!OrderModify(OrderTicket(),OrderOpenPrice(),Low[BUYSTOPCANDLE]-PADAMOUNT*pips,takeprofit,0,CLR_NONE))
Print("eror");
}
}
else
if(Bid-OrderOpenPrice()>WHENTOTRAIL*pips)
if(OrderStopLoss()<Bid-pips*TRAILAMOUNT)
if(!OrderModify(OrderTicket(),OrderOpenPrice(),Bid-(pips*TRAILAMOUNT),OrderTakeProfit(),0,CLR_NONE))//משנים את STOPLOS
Print("eror");
}
//SELL
//+------------------------------------------------------------------+
//| SELL |
//+------------------------------------------------------------------+
//------------------------------------------------------------------------------
for(int s=OrdersTotal()-1; s>=0; s--)
{
if(OrderSelect(s,SELECT_BY_POS,MODE_TRADES))
if(OrderMagicNumber()!=MagicNumber)
continue;
if(OrderSymbol()==Symbol())
if(OrderType()==OP_SELL)
if(USECANDELTRAIL)
{
if(NewBarFlag)
{
RefreshRates();
stoploss=High[SELSTOPCANDLE]+PADAMOUNT*pips;
takeprofit=OrderTakeProfit()-pips*TRAILAMOUNT;
double StopLevel=MarketInfo(Symbol(),MODE_STOPLEVEL)+MarketInfo(Symbol(),MODE_SPREAD);
if(stoploss<StopLevel*pips)
stoploss=StopLevel*pips;
if(takeprofit<StopLevel*pips)
takeprofit=StopLevel*pips;
string symbol=OrderSymbol();
double point=SymbolInfoDouble(symbol,SYMBOL_POINT);
if(MathAbs(OrderStopLoss()-stoploss)>point)
if((pips*TRAILAMOUNT)>(int)SymbolInfoInteger(_Symbol,SYMBOL_TRADE_FREEZE_LEVEL)*pips)
//--- modify order and exit
if(CheckStopLoss_Takeprofit(OP_SELL,stoploss,takeprofit))
if(OrderModifyCheck(OrderTicket(),OrderOpenPrice(),stoploss,takeprofit))
if(OrderStopLoss()>High[SELSTOPCANDLE]+PADAMOUNT*pips)
if(!OrderModify(OrderTicket(),OrderOpenPrice(),High[SELSTOPCANDLE]+PADAMOUNT*pips,takeprofit,0,CLR_NONE))
Print("eror");
}
}
else
if(OrderOpenPrice()-Ask>WHENTOTRAIL*pips)
if(OrderStopLoss()>Ask+pips*TRAILAMOUNT || OrderStopLoss()==0)
if(!OrderModify(OrderTicket(),OrderOpenPrice(),Ask+(pips*TRAILAMOUNT),OrderTakeProfit(),0,CLR_NONE))
Print("eror");
}
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| stop |
//+------------------------------------------------------------------+
//-----------------------------------------------------------------------------+
int stop()
{
total=0;
HideTestIndicators(true);
double MA_1_t=iMA(NULL,L,FastMA,0,MODE_LWMA,PRICE_TYPICAL,0); // МА_1
double MA_2_t=iMA(NULL,L,SlowMA,0,MODE_LWMA,PRICE_TYPICAL,0); // МА_2
//+------------------------------------------------------------------+
double middleBB=iBands(Symbol(),0,20, 2,0,0,MODE_MAIN,1);//middle
double lowerBB=iBands(Symbol(),0,20, 2,0,0,MODE_LOWER,1);//lower
double upperBB=iBands(Symbol(),0,20, 2,0,0,MODE_UPPER,1);//upper
//+------------------------------------------------------------------+
double MacdMAIN=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1);
double MacdSIGNAL=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1);
double MacdMAIN0=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1);
double MacdSIGNAL0=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1);
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
// DALYN GUPPY MMA
//----------------------------------------------------------------------------
double MA_3=iMA(NULL,L,3,0,MODE_EMA,PRICE_TYPICAL,0); // МА_3 DALYN GUPPY MMA
double MA_5=iMA(NULL,L,5,0,MODE_EMA,PRICE_TYPICAL,0); // МА_5 DALYN GUPPY MMA
double MA_8=iMA(NULL,L,8,0,MODE_EMA,PRICE_TYPICAL,0); // МА_8 DALYN GUPPY MMA
double MA_10=iMA(NULL,L,10,0,MODE_EMA,PRICE_TYPICAL,0); // МА_10 DALYN GUPPY MMA
double MA_12=iMA(NULL,L,12,0,MODE_EMA,PRICE_TYPICAL,0); // МА_12 DALYN GUPPY MMA
double MA_15=iMA(NULL,L,15,0,MODE_EMA,PRICE_TYPICAL,0); // МА_15 DALYN GUPPY MMA
double MA_30=iMA(NULL,L,30,0,MODE_EMA,PRICE_TYPICAL,0); // МА_30 DALYN GUPPY MMA
double MA_35=iMA(NULL,L,35,0,MODE_EMA,PRICE_TYPICAL,0); // МА_35 DALYN GUPPY MMA
double MA_40=iMA(NULL,L,40,0,MODE_EMA,PRICE_TYPICAL,0); // МА_40 DALYN GUPPY MMA
double MA_45=iMA(NULL,L,45,0,MODE_EMA,PRICE_TYPICAL,0); // МА_45 DALYN GUPPY MMA
double MA_50=iMA(NULL,L,50,0,MODE_EMA,PRICE_TYPICAL,0); // МА_50 DALYN GUPPY MMA
double MA_60=iMA(NULL,L,60,0,MODE_EMA,PRICE_TYPICAL,0); // МА_60 DALYN GUPPY MMA
//-----------------------------------------------------------------------------------
HideTestIndicators(false);
for(int trade=OrdersTotal()-1; trade>=0; trade--)
{
if(OrderSelect(trade,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=MagicNumber)
continue;
if(OrderSymbol()==Symbol() || OrderMagicNumber()==MagicNumber)
{
if(OrderType()==OP_BUY)
{
//--- should it be closed?
if(((MA_3==MA_5 && MA_5==MA_8 && MA_8==MA_10 && MA_10==MA_12 && MA_12==MA_15)
||(MA_30==MA_35 && MA_35==MA_40 && MA_40==MA_45 && MA_45==MA_50 && MA_50==MA_60))
||(Close[1]<=lowerBB))
if(!OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,Red))
Print("Did not close");
break;
Print(" CLOSE BY EXIT STRATEGY ");
//--- check for trailing stop
}
else // go to short position
{
//--- should it be closed?
if(((MA_3==MA_5 && MA_5==MA_8 && MA_8==MA_10 && MA_10==MA_12 && MA_12==MA_15)
||(MA_30==MA_35 && MA_35==MA_40 && MA_40==MA_45 && MA_45==MA_50 && MA_50==MA_60))
||(Close[1]<=lowerBB))
if(!OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,Red))
Print("Did not close");
break;
Print(" CLOSE BY EXIT STRATEGY ");
//--- check for trailing stop
}
}
}
}
return(0);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Trailing stop loss |
//+------------------------------------------------------------------+
// --------------- ----------------------------------------------------------- ------------------------
void Trail1()
{
total=OrdersTotal();
//--- it is important to enter the market correctly, but it is more important to exit it correctly...
for(int cnt=0; cnt<total; cnt++)
{
if(!OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))
continue;
if(OrderMagicNumber()!=MagicNumber)
continue;
if(OrderType()<=OP_SELL && // check for opened position
OrderSymbol()==Symbol()) // check for symbol
{
//--- long position is opened
if(OrderType()==OP_BUY)
{
//--- check for trailing stop
if(TrailingStop>0)
{
if(Bid-OrderOpenPrice()>pips*TrailingStop)
{
if(OrderStopLoss()<Bid-pips*TrailingStop)
{
RefreshRates();
stoploss=Bid-(pips*TrailingStop);
takeprofit=OrderTakeProfit();
double StopLevel=MarketInfo(Symbol(),MODE_STOPLEVEL)+MarketInfo(Symbol(),MODE_SPREAD);
if(stoploss<StopLevel*pips)
stoploss=StopLevel*pips;
string symbol=OrderSymbol();
double point=SymbolInfoDouble(symbol,SYMBOL_POINT);
if(MathAbs(OrderStopLoss()-stoploss)>point)
if((pips*TrailingStop)>(int)SymbolInfoInteger(_Symbol,SYMBOL_TRADE_FREEZE_LEVEL)*pips)
//--- modify order and exit
if(CheckStopLoss_Takeprofit(OP_BUY,stoploss,takeprofit))
if(OrderModifyCheck(OrderTicket(),OrderOpenPrice(),stoploss,takeprofit))
if(!OrderModify(OrderTicket(),OrderOpenPrice(),stoploss,takeprofit,0,Green))
Print("OrderModify error ",GetLastError());
return;
}
}
}
}
else // go to short position
{
//--- check for trailing stop
if(TrailingStop>0)
{
if((OrderOpenPrice()-Ask)>(pips*TrailingStop))
{
if((OrderStopLoss()>(Ask+pips*TrailingStop)) || (OrderStopLoss()==0))
{
RefreshRates();
stoploss=Ask+(pips*TrailingStop);
takeprofit=OrderTakeProfit();
double StopLevel=MarketInfo(Symbol(),MODE_STOPLEVEL)+MarketInfo(Symbol(),MODE_SPREAD);
if(stoploss<StopLevel*pips)
stoploss=StopLevel*pips;
if(takeprofit<StopLevel*pips)
takeprofit=StopLevel*pips;
string symbol=OrderSymbol();
double point=SymbolInfoDouble(symbol,SYMBOL_POINT);
if(MathAbs(OrderStopLoss()-stoploss)>point)
if((pips*TrailingStop)>(int)SymbolInfoInteger(_Symbol,SYMBOL_TRADE_FREEZE_LEVEL)*pips)
//--- modify order and exit
if(CheckStopLoss_Takeprofit(OP_SELL,stoploss,takeprofit))
if(OrderModifyCheck(OrderTicket(),OrderOpenPrice(),stoploss,takeprofit))
if(!OrderModify(OrderTicket(),OrderOpenPrice(),stoploss,takeprofit,0,Red))
Print("OrderModify error ",GetLastError());
return;
}
}
}
}
}
}
}
//+------------------------------------------------------------------+
//+---------------------------------------------------------------------------+
//| MOVE TO BREAK EVEN |
//+---------------------------------------------------------------------------+
void MOVETOBREAKEVEN()
{
for(int b=OrdersTotal()-1; b>=0; b--)
{
if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES))
if(OrderMagicNumber()!=MagicNumber)
continue;
if(OrderSymbol()==Symbol())
if(OrderType()==OP_BUY)
if(Bid-OrderOpenPrice()>WHENTOMOVETOBE*pips)
if(OrderOpenPrice()>OrderStopLoss())
if(CheckStopLoss_Takeprofit(OP_SELL,OrderOpenPrice()+(PIPSTOMOVESL*pips),OrderTakeProfit()))
if(OrderModifyCheck(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+(PIPSTOMOVESL*pips),OrderTakeProfit()))
if(!OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+(PIPSTOMOVESL*pips),OrderTakeProfit(),0,CLR_NONE))
Print("eror");
}
for(int s=OrdersTotal()-1; s>=0; s--)
{
if(OrderSelect(s,SELECT_BY_POS,MODE_TRADES))
if(OrderMagicNumber()!=MagicNumber)
continue;
if(OrderSymbol()==Symbol())
if(OrderType()==OP_SELL)
if(OrderOpenPrice()-Ask>WHENTOMOVETOBE*pips)
if(OrderOpenPrice()<OrderStopLoss())
if(CheckStopLoss_Takeprofit(OP_SELL,OrderOpenPrice()-(PIPSTOMOVESL*pips),OrderTakeProfit()))
if(OrderModifyCheck(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-(PIPSTOMOVESL*pips),OrderTakeProfit()))
if(!OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-(PIPSTOMOVESL*pips),OrderTakeProfit(),0,CLR_NONE))
Print("eror");
}
}
//--------------------------------------------------------------------------------------
//+------------------------------------------------------------------+
double NDTP(double val)
{
RefreshRates();
double SPREAD=MarketInfo(Symbol(),MODE_SPREAD);
double StopLevel=MarketInfo(Symbol(),MODE_STOPLEVEL);
if(val<StopLevel*pips+SPREAD*pips)
val=StopLevel*pips+SPREAD*pips;
return(NormalizeDouble(val, Digits));
// return(val);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
double ND(double val)
{
return(NormalizeDouble(val, Digits));
}
//+------------------------------------------------------------------+
//| Checking the new values of levels before order modification |
//+------------------------------------------------------------------+
bool OrderModifyCheck(int ticket,double price,double sl,double tp)
{
//--- select order by ticket
if(OrderSelect(ticket,SELECT_BY_TICKET))
{
//--- point size and name of the symbol, for which a pending order was placed
string symbol=OrderSymbol();
double point=SymbolInfoDouble(symbol,SYMBOL_POINT);
//--- check if there are changes in the Open price
bool PriceOpenChanged=true;
int type=OrderType();
if(!(type==OP_BUY || type==OP_SELL))
{
PriceOpenChanged=(MathAbs(OrderOpenPrice()-price)>point);
}
//--- check if there are changes in the StopLoss level
bool StopLossChanged=(MathAbs(OrderStopLoss()-sl)>point);
//--- check if there are changes in the Takeprofit level
bool TakeProfitChanged=(MathAbs(OrderTakeProfit()-tp)>point);
//--- if there are any changes in levels
if(PriceOpenChanged || StopLossChanged || TakeProfitChanged)
return(true); // order can be modified
//--- there are no changes in the Open, StopLoss and Takeprofit levels
else
//--- notify about the error
PrintFormat("Order #%d already has levels of Open=%.5f SL=%.5f TP=%.5f",
ticket,OrderOpenPrice(),OrderStopLoss(),OrderTakeProfit());
}
//--- came to the end, no changes for the order
return(false); // no point in modifying
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
bool CheckStopLoss_Takeprofit(ENUM_ORDER_TYPE type,double SL,double TP)
{
//--- get the SYMBOL_TRADE_STOPS_LEVEL level
int stops_level=(int)SymbolInfoInteger(_Symbol,SYMBOL_TRADE_STOPS_LEVEL);
if(stops_level!=0)
{
PrintFormat("SYMBOL_TRADE_STOPS_LEVEL=%d: StopLoss and TakeProfit must"+
" not be nearer than %d points from the closing price",stops_level,stops_level);
}
//---
bool SL_check=false,TP_check=false;
//--- check only two order types
switch(type)
{
//--- Buy operation
case ORDER_TYPE_BUY:
{
//--- check the StopLoss
SL_check=(Bid-SL>stops_level*_Point);
if(!SL_check)
PrintFormat("For order %s StopLoss=%.5f must be less than %.5f"+
" (Bid=%.5f - SYMBOL_TRADE_STOPS_LEVEL=%d points)",
EnumToString(type),SL,Bid-stops_level*_Point,Bid,stops_level);
//--- check the TakeProfit
TP_check=(TP-Bid>stops_level*_Point);
if(!TP_check)
PrintFormat("For order %s TakeProfit=%.5f must be greater than %.5f"+
" (Bid=%.5f + SYMBOL_TRADE_STOPS_LEVEL=%d points)",
EnumToString(type),TP,Bid+stops_level*_Point,Bid,stops_level);
//--- return the result of checking
return(SL_check&&TP_check);
}
//--- Sell operation
case ORDER_TYPE_SELL:
{
//--- check the StopLoss
SL_check=(SL-Ask>stops_level*_Point);
if(!SL_check)
PrintFormat("For order %s StopLoss=%.5f must be greater than %.5f "+
" (Ask=%.5f + SYMBOL_TRADE_STOPS_LEVEL=%d points)",
EnumToString(type),SL,Ask+stops_level*_Point,Ask,stops_level);
//--- check the TakeProfit
TP_check=(Ask-TP>stops_level*_Point);
if(!TP_check)
PrintFormat("For order %s TakeProfit=%.5f must be less than %.5f "+
" (Ask=%.5f - SYMBOL_TRADE_STOPS_LEVEL=%d points)",
EnumToString(type),TP,Ask-stops_level*_Point,Ask,stops_level);
//--- return the result of checking
return(TP_check&&SL_check);
}
break;
}
//--- a slightly different function is required for pending orders
return false;
}
//+------------------------------------------------------------------+
////////////////////////////////////////////////////////////////////////////////////
int getOpenOrders()
{
int Orders=0;
for(int i=0; i<OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)
{
continue;
}
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=MagicNumber)
{
continue;
}
Orders++;
}
return(Orders);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Calculate optimal lot size buy |
//+------------------------------------------------------------------+
double LotsOptimized1Mxs(double llots)
{
double lots=llots;
//--- minimal allowed volume for trade operations
double minlot=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN);
if(lots<minlot)
{ lots=minlot; }
//--- maximal allowed volume of trade operations
double maxlot=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MAX);
if(lots>maxlot)
{ lots=maxlot; }
//--- get minimal step of volume changing
double volume_step=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_STEP);
int ratio=(int)MathRound(lots/volume_step);
if(MathAbs(ratio*volume_step-lots)>0.0000001)
{ lots=ratio*volume_step;}
if(((AccountStopoutMode()==1) &&
(AccountFreeMarginCheck(Symbol(),OP_BUY,lots)>AccountStopoutLevel()))
|| ((AccountStopoutMode()==0) &&
((AccountEquity()/(AccountEquity()-AccountFreeMarginCheck(Symbol(),OP_BUY,lots))*100)>AccountStopoutLevel())))
return(lots);
/* else Print("StopOut level Not enough money for ",OP_SELL," ",lot," ",Symbol());*/
return(0);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Calculate optimal lot size buy |
//+------------------------------------------------------------------+
double LotsOptimizedMxs(double llots)
{
double lots=llots;
//--- minimal allowed volume for trade operations
double minlot=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN);
if(lots<minlot)
{
lots=minlot;
Print("Volume is less than the minimal allowed ,we use",minlot);
}
//--- maximal allowed volume of trade operations
double maxlot=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MAX);
if(lots>maxlot)
{
lots=maxlot;
Print("Volume is greater than the maximal allowed,we use",maxlot);
}
//--- get minimal step of volume changing
double volume_step=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_STEP);
int ratio=(int)MathRound(lots/volume_step);
if(MathAbs(ratio*volume_step-lots)>0.0000001)
{
lots=ratio*volume_step;
Print("Volume is not a multiple of the minimal step ,we use the closest correct volume ",ratio*volume_step);
}
return(lots);
}
//+------------------------------------------------------------------+
//| Check the correctness of the order volume |
//+------------------------------------------------------------------+
bool CheckVolumeValue(double volume/*,string &description*/)
{
double lot=volume;
int orders=OrdersHistoryTotal(); // history orders total
int losses=0; // number of losses orders without a break
//--- select lot size
//--- maximal allowed volume of trade operations
double max_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MAX);
if(lot>max_volume)
Print("Volume is greater than the maximal allowed ,we use",max_volume);
// return(false);
//--- minimal allowed volume for trade operations
double minlot=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN);
if(lot<minlot)
Print("Volume is less than the minimal allowed ,we use",minlot);
// return(false);
//--- get minimal step of volume changing
double volume_step=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_STEP);
int ratio=(int)MathRound(lot/volume_step);
if(MathAbs(ratio*volume_step-lot)>0.0000001)
{
Print("Volume is not a multiple of the minimal step ,we use, the closest correct volume is %.2f",
volume_step,ratio*volume_step);
// return(false);
}
// description="Correct volume value";
return(true);
}
//+------------------------------------------------------------------+
bool CheckMoneyForTrade(string symb,double lots,int type)
{
double free_margin=AccountFreeMarginCheck(symb,type,lots);
//-- if there is not enough money
if(free_margin>0)
{
if((AccountStopoutMode()==1) &&
(AccountFreeMarginCheck(symb,type,lots)<AccountStopoutLevel()))
{
Print("StopOut level Not enough money ", type," ",lots," ",Symbol());
return(false);
}
if(AccountEquity()-AccountFreeMarginCheck(Symbol(),type,lots)==0)
{
Print("StopOut level Not enough money ", type," ",lots," ",Symbol());
return(false);
}
if((AccountStopoutMode()==0) &&
((AccountEquity()/(AccountEquity()-AccountFreeMarginCheck(Symbol(),type,lots))*100)<AccountStopoutLevel()))
{
Print("StopOut level Not enough money ", type," ",lots," ",Symbol());
return(false);
}
}
else
if(free_margin<0)
{
string oper=(type==OP_BUY)? "Buy":"Sell";
Print("Not enough money for ",oper," ",lots," ",symb," Error code=",GetLastError());
return(false);
}
//--- checking successful
return(true);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int CountTrades()
{
int count=0;
for(int trade=OrdersTotal()-1; trade>=0; trade--)
{
if(!OrderSelect(trade,SELECT_BY_POS,MODE_TRADES))
Print("Error");
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=MagicNumber)
continue;
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
if(OrderType()==OP_SELL || OrderType()==OP_BUY)
count++;
}
return (count);
}
//+------------------------------------------------------------------+
double AccountEquityHigh()
{
if(CountTrades()==0)
AccountEquityHighAmt=AccountEquity();
if(AccountEquityHighAmt<PrevEquity)
AccountEquityHighAmt=PrevEquity;
else
AccountEquityHighAmt=AccountEquity();
PrevEquity=AccountEquity();
return (AccountEquityHighAmt);
}
//+------------------------------------------------------------------+
double CalculateProfit()
{
double Profit=0;
for(int cnt=OrdersTotal()-1; cnt>=0; cnt--)
{
if(!OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))
Print("Error");
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=MagicNumber)
continue;
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
if(OrderType()==OP_BUY || OrderType()==OP_SELL)
Profit+=OrderProfit();
}
return (Profit);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| ZigZag Highest And Lowest TrendLine Show ELIOT(3)PEAK=5WAVES |
//+------------------------------------------------------------------+
void TrendLine()
{
ArrayResize(ZigZagHigh,ZigZagNum,1);
ArrayResize(ZigZagLow,ZigZagNum,1);
ArrayResize(ZigHCandel,ZigZagNum,1);
ArrayResize(ZigLCandel,ZigZagNum,1);
double high= -1,low = -1;
double data=0;
int lowcount=0,highcount=0;
for(int i=0; i<Bars; i++)
{
high=iCustom(NULL,0,"ZigZag",5,3,1,1,i);
if((high>0) && (high==iCustom(NULL,0,"ZigZag",5,3,1,0,i)))
{
ZigZagHigh[highcount]=high;
ZigHCandel[highcount]=i;
highcount++;
}
high=-1;
if(highcount==ZigZagNum)
break;
}
for(int i=0; i<Bars; i++)
{
low=iCustom(NULL,0,"ZigZag",5,3,1,2,i);
if((low>0) && (low==iCustom(NULL,0,"ZigZag",5,3,1,0,i)))
{
ZigZagLow[lowcount]=low;
ZigLCandel[lowcount]=i;
lowcount++;
}
low=-1;
if(lowcount==ZigZagNum)
break;
}
for(int j=0; j<=ZigZagNum-1; j++)
{
//ObjectDelete("FXNODE.ZigZagHigh."+IntegerToString(j));
if(ObjectFind(0,"ELIOT.ZigZagHigh")<0)
{
ObjectCreate(0,"ELIOT.ZigZagHigh."+IntegerToString(j),OBJ_ARROW,0,0,0,0,0); // Create an arrow
ObjectSetInteger(0,"ELIOT.ZigZagHigh."+IntegerToString(j),OBJPROP_ARROWCODE,238); // Set the arrow code
ObjectSetInteger(0,"ELIOT.ZigZagHigh."+IntegerToString(j),OBJPROP_COLOR,clrCrimson);
}
ObjectSetInteger(0,"ELIOT.ZigZagHigh."+IntegerToString(j),OBJPROP_TIME,Time[ZigHCandel[j]]); // Set time
ObjectSetDouble(0,"ELIOT.ZigZagHigh."+IntegerToString(j),OBJPROP_PRICE,ZigZagHigh[j]+(10+(Period()/100))*Point);// Set price
}
for(int j=0; j<=ZigZagNum-1; j++)
{
if(ObjectFind(0,"ELIOT.ZigZagLow")<0)
{
ObjectDelete("ELIOT.ZigZagLow."+IntegerToString(j));
ObjectCreate(0,"ELIOT.ZigZagLow."+IntegerToString(j),OBJ_ARROW,0,0,0,0,0); // Create an arrow
ObjectSetInteger(0,"ELIOT.ZigZagLow."+IntegerToString(j),OBJPROP_ARROWCODE,236); // Set the arrow code
ObjectSetInteger(0,"ELIOT.ZigZagLow."+IntegerToString(j),OBJPROP_COLOR,clrOliveDrab);
}
ObjectSetInteger(0,"ELIOT.ZigZagLow."+IntegerToString(j),OBJPROP_TIME,Time[ZigLCandel[j]]); // Set time
ObjectSetDouble(0,"ELIOT.ZigZagLow."+IntegerToString(j),OBJPROP_PRICE,ZigZagLow[j]-(10+(Period()/250))*Point);// Set price
}
DrawLine=true;
First_Low_Candel=0;
Secund_Low_Candel=2;
First_High_Candel=0;
Secund_High_Candel=2;
MODE="none";
/////////////////////////////////////////////////////////////////////////////////////////////
if((highcount>2) && (DrawLine==true))
{
ObjectDelete("ELIOT.HighLine");
ObjectCreate("ELIOT.HighLine",OBJ_TREND,0,Time[ZigHCandel[Secund_High_Candel]],ZigZagHigh[Secund_High_Candel],Time[ZigHCandel[First_High_Candel]],ZigZagHigh[First_High_Candel]);
ObjectSet("ELIOT.HighLine",OBJPROP_COLOR,Color_UPLine);
ObjectSet("ELIOT.HighLine",OBJPROP_STYLE,STYLE_DASH);
ObjectSet("ELIOT.HighLine",OBJPROP_WIDTH,1);
ObjectSet("ELIOT.HighLine",OBJPROP_RAY,true);
ObjectSet("ELIOT.HighLine",OBJPROP_BACK,true);
}
if((lowcount>2) && (DrawLine==true))
{
ObjectDelete("ELIOT.LowLine");
ObjectCreate("ELIOT.LowLine",OBJ_TREND,0,Time[ZigLCandel[Secund_Low_Candel]],ZigZagLow[Secund_Low_Candel],Time[ZigLCandel[First_Low_Candel]],ZigZagLow[First_Low_Candel]);
ObjectSet("ELIOT.LowLine",OBJPROP_COLOR,Color_DWLine);
ObjectSet("ELIOT.LowLine",OBJPROP_STYLE,STYLE_DASH);
ObjectSet("ELIOT.LowLine",OBJPROP_WIDTH,1);
ObjectSet("ELIOT.LowLine",OBJPROP_RAY,true);
ObjectSet("ELIOT.LowLine",OBJPROP_BACK,true);
}
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Fractal High Low horizital line Show |
//+------------------------------------------------------------------+
int find()
{
datetime T2=0; // Second time coordinate
double t2=0;
// int Error; // Error code
//--------------------------------------------------------------- 3 --
double high= -1,low = -1;
double data=0;
int lowcount=0,highcount=0;
for(int i=0; i<Bars; i++)
{
high=iFractals(NULL,0,MODE_UPPER,i);
if(high>0)
{
if(Ask==high/*&&High[1]<high*/)
return(1);
}
}
for(int i=0; i<Bars; i++)
{
low=iFractals(NULL,0,MODE_LOWER,i);
if(low>0)
{
if(Bid==low/*&&Low[1]>low*/)
return(1);
}
}
return (0);
}
//--------------------------------------------------------------- 7 --
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
void del()
{
static datetime dtBarCurrent=WRONG_VALUE;
datetime dtBarPrevious=dtBarCurrent;
dtBarCurrent=(datetime) SeriesInfoInteger(_Symbol,_Period,SERIES_LASTBAR_DATE);
bool NewBarFlag=(dtBarCurrent!=dtBarPrevious);
if(NewBarFlag)
{
// Sleep(3000);
int obj_total=ObjectsTotal();
PrintFormat("Total %d objects",obj_total);
for(int i=obj_total-1; i>=0; i--)
{
string name=ObjectName(i);
PrintFormat("object %d: %s",i,name);
ObjectDelete(name);
}
}
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void CloseThisSymbolAll()
{
double CurrentPairProfit=CalculateProfit();
for(int trade=OrdersTotal()-1; trade>=0; trade--)
{
if(!OrderSelect(trade,SELECT_BY_POS,MODE_TRADES))
Print("Error");
if(OrderSymbol()==Symbol())
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
{
if(OrderType() == OP_BUY)
if(!OrderClose(OrderTicket(), OrderLots(), Bid, 3, Blue))
Print("Error");
if(OrderType() == OP_SELL)
if(!OrderClose(OrderTicket(), OrderLots(), Ask, 3, Red))
Print("Error");
}
Sleep(1000);
if(UseEquityStop)
{
if(CurrentPairProfit>0.0 && MathAbs(CurrentPairProfit)>TotalEquityRisk/100.0*AccountEquityHigh())
{
return;
}
}
}
}
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Calculate optimal lot size buy |
//+------------------------------------------------------------------+
double LotsOptimized(double llots)
{
double lot=llots;
int orders=OrdersHistoryTotal(); // history orders total
int losses=0; // number of losses orders without a break
//--- calcuulate number of losses orders without a break
if(IncreaseFactor>0)
{
for(int i=orders-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false)
{
Print("Error in history!");
break;
}
if(OrderSymbol()!=Symbol())
continue;
//---
if(OrderProfit()>0)
break;
if(OrderProfit()<0)
losses++;
}
if(losses>1)
// lot=NormalizeDouble(lot+lot*losses/IncreaseFactor,1);
lot=AccountFreeMargin()*IncreaseFactor/1000.0;
}
//--- minimal allowed volume for trade operations
double minlot=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN);
if(lot<minlot)
{
lot=minlot;
Print("Volume is less than the minimal allowed ,we use",minlot);
}
// lot=minlot;
//--- maximal allowed volume of trade operations
double maxlot=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MAX);
if(lot>maxlot)
{
lot=maxlot;
Print("Volume is greater than the maximal allowed,we use",maxlot);
}
// lot=maxlot;
//--- get minimal step of volume changing
double volume_step=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_STEP);
int ratio=(int)MathRound(lot/volume_step);
if(MathAbs(ratio*volume_step-lot)>0.0000001)
{
lot=ratio*volume_step;
Print("Volume is not a multiple of the minimal step ,we use the closest correct volume ",ratio*volume_step);
}
return(lot);
}
//----------------------------------------- TP_In_Money -----------------------------------------------
void Take_Profit_In_Money()
{
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
if((TP_In_Money != 0))
{
PROFIT_SUM1 = 0;
for(int i=OrdersTotal(); i>0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol())
{
if(OrderType() == OP_BUY || OrderType() == OP_SELL)
{
PROFIT_SUM1 = (PROFIT_SUM1 + OrderProfit());
}
}
}
}
if((PROFIT_SUM1 >= TP_In_Money))
{
RemoveAllOrders();
}
}
}
//+------------------------------------------------------------------+
//------------------------------------------------ TP_In_Percent -------------------------------------------------
double Take_Profit_In_percent()
{
if((TP_In_Percent != 0))
{
double TP_Percent = ((TP_In_Percent * AccountBalance()) / 100);
double PROFIT_SUM = 0;
for(int i=OrdersTotal(); i>0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol())
{
if(OrderType() == OP_BUY || OrderType() == OP_SELL)
{
PROFIT_SUM = (PROFIT_SUM + OrderProfit());
}
}
}
if(PROFIT_SUM >= TP_Percent)
{
RemoveAllOrders();
}
}
}
return(0);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
// CLOSE && Remove All Orders
//+------------------------------------------------------------------+
void RemoveAllOrders()
{
for(int i = OrdersTotal() - 1; i >= 0 ; i--)
{
if(!OrderSelect(i,SELECT_BY_POS))
Print("ERROR");
if(OrderSymbol() != Symbol())
continue;
double price = MarketInfo(OrderSymbol(),MODE_ASK);
if(OrderType() == OP_BUY)
price = MarketInfo(OrderSymbol(),MODE_BID);
if(OrderType() == OP_BUY || OrderType() == OP_SELL)
{
if(!OrderClose(OrderTicket(), OrderLots(),price,5))
Print("ERROR");
}
else
{
if(!OrderDelete(OrderTicket()))
Print("ERROR");
}
Sleep(100);
int error = GetLastError();
// if(error > 0)
// Print("Unanticipated error: ", ErrorDescription(error));
RefreshRates();
}
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int TRAIL_PROFIT_IN_MONEY2()
{
PROFIT_SUM1 = 0;
PROFIT_SUM2 = 0;
INDEX2 = 0;
double PROFIT_SUM3 = 0;
for(int j=OrdersTotal(); j>0; j--)
{
if(OrderSelect(j,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol())
{
if(OrderType() == OP_BUY || OrderType() == OP_SELL)
{
PROFIT_SUM1 = PROFIT_SUM1 + (OrderProfit() + OrderCommission() + OrderSwap());
}
}
}
}
if(PROFIT_SUM1>= Take_Profit_Money)
{
for(int i=OrdersTotal(); i>0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol())
{
if(OrderType() == OP_BUY || OrderType() == OP_SELL)
{
PROFIT_SUM2 = PROFIT_SUM2 + (OrderProfit() + OrderCommission() + OrderSwap());
}
if(PROFIT_SUM1>= PROFIT_SUM3)
{PROFIT_SUM3=PROFIT_SUM1;}
if(PROFIT_SUM2<=PROFIT_SUM3-Stop_Loss_Money)
RemoveAllOrders();
}
}
}
}
return(0);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
int Close_BUY()
{
//-------------------------------------------------------------------------------------------------
double MacdMAIN0=iMACD(NULL,PERIOD_MN1,12,26,9,PRICE_CLOSE,MODE_MAIN,1);
double MacdSIGNAL0=iMACD(NULL,PERIOD_MN1,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1);
//+------------------------------------------------------------------------------------------------+
int count_0 = 0;
for(int pos_4 = OrdersTotal() - 1; pos_4 >= 0; pos_4--)
{
bool cg = OrderSelect(pos_4, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol() != Symbol())
continue;
if(OrderSymbol() == Symbol())
if(OrderType() == OP_BUY)
if((MacdMAIN0>0 && MacdMAIN0<MacdSIGNAL0) || (MacdMAIN0<0 && MacdMAIN0<MacdSIGNAL0))
Close_All_Buy_Trades();
}
return (count_0);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
int Close_SELL()
{
//-------------------------------------------------------------------------------------------------
double MacdMAIN0=iMACD(NULL,PERIOD_MN1,12,26,9,PRICE_CLOSE,MODE_MAIN,1);
double MacdSIGNAL0=iMACD(NULL,PERIOD_MN1,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1);
//+------------------------------------------------------------------------------------------------+
int count_0 = 0;
for(int pos_4 = OrdersTotal() - 1; pos_4 >= 0; pos_4--)
{
bool cg = OrderSelect(pos_4, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol() != Symbol())
continue;
if(OrderSymbol() == Symbol())
if(OrderType() == OP_SELL)
if((MacdMAIN0>0 && MacdMAIN0>MacdSIGNAL0) || (MacdMAIN0<0 && MacdMAIN0>MacdSIGNAL0))
Close_All_Sell_Trades();
}
return (count_0);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void Close_All_Buy_Trades()
{
double CurrentPairProfit=CalculateProfit();
for(int trade=OrdersTotal()-1; trade>=0; trade--)
{
if(!OrderSelect(trade,SELECT_BY_POS,MODE_TRADES))
Print("Error");
if(OrderSymbol()==Symbol())
{
if(OrderSymbol()==Symbol())
{
if(OrderType() == OP_BUY)
if(!OrderClose(OrderTicket(), OrderLots(), Bid, 3, Blue))
Print("Error");
if(OrderType() == OP_SELL)
if(!OrderClose(OrderTicket(), OrderLots(), Ask, 3, Red))
Print("Error");
}
Sleep(1000);
}
}
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void Close_All_Sell_Trades()
{
double CurrentPairProfit=CalculateProfit();
for(int trade=OrdersTotal()-1; trade>=0; trade--)
{
if(!OrderSelect(trade,SELECT_BY_POS,MODE_TRADES))
Print("Error");
if(OrderSymbol()==Symbol())
{
if(OrderSymbol()==Symbol())
{
if(OrderType() == OP_BUY)
if(!OrderClose(OrderTicket(), OrderLots(), Bid, 3, Blue))
Print("Error");
if(OrderType() == OP_SELL)
if(!OrderClose(OrderTicket(), OrderLots(), Ask, 3, Red))
Print("Error");
}
Sleep(1000);
}
}
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+ - #79,932
- Oct 24, 2025 4:07am Oct 24, 2025 4:07am
- Joined Sep 2017 | Status: Trader | 2,686 Posts
Disliked{quote} Solution: Open 2 accounts, use trade copier with reverse trade function, open long account 1, trade copier opens short account 2 It's not rocket science!
Ignored
where to find trade copier? is it an indcator or EA?
- #79,933
- Oct 24, 2025 4:17am Oct 24, 2025 4:17am
- Joined Jul 2011 | Status: Gold Again | 10,553 Posts
Disliked{quote} thanks where to find trade copier? is it an indcator or EA?Ignored
https://www.fxblue.com/appstore/2/mt...l-trade-copier
So easy, even you can do it.
It takes a lot for me to IGNORE you, but you can try.
- #79,934
- Oct 24, 2025 4:52am Oct 24, 2025 4:52am
- Joined Mar 2022 | Status: Trader | 6,558 Posts
Dislikedkindly convert this code into standalone indicator to update ontick //+------------------------------------------------------------------+ //| ProjectName | //| Copyright 2018, CompanyName | //| http://www.companyname.net | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| ELIOT WAVE | //| https://5d3071208c5e2.site123.me/ | //+------------------------------------------------------------------+ #property copyright "AHARON TZADIK" #property link...Ignored
Attached File(s)
.ex4/.ex5 files can't be fixed or modified / I'm not a coder!
1
- #79,935
- Edited 2:57pm Oct 24, 2025 5:00am | Edited 2:57pm
DislikedFaster was in regards to the scanning/signal updating (though I didn't make that clear, and on the lowest ms timing), wasn't related to the show/hide of the panel objectsIgnored
The lowest possible update interval is 16 milliseconds (64 interrupts per second, did you know that?!). You can't go below that.
I deliberately set the lowest option to 25 ms instead of 16 ms to give the other running programs some "breathing room" (just for sure, you know, because of the 1-thread bottleneck). So it's totally fair that I wrote that it can't be any faster.
A row is updated in 25 ms! Lightning fast.
25 ms means that it can scan 40 instruments in 1 second, which is 9x40=360 chart data for 9 timeframes!
So, the "light as a breeze and fast as the wind" is absolutely valid.
You've rewritten all that nonsense you wrote earlier, just longer. I've already answered all of it.
1
- #79,936
- Oct 24, 2025 8:10am Oct 24, 2025 8:10am
DislikedHi , I have developed a automated strategy using lua (a scripting language) on the fxcm platform. Below are the points Have back tested successfully with 80% positive trades on GDP/USD, EUR/USD USD/JPY and FRA40.Its based on a support/resistance Below is the logic. 1. Find the highest /lowest bar for the (N) number of bars. N varies based on currency. 2. On the 15 min chart, if the lates bar closes above/below the highest/lowest of N 3. If the last 2 15 min bars close above /below EMA . EMA varies for currency. 4. Stop loss is defined as the highest...Ignored
- #79,938
- Edited 11:55am Oct 24, 2025 11:42am | Edited 11:55am
- Joined Mar 2022 | Status: Trader | 6,558 Posts
Disliked1. Find the highest /lowest bar for the (N) number of bars. N varies based on currency. 2. On the 15 min chart, if the lates bar closes above/below the highest/lowest of N 3. If the last 2 15 min bars close above /below EMA . EMA varies for currency. 4. Stop loss is defined as the highest or lowest bar from step 1. 5. The trade closes in profit if the same high/low logic is applied when the trade is in profit. 6 The trade breaks even when 20 pips ahead.Ignored
Is the timeframe for 1. the same, or higher?
Assuming it's a higher TF, like H1, or even the same TF, your exit logic doesn't make any sense.
During the M15 bar on which the entry conditions are met, and an order is triggered and filled, this order can be in profit immediatelly, and then the conditions are still met, and the order will be closed - according to what you wrote.
In such a case, it may be closed in profit, or even in a loss, because of slippage which we can't control.
Not to mention commissions, if any...
Also, if there are no other limitations, every time a trade is closed, and the conditions are still met, a new order will be triggered, and this will continue until the conditions are no longer met.
So, this means that you will be taking small profits (or even losses) in relation to the stoploss, and this means that when you hit a stoploss, most if not all of your profits will be gone, or even more. So, this will never work.
Also, you will almost never get the opportunity to trigger BE, unless there is a very violent, immediate move of price, or unless the conditions are no longer met.
So, in the case when there is a floating profiting position, but the conditions are no longer met, is that when the BE must be executed?
.ex4/.ex5 files can't be fixed or modified / I'm not a coder!
- #79,939
- Oct 24, 2025 6:27pm Oct 24, 2025 6:27pm
- Joined Mar 2022 | Status: Trader | 6,558 Posts
DislikedHello, I would like MQL5 indicator that plots Parabolic SAR of the RSI of period P.Ignored
.ex4/.ex5 files can't be fixed or modified / I'm not a coder!
- #79,940
- Oct 25, 2025 9:31am Oct 25, 2025 9:31am
- Joined Mar 2022 | Status: Trader | 6,558 Posts
For those of you who like to trade all sorts of time-related levels, here is a universal indicator which plots High, Low and Mid lines for the specified Start Time and End Time of the day. The specific feature of this indicator is that it can plot the lines on all timeframes, both lower and higher. So, for example, we can see the 16:00 to 16:30 HLM on H1 just as well as on M1.
Using the Unique prefix we can use two or more instances of this indicator.
Using the Temporary manual timeshift offset in hours for DST transition we can easily adjust for the transition period, when for example, Europe changed to winter time, and USA didn't. We can then save separate templates for DST and transition periods.
Do not change the file name!!!
Using the Unique prefix we can use two or more instances of this indicator.
Using the Temporary manual timeshift offset in hours for DST transition we can easily adjust for the transition period, when for example, Europe changed to winter time, and USA didn't. We can then save separate templates for DST and transition periods.
Attached File(s)
.ex4/.ex5 files can't be fixed or modified / I'm not a coder!
2