- Posts: 313
- Thank you received: 0
Het MT4 topic
- Edbeleg
-
- Offline
- Elite Member
-
Hoe kan je zien of het trade via EA uitstaat bij de Broker, weet je dat?
Please Log in or Create an account to join the conversation.
- Jules-v-H
-
- Offline
- Elite Member
-
- Forex Farmer
- Posts: 205
- Thank you received: 0
Is het al gelukt om een EA draaiend te krijgen?
Please Log in or Create an account to join the conversation.
- Jonkie76
-
- Offline
- Platinum Member
-
- Posts: 1001
- Thank you received: 0
Als je interesse hebt, pm me dan even, de tutorial is echt goed begrijpbaar.
Please Log in or Create an account to join the conversation.
- gigagonnie
-
- Offline
- Elite Member
-
- Posts: 235
- Thank you received: 0
Alvast bedankt!
Groeten,
Gonnie
Please Log in or Create an account to join the conversation.
- Jules-v-H
-
- Offline
- Elite Member
-
- Forex Farmer
- Posts: 205
- Thank you received: 0
Aleen weet ik niet of het mogelijk is om een shift in de indicator in te geven, bij een normale ema op de grafiek wel.
Please Log in or Create an account to join the conversation.
- gigagonnie
-
- Offline
- Elite Member
-
- Posts: 235
- Thank you received: 0
Please Log in or Create an account to join the conversation.
- Jules-v-H
-
- Offline
- Elite Member
-
- Forex Farmer
- Posts: 205
- Thank you received: 0
Tweede afbeelding met shift -1 [img] [img]http://www.forexinfo.nl/media/kunena/attachments/legacy/images/shift__1-20110817.JPG[/img]
Zie het verschil.
Zo kun je een crossing signaal een candle schuiven.
Ik bedenk me net dat het in jouw geval een shift 1 ipv -1 dient te zijn.
Ik heb die indicator zo niet voor de geest. Ik weet dan ook niet of je daar bij de 2 EMA die het crossing signaal geven een shift kunt instellen. Vaak kun je wel het type wijzigen (EMA of SMA of noem maar op) Wellicht kan de shift ook.
Attachments:
Please Log in or Create an account to join the conversation.
- gigagonnie
-
- Offline
- Elite Member
-
- Posts: 235
- Thank you received: 0
Please Log in or Create an account to join the conversation.
- k00tje
-
Topic Author
- Offline
- Senior Member
-
- Posts: 51
- Thank you received: 0
Zoals al eerder in dit topic vermeld, had ik wel eens last van crashende
MT4 terminals wanneer ik er meerdere open had staan met allen een aantal valutaparen.
(ze sloten ook af)
Niet fijn als je er niet bent en je SL/TP door je EA laat regelen.
Ik heb hiervoor een kleine app geschreven die je de terminals kunt laten monitoren.
In de config.txt (die in dezelfde folder moet staan) zet je de paden naar de terminals die je gemonitored wilt hebben. (er zit een voorbeeld config bij)
Hij gaat ze dan monitoren of er een actief process van is.
Als dat er niet is start hij de terminal (opnieuw) op.
Opmerking: dit werkt alleen als de terminal na de crash ook afsluit (is volgens mij wel standaard gedrag van MT4).
Acties worden gelogged in het log window en de monitoring interval is instelbaar.
Mocht je dit gebruiken en bugs tegenkomen hoor ik het graag.
Attachment Relauncher.zip not found
Please Log in or Create an account to join the conversation.
- Jonkie76
-
- Offline
- Platinum Member
-
- Posts: 1001
- Thank you received: 0
Leuk handig tootlje.. zal uhm eens downloaden van je! TX..
Please Log in or Create an account to join the conversation.
- Jonkie76
-
- Offline
- Platinum Member
-
- Posts: 1001
- Thank you received: 0
Ik ben momenteel bezig om mijn ea te laten runnen in demo zodat ik de laatste fouten er uit kan halen.
Een van de fouten waar ik tegen aanloop is het volgende..
Ik maak een berekeing en de uitkomst daarvan is met een heleboel cijfers achter de komma. Nu heb ik een screenshot hieronder geplaatst waaronder je een stukje code ziet waarin ik enkele berekeningen doe en deze vervolgens op mijn scherm laat zien met een Alert. Als je goed kijkt zie je dat in het alert scherm nooit meer dan vier cijfers achter de komma heeft. huh ?? Dat is lekker..
Is dat iets wat in de Alert functie zit ingebouwd? Hoe kan ik nu namelijk controleren of de uitkomst correct is?
En weet je wat ook vreemd is? De laatste 3 meldingen zouden allemaal exact dezelfde waarde moeten bevatten. Echter de eerste melding is een berekening van 12 gedeeld door 78. En de uitkomst is 0 ?? Stukje code ervoor bereken ik de Lots en daar is ook een deling gebruikt, en die geeft netjes een 0.0216 als uitkomst (ook weer max 4 cijfers achter de komma trouwens).
Kan iemand mij dit toelichten hoe dit kan?
Ik wil namelijk 100% zeker weten dat als ik een stoploss of profittarget bereken het getal vijf cijfers achter de komma geeft, omdat mijn broker vijf cijfers achter de komma heeft bij de prijswaarden (op bijv. eur/usd)
Alvast bedankt!
Please Log in or Create an account to join the conversation.
- forextradertje
-
- Offline
- Junior Member
-
- Posts: 17
- Thank you received: 0
als je het op de volgende manier in je script plaatst , kan je de waardes laten verschijnen in je tester
een voorbeeld hiervan:
void commentaren // aanroepen van de waarden die de indicatoren geven en laten verschijnen op het scherm
Comment (
"","\n",
"OldLocalValue = ",OldLocalValue,"\n",
"LocalValue = ",LocalValue,"\n",
"SellRunning = ",SellRunning,"\n",
"BuyRunning = ",BuyRunning,"\n",
"BuyCount = ",BuyCount,"\n",
"SellCount = ",SellCount,"\n",
"ReEntryBuyAllowed = ",ReEntryBuyAllowed,"\n",
"ReEntrySellAllowed = ",ReEntrySellAllowed,"\n",
"Local = ",Local,"\n",
"Line2 = ",Line2,"\n",
"Higher = ",Higher,"\n",
"Higher2 = ",Higher2,"\n"
);
op deze manier hoef je niet de alert te gebruiken en zal hij de werkelijke waardes weergeven.
mvg Forextradertje
Please Log in or Create an account to join the conversation.
- Jonkie76
-
- Offline
- Platinum Member
-
- Posts: 1001
- Thank you received: 0
Please Log in or Create an account to join the conversation.
- deVries
-
- Offline
- Junior Member
-
- Posts: 25
- Thank you received: 0
Heren, Dames,
Ik ben momenteel bezig om mijn ea te laten runnen in demo zodat ik de laatste fouten er uit kan halen.
Een van de fouten waar ik tegen aanloop is het volgende..
Ik maak een berekeing en de uitkomst daarvan is met een heleboel cijfers achter de komma. Nu heb ik een screenshot hieronder geplaatst waaronder je een stukje code ziet waarin ik enkele berekeningen doe en deze vervolgens op mijn scherm laat zien met een Alert. Als je goed kijkt zie je dat in het alert scherm nooit meer dan vier cijfers achter de komma heeft. huh ?? Dat is lekker..
Is dat iets wat in de Alert functie zit ingebouwd? Hoe kan ik nu namelijk controleren of de uitkomst correct is?
En weet je wat ook vreemd is? De laatste 3 meldingen zouden allemaal exact dezelfde waarde moeten bevatten. Echter de eerste melding is een berekening van 12 gedeeld door 78. En de uitkomst is 0 ?? Stukje code ervoor bereken ik de Lots en daar is ook een deling gebruikt, en die geeft netjes een 0.0216 als uitkomst (ook weer max 4 cijfers achter de komma trouwens).
Kan iemand mij dit toelichten hoe dit kan?
Ik wil namelijk 100% zeker weten dat als ik een stoploss of profittarget bereken het getal vijf cijfers achter de komma geeft, omdat mijn broker vijf cijfers achter de komma heeft bij de prijswaarden (op bijv. eur/usd)
Alvast bedankt!
![]()
Om double op die manier op te geven gebruik je het commando NormalizeDouble
Als voorbeeld afronding lotgrootte op twee decimalen Lots = NormalizeDouble(LotSize(), 2). Als je op vijf decimalen wilt afronden zou die 2 in deze formule dus een vijf moeten zijn. Het spijt me te moeten zeggen dat ik van de code op de foto niks kan lezen en het daarom voor mij nu ook moeilijk is om je voor dit programma nog meer tips te geven. Veel succes met je coding en vraag maar als er nog meer moeilijkheden hebt.
Groeten, Tjipke
Please Log in or Create an account to join the conversation.
- Jonkie76
-
- Offline
- Platinum Member
-
- Posts: 1001
- Thank you received: 0
Ondertussen heb ik het antwoord gekregen waar ik naar op zoek was!
For alerts use:
Alert(DoubleToStr(anyValue,anyNumberOfDigits));
If you let metatrader "decide" how to write out a double (in alert, print ... ) it will use 4 digits
The case with 0 is when you are dividing all integer values (12/78) and then metatrader does it as integer division
Use 12.0/78.0 instead and it will be OK (metatrader 4 does not have explicit type cast so you can not use something like (double)12/(double)78). That is one of the known "quirks" of metatrader and that is why you will often see a number+".0" in a code (just to make sure that metatrader does not "understand" some number wrongly)
Please Log in or Create an account to join the conversation.
- deVries
-
- Offline
- Junior Member
-
- Posts: 25
- Thank you received: 0
Het zou makelijker zijn als dit forum zoiets zou hebben dat bij het plaatsen van berichten de code neergezet zou kunnen worden tussen iets dergelijks als dit
...hier mq4..Die fouten van verschillende waarden zou mischien kunnen komen van verkeerd gebruik integer en double... kan het nu simpelweg niet zien. Dat staat eigenlijk ook te lezen in die engelse tekst hier.
Please Log in or Create an account to join the conversation.
- deVries
-
- Offline
- Junior Member
-
- Posts: 25
- Thank you received: 0
Attachment secret_forex_indicator_blogspot.mq4 not found
//+------------------------------------------------------------------+
//| secret-forex-indicator-blogspot.mq4 |
//| Copyright © 2011, Tjipke de Vries |
//| |
//| http://secret-forex-indicator.blogspot.com/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, Tjipke de Vries"
#property link ""
extern bool ShowComment = true; // false for backtesting
extern bool PrefferedSett = true;
extern string s1 = "== Test Settings ==";
extern double StopLoss = 240;
extern double TakeProfit = 250;
extern double TrailingStop = 110;
double TrailingStep = 1;
extern string s2 = "== Money Management ==";
extern double Lots = 0.1;
extern bool UseMM = true;
extern double PctToRisk = 2.0;
extern string s3 = "== Extra Settings ==";
extern string TradeComment = "secret-forex-indicator-blogspot";
extern int Slippage = 3;
extern int H1MagicNumber = 10060;
extern int H4MagicNumber = 10240;
extern int D1MagicNumber = 11440;
extern string s4 = "== Signal Settings ==";
extern string Signal1 = "====== Signal 1 ===================================";
extern bool UseSignal1 = true;
extern string Signal2 = "====== Signal 2 ===================================";
extern bool UseSignal2 = true;
extern string Signal3 = "====== Signal 3 ===================================";
extern bool UseSignal3 = true;
extern string Signal4 = "====== Signal 4 =================================";
extern bool UseSignal4 = true;
extern int ServerTimeZone = 0;
extern int TradeFrom1 = 0;
extern int TradeUntil1 = 24;
extern int TradeFrom2 = 0;
extern int TradeUntil2 = 0;
extern int TradeFrom3 = 0;
extern int TradeUntil3 = 0;
extern int TradeFrom4 = 0;
extern int TradeUntil4 = 0;
//extern string s5 = "== Signal Logic ==" for closing if trend change
double MACDOpenLevel = 3;
double MACDCloseLevel = 2;
double MATrendPeriod = 24;
double MacdCurrent, MacdPrevious, SignalCurrent;
double SignalPrevious, MaCurrent, MaPrevious;
double neemwinst = 100;
int MagicNumber;
int total;
int checkorder=1;
int SlipPage;
double newLots,noLots;
double dLots;
double Points,SL,TP,FP,pBid,pAsk;
string strSymbol,spread;
double MinLots = 0;
double MaxLots = 0;
double LotStep = 0;
double MaxPctToRisk = 20;
int
NumberOfTries = 5, //Number of tries to set, close orders;
RetryTime = 1;
string filename="";
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
if(Period()==240)
{
MagicNumber=H4MagicNumber;
if(PrefferedSett){
StopLoss = 300;
TakeProfit = 180;
TrailingStop = 90;
}
}
if(Period()==60)
{
MagicNumber=H1MagicNumber;
if(PrefferedSett){
StopLoss = 60;
TakeProfit = 75;
TrailingStop = 50;
}
}
if(Period()==1440)
{
MagicNumber=D1MagicNumber;
// StopLoss = 60;
// TakeProfit = 75;
// TrailingStop = 50;
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
int Signal=0;
int cnt, ticket;
filename=Symbol() + TradeComment + "-" + Month() + "-" + Day() + ".log";
strSymbol = Symbol();
if (ShowComment) subPrintDetails();
if(errorchek()!=""){Alert(errorchek());Sleep(4000);return(0);}
HandleDigits();
if(checkorder<1)
{
Signal = CheckSignal();
if (Signal == 0) return(0);
newLots=GetLots();
if(noLots<MinLots)
{
Print("Only Higher risking if you want to trade minimum Lotsize. Free Margin = ", AccountFreeMargin());
return(0);
}
CheckOpenTrade(Signal);
checkorder=checkorder+1;
return(0);
}
// exit the trade correctly...
if(checkorder>0)
{
total=OrdersTotal();
checkorder=0;
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if( OrderSymbol()!=Symbol()||OrderMagicNumber()!=MagicNumber) continue;
{
if(OrderType()==OP_BUY) // go to long position
{
checkorder=checkorder+1;
pBid = MarketInfo(strSymbol, MODE_BID);
if (StopLoss>0) {SL =(OrderOpenPrice() - (StopLoss*Points));}
if (TakeProfit>0)
{
TP =(OrderOpenPrice() + (TakeProfit*Points));
FP =(OrderOpenPrice() + (2*TakeProfit*Points)); //FakeProfit
}
// check for trailing stop
if(TrailingStop>0)
{
if(pBid-OrderOpenPrice()>Points*TrailingStop)
{
if(OrderStopLoss()<pBid-Points*(TrailingStop+TrailingStep))
{
OrderModify(OrderTicket(),OrderOpenPrice(),pBid-Points*TrailingStop,FP,0,Green);
return(0);
}
if(pBid>TP)
{
OrderClose(OrderTicket(),OrderLots(),Bid,SlipPage,Violet); // close position
return(0);
}
}
}
// modify OrderStopLoss and OrderTakeProfit for Buy
if(OrderStopLoss()==0 && OrderTakeProfit()==0 && (StopLoss>0||TakeProfit>0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),SL,TP,0,Green);
return(0);
}
if(pBid-OrderOpenPrice()>neemwinst*Points)
{
// to simplify the coding and speed up access
// data are put into internal variables
MacdCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0);
MacdPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1);
SignalCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0);
SignalPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1);
MaCurrent=iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,0);
MaPrevious=iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,1);
if(MacdCurrent>0 && MacdCurrent<SignalCurrent && MacdPrevious>SignalPrevious && MacdCurrent>(MACDCloseLevel*Points))
{
OrderClose(OrderTicket(),OrderLots(),Bid,SlipPage,Violet); // close position
return(0); // exit
}
}
}
if(OrderType()==OP_SELL) // go to short position
{
checkorder=checkorder+1;
pAsk = MarketInfo(strSymbol, MODE_ASK);
if (StopLoss>0) {SL =(OrderOpenPrice() + (StopLoss*Points));}
if (TakeProfit>0)
{
TP =(OrderOpenPrice() - (TakeProfit*Points));
FP =(OrderOpenPrice() - (2*TakeProfit*Points));
}
// check for trailing stop
if(TrailingStop>0)
{
if((OrderOpenPrice()-pAsk)>(Points*TrailingStop))
{
if((OrderStopLoss()>(pAsk+Points*(TrailingStop+TrailingStep))) || (OrderStopLoss()==0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),pAsk+Points*TrailingStop,FP,0,Red);
return(0);
}
if(pAsk<TP)
{
OrderClose(OrderTicket(),OrderLots(),Ask,SlipPage,Violet); // close position
return(0);
}
}
}
// modify OrderStopLoss and OrderTakeProfit for Sell
if(OrderStopLoss()==0 && OrderTakeProfit()==0 && (StopLoss>0||TakeProfit>0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),SL,TP,0,Red);
return(0);
}
if(OrderOpenPrice()-pAsk>neemwinst*Points)
{
// to simplify the coding and speed up access
// data are put into internal variables
MacdCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0);
MacdPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1);
SignalCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0);
SignalPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1);
MaCurrent=iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,0);
MaPrevious=iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,1);
if(MacdCurrent<0 && MacdCurrent>SignalCurrent && MacdPrevious<SignalPrevious && MathAbs(MacdCurrent)>(MACDCloseLevel*Points))
{
OrderClose(OrderTicket(),OrderLots(),Ask,SlipPage,Violet); // close position
return(0); // exit
}
}
}
}
}
}
//----
return(0);
}
// the end.
//+-----------------------------------------------------------------------------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| 4 or 5 Digit Broker Account Recognition |
//+------------------------------------------------------------------+
void HandleDigits()
{
// Automatically Adjusts to Full-Pip and Sub-Pip Accounts
if (Digits == 4 || Digits == 2)
{
SlipPage = Slippage;
Points = Point;
}
if (Digits == 5 || Digits == 3)
{
SlipPage = Slippage*10;
Points = Point*10;
}
}
// Lots Sizes and Automatic Money Management
double GetLots()
{
dLots=Lots;
MinLots = MarketInfo(Symbol(), MODE_MINLOT);
MaxLots = MarketInfo(Symbol(), MODE_MAXLOT);
LotStep = MarketInfo(Symbol(), MODE_LOTSTEP);
//MM Setup function to calculate Lots
// Tranform Lots to Integer Multiple of LotsStep, then set within Max/Min Limit
// This new MM will work with different MinLot and LotStep
// such as Alpari UK Classic which have Minimum 0.1 then 0.11, 0.12, 0.13 etc
// The EA trades now trading XX% of your account balance. With a maximum of 20%.
// or it trades minimum lotsize if risking 20% is lower then minimum lotsize.
double StopLossPoint;
StopLossPoint = StopLoss;
double RiskEquity = AccountEquity() * (PctToRisk/100);
double eRiskEquity = AccountEquity() * (MaxPctToRisk/100);
double PipValue = MarketInfo(Symbol(), MODE_TICKVALUE) * (Points / MarketInfo(Symbol(), MODE_TICKSIZE));
double eLots = eRiskEquity / (StopLossPoint * PipValue);
if(UseMM){dLots = RiskEquity / (StopLossPoint * PipValue);}
if(eLots < dLots){dLots = eLots;}
noLots = dLots;
if (dLots < MinLots){dLots = MinLots;}
dLots = MinLots + NormalizeDouble(((dLots - MinLots) / LotStep),0) * LotStep;
if (dLots > MaxLots){dLots = MaxLots;}
return (dLots);
}
//----------------------- PRINT COMMENT FUNCTION
void subPrintDetails()
{
string sComment = "";
string SP = " ----------------------------------------\n";
string NL = "\n";
string sDirection = "";
sComment = "secret....v1.0" + NL;
sComment = sComment + NL;
sComment = sComment + "Magic Number " + DoubleToStr(MagicNumber,0)+ NL;
sComment = sComment + "StopLoss " + DoubleToStr(StopLoss,0) + " | ";
sComment = sComment + "TakeProfit " + DoubleToStr(TakeProfit,0) + " | ";
sComment = sComment + "TrailingStop " + DoubleToStr(TrailingStop,0) + NL;
sComment = sComment + "Date: " + Month() +"-"+Day()+"-"+Year()+NL;// " Server Time: " + TimeToStr(TimeCurrent(), TIME_SECONDS) + NL;
sComment = sComment + "GMT Time: " + TimeToStr((TimeCurrent()+ (( 0 - ServerTimeZone) * 3600)), TIME_SECONDS) + NL;
sComment = sComment + "ServerTimeZone: " + ServerTimeZone + " (TimeZone)" + NL;
sComment = sComment + SP;
sComment = sComment + "Lot Size " + DoubleToStr(newLots,2) + NL;
Comment(sComment);
}
//+------------------------------------------------------------------+
string errorchek()
{
if(Bars<100){return("bars less than 100");}
if(TakeProfit<10){return("TakeProfit less than 10");}
//if((Period() != 240) &&(Period() != 60)) {return("Wrong Timeframe choose M240 or M60");}
return("");
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| START Function Open Trade |
//+------------------------------------------------------------------+
int CheckOpenTrade(int signal)
{
int err = 0;
//Opening Sell
if(signal==1)
{
if(OrderSend(Symbol(),OP_SELL,newLots,Bid,Slippage,0,0,"FirstTrade",MagicNumber,0,Coral) < 0)
{
err = GetLastError();
Print("Error Ordersend(",err,"): ");
return(-1);
}
return(0);
}
//Opening Buy
if(signal==2)
{
if(OrderSend(Symbol(),OP_BUY,newLots,Ask,Slippage,0,0,"FirstTrade",MagicNumber,0,LightBlue) < 0)
{
err = GetLastError();
Print("Error Ordersend(",err,"): ");
return(-1);
}
return(0);
}
}
//+------------------------------------------------------------------+
//| END Function Open Trade |
//+------------------------------------------------------------------+
//===SIGNALS=========FOR===BUY==OR==SELL==============
int CheckSignal()
{
//=====================SIGNAL1========================
bool BuySignal1=false, SellSignal1=false;
//Smoothed ADX
if(UseSignal1)
{
int ADXPeriod =14;
double nowplusdi0 = iADX(NULL,0,ADXPeriod,PRICE_CLOSE,MODE_PLUSDI,0);
double nowplusdi1 = iADX(NULL,0,ADXPeriod,PRICE_CLOSE,MODE_PLUSDI,1);
double nowminusdi0 = iADX(NULL,0,ADXPeriod,PRICE_CLOSE,MODE_MINUSDI,0);
double nowminusdi1 = iADX(NULL,0,ADXPeriod,PRICE_CLOSE,MODE_MINUSDI,1);
if(nowplusdi0>nowplusdi1){BuySignal1 = true;} //nowminusdi0>nowminusdi1 &&
if(nowminusdi0<nowminusdi1){SellSignal1 = true;}//&& nowplusdi0<nowplusdi1
}
else {SellSignal1=true;BuySignal1=true;}
//=====================SIGNAL2========================
//SMA moving average period 20
bool BuySignal2=false, SellSignal2=false;
int SMAPeriod=20;
if(UseSignal2)
{
double SMA1=iMA(NULL,0,SMAPeriod,0,MODE_SMA,PRICE_CLOSE,0);//SMA-Current
double SMA2=iMA(NULL,0,SMAPeriod,0,MODE_SMA,PRICE_CLOSE,1);//SMA-Previous
if((SMA2-SMA1>0) && (Close[0]<SMA1)) {SellSignal2 = true;}
if((SMA1-SMA2>0) && (Close[0]>SMA1)) {BuySignal2 = true;}
}
else {SellSignal2=true;BuySignal2=true;}
//=====================SIGNAL3========================
bool BuySignal3=false, SellSignal3=false;
if(UseSignal3)
{
if(High[1]>High[2]&&Low[1]<Low[2]&&Close[0]<Low[1]) {SellSignal3 = true;}
if(High[1]>High[2]&&Low[1]<Low[2]&&Close[0]>High[1]) {BuySignal3 = true;}
}
else {SellSignal3=true;BuySignal3=true;}
//=====================SIGNAL4=======================
bool BuySignal4=false, SellSignal4=false;
if(UseSignal4)
{
int iHour=TimeHour(TimeCurrent()+ (( 0 - ServerTimeZone) * 3600));
int ValidTradeTime = F_ValidTradeTime(iHour);
if(ValidTradeTime==true)
{
BuySignal4=true;
SellSignal4=true;
}
}
else {SellSignal4=true;BuySignal4=true;}
if((SellSignal1==true) && (SellSignal2==true) && (SellSignal3==true) && (SellSignal4==true)) return(1);
if((BuySignal1==true) && (BuySignal2==true) && (BuySignal3==true) && (BuySignal4==true)) return(2);
return (0);
}
//====================================================
//+------------------------------------------------------------------+
//| START Function Valid Trade Time |
//+------------------------------------------------------------------+
bool F_ValidTradeTime (int iHour)
{
if(((iHour >= TradeFrom1) && (iHour <= (TradeUntil1-1)))||((iHour>= TradeFrom2) && (iHour <= (TradeUntil2-1)))
||((iHour >= TradeFrom3)&& (iHour <= (TradeUntil3-1)))||((iHour >= TradeFrom4) && (iHour <=(TradeUntil4-1))))
{
return (true);
}
else
return (false);
}
//+------------------------------------------------------------------+
//| END Function Valid Trade Time |
//+------------------------------------------------------------------+ Gebruiken voor eigen risico
De indicatoren en beschrijving waarover het gaat kun je hier vinden
secret-forex-indicator.blogspot.com/
Ik zie dat het werkt makelijker dan een foto
Please Log in or Create an account to join the conversation.
- Jonkie76
-
- Offline
- Platinum Member
-
- Posts: 1001
- Thank you received: 0
Maar goed, zoals je ziet heb ik de uiteindelijke antwoord/oplossing op mijn vraag gevonden! Maar ook jullie bedankt voor jullie reacties..!!
Please Log in or Create an account to join the conversation.
- deVries
-
- Offline
- Junior Member
-
- Posts: 25
- Thank you received: 0
Ik had nog niet gezien dat iemand dit hier gebruikt had. Ben hoofdzakelijk zelf bezig met oefenen en coderen in mq4... Alleen die smileys zouden niet in de code geplaatst moeten worden hier. Een punt voor de moderators om even naar te kijken of dat misschien verbeterd kan worden. Een klein stukje code zou op deze manier makelijk gekopieerd kunnen worden, om het dan in de metaeditor voor jezelf te bewerken...
Ik waardeer je werk hier hoe je ook hier op jouw manier uitleg hebt gegeven over programeren in mq4. Succes allemaal met trading...
Please Log in or Create an account to join the conversation.
- Jonkie76
-
- Offline
- Platinum Member
-
- Posts: 1001
- Thank you received: 0
Als er antwoord op komt, post ik deze hier ook.
Het is mijn laatste vraagstuk die nog open staat in mijn expert advisor.
=========================================================================
Hello Guys and Girls.
At some point in my programm I'd like to call for a function.
However the function has no return value (void). So how do I call the function,
so it executes the code inside the function exactly on the place where I call for it,
as if it was written on that place itself?
I made some example code below.. where I check some parameters, and if Ok, I want to execute the function...
Hope someone can help me with this, tx in advance, Jonkie76
//+
+
//| expert start function |
//+
+
int start()
{
//----
if (Price >= PRICE_CLOSE)
call function ; // At this point I'd like to call the function.How do I do that?
else
Alert("Do nothing"); //
//----
return(0);
}
//+
+
//===================================================================+
//FUNCTIONS
//===================================================================+
//
CLOSE ORDER FUNCTION
+
void subCloseOrder()
{
int
i,
total = 0,
ticket = 0,
err = 0,
c = 0;
total = OrdersTotal();
for(i=total-1;i>=0;i--)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol() &&
OrderMagicNumber()==Magic)
{
switch(OrderType())
{
case OP_BUY :
for(c=0;c<NumberOfTries;c++)
{
ticket=OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Violet);
err=GetLastError();
if(err==0)
{
if(ticket>0) break;
}
else
{
if(err==0 || err==4 || err==136 || err==137 || err==138 || err==146) //Busy errors
{
Sleep(5000);
continue;
}
else //normal error
{
if(ticket>0) break;
}
}
}
break;
}
}
}
}
Please Log in or Create an account to join the conversation.