Thread: How to code?
View Single Post
  #1874 (permalink)  
Old 07-02-2009, 03:27 PM
rortiz77 rortiz77 is offline
Junior Member
 
Join Date: Jun 2009
Posts: 3
rortiz77 is on a distinguished road
Unhappy NewB in need of some help with coding

Hi All,

I'm in need of some disparate help here. I've got some code that will look for an agreement between different indicators. Once they all agree I want a way for the trades to enter in the way I described it in the chart images. So far I can enter the 1st "Buy" trade but it doesn't enter just 1 trade....it's entering up to 8 trades. And then, if the market goes against me I enter a "contingency trade" where I'm buy/selling again despite that its going against me. I would greatly appreciate if someone could show me what the correct code should look like

Not sure if these images will show but just in case I also have them as attachments.
Pic 1
Pic 2

Here is my flawed code that is supposed to execute the trade...
while (execute_trade ==5)
{if ( OrdersTotal() == buy_trade1 ) //buy_trade1 = 1...this stops it after 1 order have been placed...but doesnt work yet
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+ TakeProfit*Point);
execute_trade=0;

if(OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES))
Print("My ticket is: " , ticket);
{
buy1 = OrderOpenPrice(); //taking the 1st order's price and pushing it into this variable
// Comment("order #1 open price is ", OrderOpenPrice() + " " + buy1 + " less than " + (buy1-0.0030));
if (buy1 >= (buy1-0.0030))
{
//if ( OrdersTotal() <= buy_trade1 ) //this stops it after 1 order have been placed.
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+ TakeProfit*Point);
//execute_trade=0;
}


}
else
Print("OrderSelect returned the error of ",GetLastError());

}
Attached Images
File Type: jpg the perfect buy and sell.jpg (117.6 KB, 101 views)
File Type: jpg Contingency Trades 2.jpg (155.3 KB, 91 views)
Reply With Quote