Quite new to forex as well as MT4 and want to thank all people on this and other threads for the enthusiasm and ideas.
I have gone through the code posted by ForexFlash and do think there is an issue with brackets. ForexFlash, below i post an extract of a local copy that i made which does seem to do both buy and sell:
if(
MarketAnalize()==-1
&& myMA*(1+Percent/100)<Bid
&& Direction!=22
&& (Bid>=(LastPrice+(CurrentPipStep*Point)) || MyOrdersTotal()==0)
&& RVI<0
) // modified by Renato
{
LogWrite("SELL: " + MarketAnalize() + " myMA: " + myMA + "Bid: " + Bid + "Direction: " + Direction + "LastPrice: " + LastPrice + "MyOrdersTotal: "+ MyOrdersTotal() + "RVI: " + RVI);
OrderSend(Symbol(),OP_SELL,Lots,Bid,slip,Bid+(Stoploss*Point),Bid-(TakeProfit*Point),GetCommentForOrder(),MagicNumber,0,clOpenSell); // modified by Renato
ret = 1;
}
if(
MarketAnalize()==1
&& myMA*(1-Percent/100)>Ask
&& Direction!=11
&& (Ask<=(LastPrice-(CurrentPipStep*Point)) || MyOrdersTotal()==0)
&& RVI>0
) // Go LONG -> Only buy if >= 30 pips below previous position entry // modified by Renato
{
LogWrite("BUY: " + MarketAnalize() + " myMA: " + myMA + "Bid: " + Bid + "Direction: " + Direction + "LastPrice: " + LastPrice + "MyOrdersTotal: "+ MyOrdersTotal() + "RVI: " + RVI);
OrderSend(Symbol(),OP_BUY,Lots,Ask,slip,Ask-(Stoploss*Point),Ask+(TakeProfit*Point),GetCommentForOrder(),MagicNumber,0,clOpenBuy); // modified by Renato
ret = 2;
}
Please check and see if this was the intention.
Fredella
I have gone through the code posted by ForexFlash and do think there is an issue with brackets. ForexFlash, below i post an extract of a local copy that i made which does seem to do both buy and sell:
if(
MarketAnalize()==-1
&& myMA*(1+Percent/100)<Bid
&& Direction!=22
&& (Bid>=(LastPrice+(CurrentPipStep*Point)) || MyOrdersTotal()==0)
&& RVI<0
) // modified by Renato
{
LogWrite("SELL: " + MarketAnalize() + " myMA: " + myMA + "Bid: " + Bid + "Direction: " + Direction + "LastPrice: " + LastPrice + "MyOrdersTotal: "+ MyOrdersTotal() + "RVI: " + RVI);
OrderSend(Symbol(),OP_SELL,Lots,Bid,slip,Bid+(Stoploss*Point),Bid-(TakeProfit*Point),GetCommentForOrder(),MagicNumber,0,clOpenSell); // modified by Renato
ret = 1;
}
if(
MarketAnalize()==1
&& myMA*(1-Percent/100)>Ask
&& Direction!=11
&& (Ask<=(LastPrice-(CurrentPipStep*Point)) || MyOrdersTotal()==0)
&& RVI>0
) // Go LONG -> Only buy if >= 30 pips below previous position entry // modified by Renato
{
LogWrite("BUY: " + MarketAnalize() + " myMA: " + myMA + "Bid: " + Bid + "Direction: " + Direction + "LastPrice: " + LastPrice + "MyOrdersTotal: "+ MyOrdersTotal() + "RVI: " + RVI);
OrderSend(Symbol(),OP_BUY,Lots,Ask,slip,Ask-(Stoploss*Point),Ask+(TakeProfit*Point),GetCommentForOrder(),MagicNumber,0,clOpenBuy); // modified by Renato
ret = 2;
}
Please check and see if this was the intention.
Fredella