/*[[ Name := BTSimpleExpert
Author := BontBoy + Jesse Breaker
Link := Forex Trading Software: Forex Trading Platform MetaTrader 4
Notes := If you want to use BrainTrend1 signals to generate your buy/sells, set the UseBT1 Sig to 1
Notes := Same for BT2. Can also use both by setting both to 1.
Notes := If you want to use the trailing stop values of BT1 or 2 , set the relevant UseBTxTS to 1
Notes := Set your required take profit value in ProfitValue
Lots := 1.00
Stop Loss := 30
Take Profit := 100
Trailing Stop := 0
]]*/
defines: UseBT1Sig(1), UseBT2Sig(0), UseBT1TS(1), UseBT2TS(0), ProfitValue(10),Slippage(5),midprice(0),TrendSignal(0),HighTrend(0),MediumTrend(0),FH(0);
var: CustVal(0), PrevSnapShot(0);
var: i(0),cnt(0),filler(0),mode(0), BT1SellVal(0), BT2SellVal(0), BT1BuyVal(0), BT2BuyVal(0),Filer(0);
var : BTStopVal(0), InitStopValBuy(0),InitStopValSell(0), PairDivider(0);
//Only execute this once per bar
if PrevSnapShot = Time then exit;
PrevSnapShot = Time;
FH=FileOpen(Symbol + "HighTrend",",");
HighTrend=FileReadNumber(FH);
FileClose(fh);
FH=FileOpen(Symbol + "MediumTrend",",");
MediumTrend=FileReadNumber(FH);
FileClose(fh);
If HighTrend = 1 and MediumTrend = 1 then
{
TrendSignal=1;
};
If HighTrend = -1 and MediumTrend = -1 then
{
TrendSignal=-1;
};
If HighTrend = 0 or MediumTrend = 0 then
{
exit;
};
//For various JPY pairs, divide the takeprofit term by 100 to give you the correct stop/tp level, otherwise divide by 10000
if (Symbol = "USDJPY") or (Symbol = "EURJPY") or (Symbol = "GBPJPY") then
PairDivider = 100
else
PairDivider = 10000;
For cnt=1 to TotalTrades //We have a trade open
{
if OrderValue(cnt,VAL_SYMBOL)= Symbol then
{
BT1SellVal=iCustom("BrainTrend1Sig",400,MODE_FIRST,1); //Get the value of the BT1 Signal used for SELL signals
BT1BuyVal=iCustom("BrainTrend1Sig",400,MODE_SECOND,1); //Get the value of the BT1 Signal used for BUY signals
BT2SellVal=iCustom("BrainTrend2Sig",400,MODE_SECOND,1); //Get the value of the BT2 Signal used for SELL signals
BT2BuyVal=iCustom("BrainTrend2Sig",400,MODE_FIRST,1); //Get the value of the BT2 Signal used for BUY signals
mode=OrderValue(cnt,VAL_TYPE);
if UseBT1TS then //If we have chosen to use the BT1 stop signals, set the initial stop to the BT1 Value
{
InitStopValBuy = BT1BuyVal;
InitStopValSell = BT1SellVal;
if ord(cnt,VAL_TYPE)=OP_BUY then //It is a BUY trade
BTStopVal=iCustom("BrainTrend1Stopline",500,MODE_SECOND,1) //Get the value of the BTStop line
else
BTStopVal=iCustom("BrainTrend1Stopline",500,MODE_FIRST,1); //Get the value of the BTStop line
};
if UseBT2TS then //If we have chosen to use the BT2 stop signals, set the initial stop to the BT2 Value
{
InitStopValBuy = BT2BuyVal;
InitStopValSell = BT2SellVal;
if ord(cnt,VAL_TYPE)=OP_BUY then //It is a BUY trade
BTStopVal=iCustom("BrainTrend2Stopline",500,MODE_FIRST,1) //Get the value of the BTStop line
else
BTStopVal=iCustom("BrainTrend2Stopline",500,MODE_SECOND,1); //Get the value of the BTStop line
};
if UseBT1TS < 1 and UseBT2TS < 1 then //If we are not using either trailingstop, use the standard StopLoss
{
If StopLoss=0 then
{
InitStopValBuy = -1;
InitStopValSell = -1;
};
If StopLoss 0 then
{
InitStopValBuy = C[0] - StopLoss / PairDivider;
InitStopValSell = C[0] + StopLoss / PairDivider;
};
};
//Change -ve numbers to 0
if InitStopValBuy < 0 then InitStopValBuy = 0;
if InitStopValSell < 0 then InitStopValSell = 0;
if UseBT1Sig > 0 and UseBT2Sig > 0 then //If we are using both BT1sig and BT2sig to generate the buy/sell signals
{
if (BT1SellVal >0 and BT2SellVal>0) and (TrendSignal=0) then //BT1Sig and BT2Sig SELL dots have been plotted by BrainTrading
{
if mode=OP_BUY then // A sell came in and cancelled our order, but opened up a new Sell Stop
{
CloseOrder(ord(cnt,VAL_TICKET),ord(cnt,VAL_LOTS),bid,0,white);
SetOrder(OP_SELL,lots,bid,slippage,InitStopValSell,bid-(ProfitValue / PairDivider),White);
};
if mode=OP_SELL then // A sell came in and is just confirming our entry, COOL!
{
Filler=1;
};
};
if (BT1BuyVal >0 and BT2BuyVal>0) and (TrendSignal=0) then //BT1Sig and BT2Sig Buy dots have been plotted by BrainTrading
{
if mode=OP_SELL then // A sell came in and cancelled our order, but opened up a new buy Stop
{
CloseOrder(ord(cnt,VAL_TICKET),ord(cnt,VAL_LOTS),ask,0,white);
SetOrder(OP_BUY,lots,ask,slippage,InitStopValBuy,ask+(ProfitValue / PairDivider),White) ;
};
if mode=OP_BUY then // A sell came in and is just confirming our entry, COOL!
{
Filler=1;
};
};
If (!(BT1SellVal >0 and BT2SellVal>0)) and (!(BT1BuyVal >0 and BT2BuyVal>0)) then // no dot apperared so let's check the stop loss
{
if BTStopVal > 0 and BTStopVal ord(cnt,VAL_STOPLOSS) then //The stop line value is different to the current stoploss
ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE),BTStopVal,Ord(cnt,VAL_TAKEPROFIT),White); //Modify the stoploss value
};
};
if UseBT1Sig > 0 and UseBT2Sig < 1 then //If we are only using BT1Sig to generate buy/sell signals
{
if (BT1SellVal >0) and (TrendSignal=0) then //BT1Sig SELL dots have been plotted by BrainTrading
{
if mode=OP_BUY then // A sell came in and cancelled our order, but opened up a new Sell Stop
{
CloseOrder(ord(cnt,VAL_TICKET),ord(cnt,VAL_LOTS),bid,0,white);
SetOrder(OP_SELL,lots,bid,slippage,InitStopValSell,bid-(ProfitValue / PairDivider),White);
};
if mode=OP_SELL then // A sell came in and is just confirming our entry, COOL!
{
Filler=1;
};
};
if (BT1BuyVal >0) and (TrendSignal=0) then //BT1Sig Buy dots have been plotted by BrainTrading
{
if mode=OP_SELL then // A sell came in and cancelled our order, but opened up a new buy Stop
{
CloseOrder(ord(cnt,VAL_TICKET),ord(cnt,VAL_LOTS),ask,0,white);
SetOrder(OP_BUY,lots,ask,slippage,InitStopValBuy,ask+(ProfitValue / PairDivider),White) ;
};
if mode=OP_BUY then // A sell came in and is just confirming our entry, COOL!
{
Filler=1;
};
};
If (!(BT1SellVal >0)) and (!(BT1BuyVal >0 )) then // no dot apperared so let's check the stop loss
{
if BTStopVal > 0 and BTStopVal ord(cnt,VAL_STOPLOSS) then //The stop line value is different to the current stoploss
ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE),BTStopVal,Ord(cnt,VAL_TAKEPROFIT),White); //Modify the stoploss value
};
};
if UseBT1Sig 0 then //If we are only using BT2Sig to generate buy/sell signals
{
if (BT2SellVal >0) and (TrendSignal=0) then //BT2Sig SELL dots have been plotted by BrainTrading
{
if mode=OP_BUY then // A sell came in and cancelled our order, but opened up a new Sell Stop
{
CloseOrder(ord(cnt,VAL_TICKET),ord(cnt,VAL_LOTS),bid,0,white);
SetOrder(OP_SELL,lots,bid,slippage,InitStopValSell,bid-(ProfitValue / PairDivider),White);
};
if mode=OP_SELL then // A sell came in and is just confirming our entry, COOL!
{
Filler=1;
};
};
if (BT2BuyVal >0) and (TrendSignal=0) then //BT2Sig Buy dots have been plotted by BrainTrading
{
if mode=OP_SELL then // A sell came in and cancelled our order, but opened up a new buy Stop
{
CloseOrder(ord(cnt,VAL_TICKET),ord(cnt,VAL_LOTS),ask,0,white);
SetOrder(OP_BUY,lots,ask,slippage,InitStopValBuy,ask+(ProfitValue / PairDivider),White) ;
};
if mode=OP_BUY then // A sell came in and is just confirming our entry, COOL!
{
Filler=1;
};
};
If (!(BT2SellVal >0)) and (!(BT2BuyVal >0 )) then // no dot apperared so let's check the stop loss
{
if BTStopVal > 0 and BTStopVal ord(cnt,VAL_STOPLOSS) then //The stop line value is different to the current stoploss
ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE),BTStopVal,Ord(cnt,VAL_TAKEPROFIT),White); //Modify the stoploss value
};
};
};
};
if TotalTrades<1 then //There are no trades open
{
BT1SellVal=iCustom("BrainTrend1Sig",400,MODE_FIRST,1); //Get the value of the BT1 Signal used for SELL signals
BT1BuyVal=iCustom("BrainTrend1Sig",400,MODE_SECOND,1); //Get the value of the BT1 Signal used for BUY signals
BT2SellVal=iCustom("BrainTrend2Sig",400,MODE_SECOND,1); //Get the value of the BT2 Signal used for SELL signals
BT2BuyVal=iCustom("BrainTrend2Sig",400,MODE_FIRST,1); //Get the value of the BT2 Signal used for BUY signals
midprice=abs(low[1]-high[1]);
if UseBT1TS then //If we have chosen to use the BT1 stop signals, set the initial stop to the BT1 Value
{
InitStopValBuy = BT1BuyVal;
InitStopValSell = BT1SellVal;
//InitStopValBuy = Low[1];
//InitStopValSell = High[1];
};
if UseBT2TS then //If we have chosen to use the BT2 stop signals, set the initial stop to the BT2 Value
{
InitStopValBuy = BT2BuyVal;
InitStopValSell = BT2SellVal;
//InitStopValBuy = Low[1];
//InitStopValSell = High[1];
};
if UseBT1TS < 1 and UseBT2TS < 1 then //If we are not using either trailingstop, use the standard StopLoss
{
If StopLoss=0 then
{
InitStopValBuy = -1;
InitStopValSell = -1;
};
If StopLoss 0 then
{
InitStopValBuy = C[0] - StopLoss / PairDivider;
InitStopValSell = C[0] + StopLoss / PairDivider;
};
};
//Change -ve numbers to 0
if InitStopValBuy < 0 then InitStopValBuy = 0;
if InitStopValSell < 0 then InitStopValSell = 0;
if UseBT1Sig > 0 and UseBT2Sig > 0 then //If we are using both BT1sig and BT2sig to generate the buy/sell signals
{
if (BT1SellVal >0 and BT2SellVal>0) and (TrendSignal=-1 or TrendSignal=0) then //BT1Sig and BT2Sig SELL dots have been plotted by BrainTrading
SetOrder(OP_SELL,lots,bid,slippage,InitStopValSell,bid-(ProfitValue / PairDivider),White);
if (BT1BuyVal >0 and BT2BuyVal>0) and (TrendSignal=1 or TrendSignal=0)then //BT1Sig and BT2Sig BUY dots have been plotted by BrainTrading
SetOrder(OP_BUY,lots,ask,slippage,InitStopValBuy,ask+(ProfitValue / PairDivider),White) ;
};
if UseBT1Sig > 0 and UseBT2Sig < 1 then //If we are only using BT1Sig to generate buy/sell signals
{
if (BT1SellVal >0) and (TrendSignal=-1 or TrendSignal=0) then //BT1Sig SELL dot has been plotted by BrainTrading
SetOrder(OP_SELL,lots,bid,slippage,InitStopValSell,bid-(ProfitValue / PairDivider),White);
if (BT1BuyVal >0) and (TrendSignal=1 or TrendSignal=0) then //BT2Sig BUY dot has been plotted by BrainTrading
SetOrder(OP_BUY,lots,ask,slippage,InitStopValBuy,ask+(ProfitValue / PairDivider),White) ;
};
if UseBT1Sig 0 then //If we are only using BT2Sig to generate buy/sell signals
{
if (BT2SellVal>0) and (TrendSignal=-1 or TrendSignal=0) then //BT2Sig SELL dot has been plotted by BrainTrading
SetOrder(OP_SELL,lots,bid,slippage,InitStopValSell,bid-(ProfitValue / PairDivider),White);
if (BT2BuyVal>0) and (TrendSignal=1 or TrendSignal=0) then //BT2Sig BUY dot has been plotted by BrainTrading
SetOrder(OP_BUY,lots,ask,slippage,InitStopValBuy,ask+(ProfitValue / PairDivider),White) ;
};
};
Comment("Day : ",Day," Hour : ",Hour," Min ",Minute," Seconds ", Seconds,
"\n","TrendSignal : ",TrendSignal," HighTrend = ",HighTrend," MediumTrend = ",MediumTrend);
FH=FileOpen("v7",",");
While !(IsFileEnded(FH)) Begin
Filer=FileReadString(FH);
End;
FileWrite(FH,"Month",month,"Day : ",Day," Hour : ",Hour," Min ",Minute," Seconds ", Seconds," : MT = ",MediumTrend," HT = ",HighTrend, "TrendSignal = ",TrendSignal);
FileClose(fh);
It would be nice to see it made into an EA, is there one over at TSD already?

Good morning, I wanted to ask for information, I tried to compile an EA under the code I brought over, but does not work, I brought several compilation errors.
Wanted hiedere if someone before me has already tried and perhaps solved the problem?
Thanks

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello friends, found the source code in the brain trend, but as not understand anything about the language mq4 when simply enter in goal editor and put pra compile several errors appear! Someone by accident would not schedule this code?