Experts: Self Adapting EA - Deep Learning System - page 2

 
Rodolphe Ahmad #:
What u mean?
what you think on rrocji and ertgh proposal, I would propose similar too? 
 

make mq5 version

to get 100% quality backtest using mt5

 
rrocchi #:

You are absolutely right! This is exactly how it (any A.I. expert) must be trained initially


Hey y'all! Very new to all this. After having read the code, i cant seam to find how and where the patterns are "saved" to a csv. Can someone help walk me through how I may go about saving the learned patterns in back test to load and use on live or demo... 

Thanks in advance!

 
Christ Krishna #:

Hey y'all! Very new to all this. After having read the code, i cant seam to find how and where the patterns are "saved" to a csv. Can someone help walk me through how I may go about saving the learned patterns in back test to load and use on live or demo... 

Thanks in advance!


1. During backtesting, collect patterns and serialize them into a CSV file:


// Define pattern data structure

struct Pattern {

    datetime timestamp;

    double price;

    int patternType;

};



// Array to store collected patterns

Pattern patterns[];

// Function to collect patterns during backtesting

void CollectPattern() {

    Pattern newPattern;

    newPattern.timestamp = TimeCurrent();

    newPattern.price = Close[0];

    newPattern.patternType = 1; // Replace with your own logic to identify pattern types

    

    patterns[ArraySize(patterns)] = newPattern;

}




// Function to serialize patterns into a CSV file

void SerializePatterns() {

    int fileHandle = FileOpen("patterns.csv", FILE_WRITE|FILE_CSV);

    

    for (int i = 0; i < ArraySize(patterns); i++) {

        string line = IntegerToString(patterns[i].timestamp) + "," +

                      DoubleToString(patterns[i].price, _Digits) + "," +

                      IntegerToString(patterns[i].patternType);

        

        FileWriteString(fileHandle, line);

    }

    

    FileClose(fileHandle);

}




2. During real-time trading, load serialized pattern data from the file:


// Array to store loaded patterns

Pattern loadedPatterns[];

// Function to load patterns from CSV file

void LoadPatternsFromFile() {

    int fileHandle = FileOpen("patterns.csv", FILE_READ|FILE_CSV);

    string line;

    while (!FileIsEnding(fileHandle)) {

        if (FileReadString(fileHandle, line) < 0)

            break;

        

        string[] values = StringSplit(line, ',');

        

        Pattern loadedPattern;

        loadedPattern.timestamp = StrToTime(values[0]);

        loadedPattern.price = StrToDouble(values[1]);

        loadedPattern.patternType = StrToInteger(values[2]);

        

        loadedPatterns[ArraySize(loadedPatterns)] = loadedPattern;

    }

    

    FileClose(fileHandle);

}



3. Perform real-time trading using the stored patterns:



// Function to use stored patterns for trading

void TradeUsingPatterns() {

    // Use the loaded patterns in your trading logic

    for (int i = 0; i < ArraySize(loadedPatterns); i++) {

        // Check for pattern matches and place trades accordingly

        // Replace this with your own trading strategy

        

        if (loadedPatterns[i].patternType == 1) {

            // Place a buy trade

            OrderSend(Symbol(), OP_BUY, 0.01, loadedPatterns[i].price, 0, 0, 0, "Pattern Trade", MagicNumber, 0, Green);

        } else if (loadedPatterns[i].patternType == 2) {

            // Place a sell trade

            OrderSend(Symbol(), OP_SELL, 0.01, loadedPatterns[i].price, 0, 0, 0, "Pattern Trade", MagicNumber, 0, Red);

        }

    }

}