[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 268

 

extern string AlliesO1 = "GBPUSD"; - валюта

string AlliesO[5]; - массив в котором хранятся валюты.



Так я проверяю нужно ли добавлять валюту в массив. (Изначально вместо валют нули, всего валют 5)

if (StringLen (AlliesO1)>2)
{
CountAlliesO++;
AlliesO [0] = AlliesO1;
}





Потом в цикле перебираю валюты и на каждой валюте открываю ордер.

for (int i=0;i<CountAlliesO;i++)

{
l_ticket_4 = OrderSend(AlliesO[i], OP_BUY, Lots, NormalizeDouble(Ask, Digits), l_slippage_8, iif(StopLoss == 0.0, 0, NormalizeDouble(Ask - StopLoss / MathPow(10, Digits), Digits)), iif(TakeProfit == 0.0, 0, NormalizeDouble(Ask +
TakeProfit / MathPow(10, Digits), Digits)), 0, Magic, 0, CLR_NONE);
Print ("Ticket " + Allies[i] + ": " + l_ticket_4);
}



This is what it outputs:

22:05:25 RSI_Valut_Test2 EURUSD,H1: CountAlliesO: 2
22:05:25 RSI_Valut_Test2 EURUSD,H1: CountEnemyO: 2
22:05:25 RSI_Valut_Test2 EURUSD,H1: Allies: GBPUSD // - in the loop print AlliesO[i].
22:05:25 RSI_Valut_Test2 EURUSD,H1: Allies: GBPUSD
22:05:25 RSI_Valut_Test2 EURUSD,H1: Enemy: USDCHF
22:05:25 RSI_Valut_Test2 EURUSD,H1: Enemy: USDCHF
22:05:25 RSI_Valut_Test2 EURUSD,H1: Ticket USDCHF: -1

22:05:25 RSI_Valut_Test2: symbol name for OrderSend function must be a string


Well in general so-and-so, I can't give all code, as asked not to distribute... Well, a couple of printers were thrown in there which output these data... Why does it say it's not a string? If it's declared as a string?


Please help me, thanks in advance.

 

Good evening all. Please advise how to write a proper function to close an order after a few bars have been opened, and how to optimize this number.

 

CountBars - number of bars.

Ticket - order number.

CloseAfterSomeBar (int CountBars, int Ticket)

{
OrderSelect (Ticket, SELECT_BY_TICKET, MODE_TRADES)
datetime date = OrderOpenTime();
int BarShift = iBarShift (Symbol(), 0, date, false);
if (CountBars>=BarShift)
{
if (OrderType() = OP_BUY)
OrderClose(Ticket,OrderLots(),Bid, (Ask - Bid) / Point, CLR_NONE);
else
OrderClose(Ticket,OrderLots(),Ask, (Ask - Bid) / Point, CLR_NONE);
}
}


Run on every tick, not sure about the number of bars, it may be -1, or +1, because I don't know exactly how the offset is calculated... Well, it's not hard to check on M1...

Is it like that?

 
PODLIY16:

CountBars - number of bars.

Ticket - order number.

CloseAfterSomeBar (int CountBars, int Ticket)

{
OrderSelect (Ticket, SELECT_BY_TICKET, MODE_TRADES)
datetime date = OrderOpenTime();
int BarShift = iBarShift (Symbol(), 0, date, false);
if (CountBars>=BarShift)
{
if (OrderType() = OP_BUY)
OrderClose(Ticket,OrderLots(),Bid, (Ask - Bid) / Point, CLR_NONE);
else
OrderClose(Ticket,OrderLots(),Ask, (Ask - Bid) / Point, CLR_NONE);
}
}


Run on every tick, not sure about the number of bars, it may be -1, or +1, because I don't know exactly how the offset is calculated... Well, it's not hard to check on M1...

Is that it?

 
isaev-av:

I guess so. I'm not a programmer. I'll try it now. The main thing is to make it work on the TF.
 
void CloseAfterSomeBar (int CountBars, int Ticket)
{
OrderSelect (Ticket, SELECT_BY_TICKET, MODE_TRADES);
datetime date = OrderOpenTime();
int BarShift = iBarShift (Symbol(), 0, date, false);
if (BarShift>=CountBars)
{
if (OrderType() == OP_BUY)
OrderClose(Ticket,OrderLots(),Bid, (Ask - Bid) / Point, CLR_NONE);
else
OrderClose(Ticket,OrderLots(),Ask, (Ask - Bid) / Point, CLR_NONE);
}
}


This one is correct, it closes the order as soon as the right bar opens, for example on M1 I just tried it, the order opened at the ninth minute, closed at 11:01.

 
Can you tell me how to overlay a MA on an RSI or Stohastic indicator, i.e. take the MA not from a chart but from an indicator?
 
It's not working. Maybe someone can correct it. Good evening everyone. Please advise how to write a proper function to close an order after a few bars have been opened, and how to optimize this number.
Files:
 

Try it with 2 new variables:


extern bool IfTrueThenCountBarWork = false; // - if false, this function will not work, to work it is necessary to set true.

extern inttern CountBar = 0; // - number of bars after which to close. I have described above how bars are counted.


I hope I have done something useful.

Files:
 
PODLIY16:

Try it with 2 new variables:


extern bool IfTrueThenCountBarWork = false; // - if you set false, this function will not work, you should set true for it to work.

extern int CountBar = 0; // - number of bars after which to close. How the bars are counted, I wrote above.


I hope I have helped you in some way.




Thank you!
Reason: