
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
ok, I got it now; u shld add to the trading technique, and not have a different program. One question though - when will your straddle ends cos u start a new one every new day, so when will the prev day straddle ends?
found an error in prev code: the takeprofit shld be using the value x and not Ask or Bid
if (TimeHour(TimeCurrent())==1 && TimeMinute(TimeCurrent())==0)
{
double x = NormalizeDouble((iHigh(Symbol(),PERIOD_H1,1)+iLow(Symbol(),PERIOD_H1,1))/2.0,Digits);
OrderSend(Symbol(),OP_BUYSTOP,Lots,x+Step*Point,3,x+(Step-SL)*Point,x+(Step+TP)*Point,"",0,0,Green);
OrderSend(Symbol(),OP_SELLSTOP,Lots,x-Step*Point,3,x+(-Step+SL)*Point,x-(Step+TP)*Point,"",0,0,Red);
}
The straddle should end immediately price touches either the take profit or stop loss of the triggered order(s)
It should also end at the close of the day if none of the orders get triggered throughout the whole day.
The straddle should end immediately price touches either the take profit or stop loss of the triggered order(s)
It should also end at the close of the day if none of the orders get triggered throughout the whole day.
A. When one stop order is triggered, it essentially means the other pending order's SL is reached.
Then have a function to count how many pending orders you have
int GetPendingOrdersCount(int magic)
{
int PendingOrderCnt=0;
int total = OrdersTotal();
for(int i = 0; i < total; i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(OrderMagicNumber() == magic)
{
if (OrderType()>1) PendingOrderCnt++;
}
}
return(PendingOrderCnt);
}
Now check for existence of one pending order:
void start()
{
int PendingOrderCnt=GetPendingOrdersCount(MagicNo);
if (PendingOrderCnt==1)
{
total = OrdersTotal();
for(int i = 0; i < total; i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(OrderMagicNumber() == MagicNo)
{
if (OrderType()>1)
{
OrderDelete(OrderTicket());
} //end if (OrderType()>1)
} //end if(OrderMagicNumber() == MagicNo)
}//end for
} //end if
}//end start
A. When one stop order is triggered, it essentially means the other pending order's SL is reached.
Then have a function to count how many pending orders you have
int GetPendingOrdersCount(int magic)
{
int PendingOrderCnt=0;
int total = OrdersTotal();
for(int i = 0; i < total; i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(OrderMagicNumber() == magic)
{
if (OrderType()>1) PendingOrderCnt++;
}
}
return(PendingOrderCnt);
}
Now check for existence of one pending order:
void start()
{
int PendingOrderCnt=GetPendingOrdersCount(MagicNo);
if (PendingOrderCnt==1)
{
total = OrdersTotal();
for(int i = 0; i < total; i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(OrderMagicNumber() == MagicNo)
{
if (OrderType()>1)
{
OrderDelete(OrderTicket());
} //end if (OrderType()>1)
} //end if(OrderMagicNumber() == MagicNo)
}//end for
} //end if
}//end start
I need your advise, running EA tests on strategy tester does not give enough details on its results I wish it could render a simulated account history but all I see is the graph and statistics
How else do you think one can test EA's best
I need your advise, running EA tests on strategy tester does not give enough details on its results I wish it could render a simulated account history but all I see is the graph and statistics
How else do you think one can test EA's best
I am not sure exactly what u are looking for, but backtesting gives us an idea if the codes are correct, to test out some parameters of the strategy but ultimately u need to do a forward test, ie run it off a demo acct for several weeks;
anyway, looking at the Results of tester with the orders placed is generally sufficient to understand if yr strategy is correctly coded
I am not sure exactly what u are looking for, but backtesting gives us an idea if the codes are correct, to test out some parameters of the strategy but ultimately u need to do a forward test, ie run it off a demo acct for several weeks;
anyway, looking at the Results of tester with the orders placed is generally sufficient to understand if yr strategy is correctly coded
The summary of the strategy goes thus
1. Determine the position size to be 0.1% of the available margin
2. Determine the first candle of the day
3. Split the first candle of the day into two and set pending orders buy stop sell stop
4. set expiry time for the pending orders so all the untriggered orders of yesterday get deleted
5. if the sl or tp of the triggered order gets hit, the point where it gets reached becomes another point x where new pending orders will be set
6. immediately the sl or tp of the order(s) get hit all pending orders get deleted automatically
7. the program continues to loop back to 5 till the next day
//The lines below is to declare variables and determine lotsize for the trade
double floatingbalance;
double lotsize;
int Step=40;
int Tp=40;
int SL=120;
floatingbalance = AccountEquity();
lotsize=NormalizeDouble(floatingbalance*0.001,1);
//The line below is to determine the first candle of the day
if (TimeHour(TimeCurrent())==1 && TimeMinute(TimeCurrent())==0)
//The line below is to set the expiration time variable for the pending orders
{
datetime expiretime = TimeCurrent()+24*60*60;
//The line below is to determine point X
double x = NormalizeDouble((iHigh(Symbol(),PERIOD_H1,1)+iLow(Symbol(),PERIOD_H1,1))/2.0,Digits);
//These lines are for setting the pending orders
OrderSend(Symbol(),OP_BUYSTOP,Lots,x+Step*Point,3,x+(Step-SL)*Point,x+(Step+TP)*Point,"",0,expiretime,Green);
OrderSend(Symbol(),OP_SELLSTOP,Lots,x-Step*Point,3,x+(-Step+SL)*Point,x-(Step+TP)*Point,"",0,expiretime,Red);
}
// This is how far I understand the program...
But there are still some important areas which are
1. If one of the pending orders get triggered no pending order should be deleted till the triggered order hits SL or TP
This should be so because there must be an hedge at the entry point of the second order, this makes the loss limited
to 80pips if the second pending order gets deleted the loss will be 120pips instead of 80.
2. If one of the pending orders get triggered and hits TP, the second pending order should be deleted.
3. The point where the previous pending order hit TP or SL should be considered another point X to set the pending orders again.
4. the program should loop back to 1. till the next day thatis (continue to use the Tp or SL of trggered orders as next entry point till the next day)
I'll need your help in putting this parts together
Point 1,2,3 a little tricky, let me think over how to do this.
By the way, if an order gets triggered but has not TP or SL, do u close the order end of day?
Hmm, I think such an order without TP or SL must be closed at the end of the day but that will be a very risky trade especially if it is GBP/JPY
I am thinking of using a detection of the existence of a current triggered order to decide if a new straddle be placed on a new day. So for example, an order has been triggered and not tp or sl and we decide not to close it end of day, then a new straddle on a new day will not be placed. On the other hand if we close the prev day orders and take whatever profit or loss, then a new straddle can be issued on the new day.