Forum on trading, automated trading systems and testing trading strategies
When you post code please use the CODE button (Alt-S)!

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi Guys
I'm new to coding and I've got a problem with my sell order opening and closing the trade as soon as it enters. Can anyone figure out why. Im trying to sell when the MinusDi crosses the PlusDI, or when MinusDI is Higher than PlusDI.
Any help would be great.
//....................ENTERING BUY ORDERS CODE FOR "LONG SETUP 1" AND "LONG SETUP 2".........................................
// Check for long trade setup 1 .........................................................
if ((PlusDIone<MinusDIone)&&(PlusDItwo<MinusDItwo)&& (PlusDI>MinusDI))
{
int OrderResult = OrderSend(Symbol(), OP_BUY,LotsToTrade,Ask, 10,0,0,"Buy Order",Magic,0,clrBlue) ; // Ordersend is function for inputting Buy or Sell
LastTradePlacedTimeStamp= TimeCurrent(); // note the time you send the trade used in trade delay code
ExitRuleLong = True;
}
// Long Setup 2 code................................................................................
elseif ((PlusDIone>MinusDIone)&&(PlusDItwo>MinusDItwo)&& ( PlusDI>MinusDI))
{
int OrderResult = OrderSend(Symbol(), OP_BUY,LotsToTrade,Ask,10,0,0,"Buy Order",Magic,0,clrBlue) ; // Ordersend is function for inputting Buy or Sell
LastTradePlacedTimeStamp= TimeCurrent();
ExitRuleLong = True;
}
//.......................ENTERING SELL ORDERS FOR "SHORT SETUP 1" AND "SHORT SETUP 2".....................................
// SHORT SETUP 1
else if ((PlusDIone>MinusDIone)&&(PlusDItwo>MinusDItwo)&& ( PlusDI<MinusDI))
{
int OrderResult = OrderSend(Symbol(), OP_SELL,LotsToTrade,Bid, 10,0,0,"Sell Order",Magic,0,clrBlack) ; // Ordersend is function for inputting Buy or Sell
LastTradePlacedTimeStamp= TimeCurrent(); // note the time you send the trade used in trade delay code
ExitRuleShort = False ;
}
// Short Setup 2
elseif ((PlusDIone<MinusDIone)&&(PlusDItwo<MinusDItwo) && ( PlusDI<MinusDI))
{
int OrderResult = OrderSend(Symbol(), OP_SELL,LotsToTrade,Bid, 10,0,0,"Sell Order",Magic,0,clrBlack) ; // Ordersend is function for inputting Buy or Sell
ExitRuleShort = False ;
LastTradePlacedTimeStamp= TimeCurrent();
}