|
4 registered members (clint000, TipmyPip, vince, 1 invisible),
28,447
guests, and 6
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Xor Memory Problem.
[Re: NewtraderX]
#488010
12/26/23 16:02
12/26/23 16:02
|
Joined: Sep 2017
Posts: 289
TipmyPip
OP
Member
|
OP
Member
Joined: Sep 2017
Posts: 289
|
>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
NewBorn
Guest
|
Guest
Joined: Sep 2020
Posts: 2
|
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. // 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.
|
|
|
|