hello ;
i am here provided with a small part of my strategy...
if buy takes profit next will be a buy but if it ends in stop loss ordertype will change from 0 to 1...same case for sell..each time it inccurs a loss ordertype will negate....source:-
as a sl occurs it should reverse its direction but not happening...anybody with suggestions
Are you trying to confuse yourself ?
bool true or false
int 0 or 1
why make your code harder to read by mixing bools with ints ? OrderSend() requires a int for the order type, read the documentation and see for yourself.
Are you trying to confuse yourself ?
bool true or false
int 0 or 1
why make your code harder to read by mixing bools with ints ? OrderSend() requires a int for the order type, read the documentation and see for yourself.
//+------------------------------------------------------------------+ //| tester n.mq4 | //| Copyright 2013, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright 2013, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #include <stdlib.mqh> int sl=8,ab,ticket1,ticket2,tp; double abc; bool fot=0,pot=0,flag=0; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { if(OrdersTotal()>0) { OrderSelect(0,SELECT_BY_POS); abc=OrderTakeProfit(); ab=OrderStopLoss(); tp=OrderType(); if(tp==0) { if(CompareDoubles(Bid,abc)) flag=1; } if(tp==1) { if(CompareDoubles(Ask,abc)) flag=1; } } if(OrdersTotal()==0) { if (flag!=1) pot=(!fot); if(pot==0) ticket1=OrderSend(Symbol(),0,0.01,Ask,3,Ask-sl*Point,Ask+sl*Point,0,0,0); if(pot==1) ticket2=OrderSend(Symbol(),1,0.01,Bid,3,Bid+sl*Point,Bid-sl*Point,0,0,0); flag=0; } } //+------------------------------------------------------------------+
hello ;
i am here provided with a small part of my strategy...
if buy takes profit next will be a buy but if it ends in stop loss ordertype will change from 0 to 1...same case for sell..each time it inccurs a loss ordertype will negate....source:-
as a sl occurs it should reverse its direction but not happening...anybody with suggestions
I would think you meant to check the most recent order in history rather than a currently open trade. If an order has hit TP or SL it will always be in the history. Once selected from history, you could determine profit/loss status by checking OrderProfit() and then updating your flag to trade according to your rules when you open the next trade.
Regards, Paul.
Are you trying to confuse yourself ?
bool true or false
int 0 or 1
why make your code harder to read by mixing bools with ints ? OrderSend() requires a int for the order type, read the documentation and see for yourself.
done that but same results..
No you haven't, you still have
bool fot=0,pot=0,flag=0; // and if (flag!=1) pot=(!fot); if(pot==0)
and now you are using 0 and 1 for Order Types, why not use OP_BUY and OP_SELL ?
I would think you meant to check the most recent order in history rather than a currently open trade. If an order has hit TP or SL it will always be in the history. Once selected from history, you could determine profit/loss status by checking OrderProfit() and then updating your flag to trade according to your rules when you open the next trade.
Regards, Paul.
thats the way i like it..thanku....

- 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 ;
i am here provided with a small part of my strategy...
if buy takes profit next will be a buy but if it ends in stop loss ordertype will change from 0 to 1...same case for sell..each time it inccurs a loss ordertype will negate....source:-
as a sl occurs it should reverse its direction but not happening...anybody with suggestions