Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1122

 
Alekseu Fedotov:

It won't go away.

read

Modified

if(Bid == PriceLine)

to

if(NormalizeDouble(Bid,4) == NormalizeDouble(PriceLine,4))

Transactions still do not open at the intersection

 
Fib0 RU:

Modified

to

The trades still do not open on the crossover

The price between ticks is not equal to 1 point, this equality is rare. if from below the price then catch the price is greater or equal. If without controlling where the price came from. it's more complicated. like was less, became more or equal and symmetrical. There are two checks. Either check the line level range plus 5 pips and minus 5 pips.

 
Is it possible for the library to output information to a file (simulate the Print() function) to check what values are inside the library function, tried the usual way of outputting to a file using C++ means did not help, I gave examples earlier, who can give advice?
 
Valeriy Yastremskiy:

the price between ticks is not equal to 1 point, this equality is rare. if from below the price then catch the price is greater or equal. If without controlling where the price came from. It's more complicated. Like it was less, became more or equal and symmetrical. There are two checks. Either check the line level range plus 5 pips and minus 5 pips.

But when setting the lines manually without the indicator, the deals are opened, even if not always. The advisor does not see the indicator lines.
 
Seric29:
Is it possible from library side to output information to file (simulate Print() function) to check what values are inside library function, tried usual way of output to file by C++ means did not help, I gave examples earlier, who can advise what?
std::fstream, CreateFile. What do you like best, both work.
 
Vladimir Simakov:
std::fstream, CreateFile. What do I like better, both work.

Did you check your own advice?

Please try this and no file is created or written I tried manually and it doesn't work either

#include "stdafx.h"
#include <conio.h>
#include <iostream>
#include <fstream>
#include <string>


/*using std::cout;
using std::endl;
using std::cin;*/

using namespace std;


#define _DLLAPI extern "C" __declspec(dllexport)

/*_DLLAPI int __stdcall Funkt(int qa){//"C:\\Program Files(x86)\\Forex4you\\MQL4\\Experts\\Moyperviyzapisfiles.txt\\Moyperviyzapisfiles.txt"
        ofstream file;//"C:\\Users\\123\\Documents\\Visual Studio 2012\\Projects\\ConsoleApplication8\\ConsoleApplication8\\Moyperviyzapisfiles.txt"
        //"C:\\Users\\123\\documents\\visual studio 2012\\Projects\\ConsoleApplication8\\Debug\\ConsoleApplication8.dll\\Moyperviyzapisfiles.txt"
        file.open("C:\\Program Files(x86)\\Forex4you\\MQL4\\Experts\\Moyperviyzapisfiles.txt");//,ios::out
        file<<"Moyperviyzapisfiles";//(string)qa
        file.close();   
        return 12;}*/
The function connects and returns 12 but does not do any file work.
 

Can anyone help where I have the error?


/////////////////////////////////////////////////

// Close the order but only if it is in profit //

/////////////////////////////////////////////////


void CloseIfInProfit(string symb , int index)

{

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

{

if( OrderSelect(i,SELECT_BY_POS,MODE_TRADES) )

{

if( OrderSymbol() == symb )

{

double profit = ( OrderProfit() - OrderCommission () - OrderSwap() );

if( ( ( OrderType() == OP_BUY || OrderType() == OP_SELL) && ( profit >= 0 ) && (OrderMagicNumber() == MAGIC) )

{

OrderClose(OrderTicket(),OrderLots(),MarketInfo(symb,MODE_BID),100,Red); // Close any open orders

ObjectSetText("Text2"+symb,"",TextSize, "Arial"); // Gets rid of entry criteria message.

}

if (OrderType() == OP_BUYSTOP || OrderType() == OP_SELLSTOP)

{

OrderDelete(OrderTicket()); // Delete any pending orders

ObjectSetText("Text2"+symb,"",TextSize, "Arial"); // Gets rid of entry criteria message.

}

}

}

}

partial[index] = false;

}


 

Hello all!

Please help me solve a problem.

I wrote a robot in mql4. I want to rewrite this robot in some close mql language to be able to work on the exchange, such as binance, bimex which have a different trading terminal.

 
Seric29:

Did you check your own advice?

Please try this and no file is created or written I tried manually and it doesn't work either

The function connects and returns 12 but does not work with the files.
Try creating a file where you have access rights)))
 
Fib0 RU:
But when setting lines manually without an indicator, deals open, even if not always. The Expert Advisor does not see the indicator lines.
if((fabs( round((Bid - PriceLine}/Point))<=10)Print (Bid,"  ",PriceLine);

Try looking at the logbook to see what it prints. This is the modulus of the rounded to integer difference divided by the point.