I want to make each day open, the ad is loops (Hedging style) The values used to open orders on a daily basis are not equal, they are the values of the day. Some days to order to go to another day. For example: Makes the next order opening time in the first day's loops take the value of Day 2. I want to I do not want to go back to the value of the day itself. I will fix it. Thank you
//////////////////////////////////////////////////////////////////////////////////////////////////////////////int DayOfYearOrderNow;
int OrderNow;
for ( int k= 0 ;k< OrdersTotal ();k++)
{
(OrderNow= OrderSelect (k, SELECT_BY_POS , MODE_TRADES ));
if ( OrderSymbol ()== Symbol () && OrderMagicNumber ()==MagicNumber)
{
if ( OrderType ()== OP_BUY )
{
DayOfYearOrderNow= TimeDayOfYear ( OrderOpenTime ());
}
if ( OrderType ()== OP_SELL )
{
DayOfYearOrderNow= TimeDayOfYear ( OrderOpenTime ());
}
}
}
datetime TradeDate= TimeCurrent ();
int DayOfYearNow= TimeDayOfYear ( TradeDate );
for ( int i= 0 ;i<= (DayOfYearNow - DayOfYearOrderNow);i++) //The number of days that will go back to how many days to see that the outstanding after the day.
{
dPriceHighAll= High [ Highest ( NULL , 0 , MODE_HIGH ,( iBarShift ( NULL , 0 , StrToTime ( TimeToStr (TradeDate-( 86400 *i), TIME_DATE ) + " " + sTimeBegin)))-( iBarShift ( NULL , 0 , StrToTime ( TimeToStr (TradeDate-( 86400 *i), TIME_DATE ) + " " + sTimeEnd))), ( iBarShift ( NULL , 0 , StrToTime ( TimeToStr (TradeDate-( 86400 *i), TIME_DATE ) + " " + sTimeEnd))))];
dPriceLowAll= Low [ Lowest ( NULL , 0 , MODE_LOW ,( iBarShift ( NULL , 0 , StrToTime ( TimeToStr (TradeDate-( 86400 *i), TIME_DATE ) + " " + sTimeBegin)))-( iBarShift ( NULL , 0 , StrToTime ( TimeToStr (TradeDate-( 86400 *i), TIME_DATE ) + " " + sTimeEnd))), ( iBarShift ( NULL , 0 , StrToTime ( TimeToStr (TradeDate-( 86400 *i), TIME_DATE ) + " " + sTimeEnd))))];
if (CountPendingOrderNow()== 0 && CountOrderHISTORY()== 0 )
{
if (i== 0 ) // i=0 use dPriceHighAll dPriceLowAll that day
{
if ( Hour ()== 2 && Minute ()== 30 && Seconds ()== 0 ) //open frist order of day loop this time
{
int EXP= 23 - StrToDouble (periodEnd);
int onebuystop1= OrderSend ( Symbol (), OP_BUYSTOP ,CanLoss/(( MathAbs ((dPriceHighAll-dPriceLowAll))/ Point )* MarketInfo ( Symbol (), MODE_TICKVALUE )),dPriceHighAll, 0 ,dPriceLowAll,dPriceHighAll+(dPriceHighAll-dPriceLowAll), "onebuystop1" +DayOfYearNow,MagicNumber,EXP, clrGreen );
int onesellstop1= OrderSend ( Symbol (), OP_SELLSTOP ,CanLoss/(( MathAbs ((dPriceHighAll-dPriceLowAll))/ Point )* MarketInfo ( Symbol (), MODE_TICKVALUE )),dPriceLowAll, 0 ,dPriceHighAll,dPriceLowAll-(dPriceHighAll-dPriceLowAll), "onesellstop1" +DayOfYearNow,MagicNumber,EXP, clrRed );
}
}
}
if (CountPendingOrderNow2()== 0 && CountOrderHISTORY2()== 0 )
{
if (WhatOrderNow()== "onebuystop1" +(DayOfYearNow-i)) // If any of the loops are not closed, use the dPriceHighAll value. dPriceLowAll of that day only
if (ProfitinOneDay()== "Yes" )
{
int twobuystop1ifbuy= OrderSend ( Symbol (), OP_BUYSTOP ,CanLoss/(( MathAbs ((dPriceHighAll-dPriceLowAll))/ Point )* MarketInfo ( Symbol (), MODE_TICKVALUE )),dPriceHighAll+(dPriceHighAll-dPriceLowAll), 0 ,dPriceHighAll,dPriceHighAll+( 2 *(dPriceHighAll-dPriceLowAll)), "twobuystop1ifbuy" +(DayOfYearNow-i),MagicNumber, 0 , clrGreen );
}
int onesellstop2ifbuy= OrderSend ( Symbol (), OP_SELLSTOP , 2 *CanLoss/(( MathAbs ((dPriceHighAll-dPriceLowAll))/ Point )* MarketInfo ( Symbol (), MODE_TICKVALUE )),dPriceLowAll, 0 ,dPriceHighAll,dPriceLowAll-(dPriceHighAll-dPriceLowAll), "onesellstop2ifbuy" +(DayOfYearNow-i),MagicNumber, 0 , clrRed );
}
if (WhatOrderNow()== "onesellstop1" +(DayOfYearNow-i)) // If any of the loops are not closed, use the dPriceHighAll value. dPriceLowAll of that day only
{
int onebuystop2ifsell= OrderSend ( Symbol (), OP_BUYSTOP , 2 *CanLoss/(( MathAbs ((dPriceHighAll-dPriceLowAll))/ Point )* MarketInfo ( Symbol (), MODE_TICKVALUE )),dPriceHighAll, 0 ,dPriceLowAll,dPriceHighAll+(dPriceHighAll-dPriceLowAll), "onebuystop2ifsell" +(DayOfYearNow-i),MagicNumber, 0 , clrGreen );
if (ProfitinOneDay()== "Yes" )
{
int twosellstop1ifsell= OrderSend ( Symbol (), OP_SELLSTOP ,CanLoss/(( MathAbs ((dPriceHighAll-dPriceLowAll))/ Point )* MarketInfo ( Symbol (), MODE_TICKVALUE )),dPriceLowAll-(dPriceHighAll-dPriceLowAll), 0 ,dPriceLowAll,dPriceLowAll-( 2 *(dPriceHighAll-dPriceLowAll)), "twosellstop1ifsell" +(DayOfYearNow-i),MagicNumber, 0 , clrRed );
}
}
}
I want to make each day open, the ad is loops (Hedging style)
The values used to open orders on a daily basis are not equal, they are the values of the day.
Some days to order to go to another day.
For example:
Makes the next order opening time in the first day's loops take the value of Day 2.
I want to I do not want to go back to the value of the day itself.
I will fix it.
Thank you