Gamestudio Links
Zorro Links
Newest Posts
long time to load data
by qin. 12/29/25 14:06
The new evaluation shell
by jcl. 12/29/25 09:56
about Zorro S (monthly)
by AndrewAMD. 12/29/25 03:24
Xor Memory Problem.
by TipmyPip. 12/26/25 19:14
ZorroFix. ini /data and /log path
by Martin_HH. 12/19/25 21:02
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (vicknick), 81,396 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Syndrela, HDRSEO, AOUNZA, digitalboy381, agasior
19190 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 3 of 3 1 2 3
Re: Xor Memory Problem. [Re: NewtraderX] #488010
12/26/23 16:02
12/26/23 16:02
Joined: Sep 2017
Posts: 177
TipmyPip Offline OP
Member
TipmyPip  Offline OP
Member

Joined: Sep 2017
Posts: 177
>int binaryPriceX[length];
>int binaryPriceY[length];


Thank you for your interest, the definition of the above is based on different ideas for trading, if you try Zorro Trader GPT, you can create your own definitions for new strategies, and it is not difficult, Very easy...
We encourage you to explore your ideas and share them with us...

For example :

binaryPriceX[MAX_LENGTH]: This array stores the binary representation of the current price data. The conversion to binary is based on a specific condition. In the example, this condition is whether each price is greater than the first price in the lookback period. This is done in the ConvertToBinary function. For each price in the ClosePrices data series:

If the price is greater than the first price in the series (ClosePrices[0]), the corresponding element in binaryPriceX is set to 1.
If the price is less than or equal to the first price in the series, the corresponding element in binaryPriceX is set to 0.
binaryPriceY[MAX_LENGTH]: This array stores the binary representation of the Simple Moving Average (SMA) of the price data. The SMA is calculated over a specified period (20 periods in your example). The conversion to binary follows the same logic as binaryPriceX, comparing each SMA value to the first price in the ClosePrices series.

If the SMA value is greater than ClosePrices[0], the corresponding element in binaryPriceY is set to 1.
If the SMA value is less than or equal to ClosePrices[0], the corresponding element in binaryPriceY is set to 0.
These binary representations are then used for further analysis, such as the XOR operation in your strategy. The XOR operation compares the corresponding binary values in binaryPriceX and binaryPriceY for each period. The result of this operation (stored in xorResult) can indicate differences or divergences between the current price trend and its moving average, which you use to make trading decisions.

Last edited by TipmyPip; 12/26/23 16:14.
Re: Xor Memory Problem. [Re: TipmyPip] #489047
12/26/25 06:01
12/26/25 06:01
Joined: Sep 2020
Posts: 2
N
NewBorn Offline
Guest
NewBorn  Offline
Guest
N

Joined: Sep 2020
Posts: 2
Originally Posted by TipmyPip
Here is another strategy to help those who find the relation between the abstract currency moves in different timeframes and their relation to other currency moves.
If anyone has great ideas to share, I am quite sure money is already flowing in your world of creation and inspired beyond this physical world of desire.

Code
// Function prototypes
void ConvertToBinary(vars priceData, int* binaryRepresentation, int length);
void XORBinaryLists(int* list1, int* list2, int* result, int length);
int FindMaximumXOR(int* xorResult, int length);

void run() 
{
    // Set parameters
    BarPeriod = 60; // 1-hour bars
    StartDate = 2020;
    EndDate = 2021;
    LookBack = 100; // Look back period for initialization

    // Define the list of currency pairs
    string pairs[] = {"EURUSD", "GBPUSD", "USDJPY", "GBPJPY", "USDCAD", "EURAUD", "EURJPY", "AUDCAD",
               "AUDJPY", "AUDNZD", "AUDUSD", "CADJPY", "EURCAD", "EURCHF", "EURGBP", "EURNZD", 
               "GBPCAD", "GBPCHF", "NZDCAD", "NZDJPY", "NZDUSD", "USDCHF", "CHFJPY", "AUDCHF", 
               "GBPNZD", "NZDCHF", "CADCHF", "GBPAUD"
    int numPairs = sizeof(pairs) / sizeof(string);

    // Loop through each currency pair
    for(int i = 0; i < numPairs; i++) 
    {
        asset(pairs[i]);
        vars ClosePrices = series(priceClose());

        // Prepare binary representations for XOR operation
        int length = LookBack;
        int binaryPriceX[length];
        int binaryPriceY[length];

        // Fill binary representations (example: comparing current prices with a moving average)
        ConvertToBinary(ClosePrices, binaryPriceX, length);
        ConvertToBinary(series(SMA(ClosePrices, 20)), binaryPriceY, length); // 20-period SMA for comparison

        // Perform XOR operation
        int xorResult[length];
        XORBinaryLists(binaryPriceX, binaryPriceY, xorResult, length);

        // Find Maximum XOR value
        int max_xor = FindMaximumXOR(xorResult, length);

        // Example trading logic based on Maximum XOR
        if(max_xor == 1) // Significant divergence detected
            enterLong();
        else
            exitLong();
    }
}

void ConvertToBinary(vars priceData, int* binaryRepresentation, int length) 
{
    int i;
    for(i = 0; i < length; i++) 
    {
        binaryRepresentation[i] = (priceData[i] > priceData[0]) ? 1 : 0;
    }
}

void XORBinaryLists(int* list1, int* list2, int* result, int length) 
{
    int i;
    for(i = 0; i < length; i++) 
    {
        result[i] = list1[i] ^ list2[i];
    }
}

int FindMaximumXOR(int* xorResult, int length) 
{
    int max_xor = 0;
    for(int i = 0; i < length; i++) 
    {
        if(xorResult[i] > max_xor) 
            max_xor = xorResult[i];
    }
    return max_xor;
}


Thank you to the Team of Zorro Trader, who have inspired my life.


Dear TipMyPip,

Such a creative and interesting idea and contribution you shared to us.
I am checking your idea with other AI due to my lack of programming background.
From your say "different timeframe", I did not see it in the code. All execution is within 60 BarPeriod.
Do you mind to enlighten me?
I will try to add currency strength and regime detection to make basket trading and I want this to scan different timeframe to make conclusion all agreed on the decision.

Thank you


Last edited by NewBorn; 12/26/25 06:04.
Re: Xor Memory Problem. [Re: NewBorn] #489048
12/26/25 19:14
12/26/25 19:14
Joined: Sep 2017
Posts: 177
TipmyPip Offline OP
Member
TipmyPip  Offline OP
Member

Joined: Sep 2017
Posts: 177
Thank you for your kind words, you can use the ZorroGPT in order to expand the use on different timeframes or simultaneous.
you are most welcome, It would be great if you share your ideas too...

Page 3 of 3 1 2 3

Moderated by  Petra 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1